diff options
Diffstat (limited to 'keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.c')
| -rw-r--r-- | keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.c | 147 |
1 files changed, 144 insertions, 3 deletions
diff --git a/keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.c b/keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.c index 6842635d1..7bd5a0783 100644 --- a/keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.c +++ b/keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.c | |||
| @@ -12,7 +12,140 @@ You should have received a copy of the GNU General Public License | |||
| 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 13 | */ | 13 | */ |
| 14 | 14 | ||
| 15 | #include "simple_visualizer.h" | 15 | #include "visualizer.h" |
| 16 | #include "gfx.h" | ||
| 17 | #include "math.h" | ||
| 18 | #include "default_animations.h" | ||
| 19 | #include "led_backlight_keyframes.h" | ||
| 20 | |||
| 21 | #define ONESIDESCAN 9 | ||
| 22 | #define BOTHSIDESCAN 16 | ||
| 23 | #define FULL_ON LUMA2COLOR(255) | ||
| 24 | #define THREE_QUARTER LUMA2COLOR(200) | ||
| 25 | #define HALF_ON LUMA2COLOR(150) | ||
| 26 | #define ONE_QUARTER LUMA2COLOR(50) | ||
| 27 | #define CROSSFADE_TIME 8000 | ||
| 28 | bool KITT_scan_one_side_left_to_right(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 29 | bool KITT_scan_one_side_right_to_left(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 30 | keyframe_animation_t Fade_in_all_leds = { | ||
| 31 | .num_frames = 1, | ||
| 32 | .loop = false, | ||
| 33 | .frame_lengths = { | ||
| 34 | CROSSFADE_TIME, | ||
| 35 | }, | ||
| 36 | .frame_functions = { | ||
| 37 | led_backlight_keyframe_fade_in_all, | ||
| 38 | }, | ||
| 39 | }; | ||
| 40 | /* | ||
| 41 | * one set left to right. then reverse to go back. | ||
| 42 | * | left side | right side | | | ||
| 43 | |---|---|---|---|---|---|---|:-:|---|---|---|---|---|---|-------| | ||
| 44 | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | phase | | ||
| 45 | _________________________________________________________________ | ||
| 46 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | ||
| 47 | | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | | ||
| 48 | | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | | ||
| 49 | | 1 | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | | ||
| 50 | | 0 | 1 | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | | ||
| 51 | | 0 | 0 | 1 | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | | ||
| 52 | | 0 | 0 | 0 | 1 | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 6 | | ||
| 53 | | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | | ||
| 54 | | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | | ||
| 55 | | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 9 | | ||
| 56 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 0 | 0 | 0 | 0 | 10 | | ||
| 57 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 0 | 0 | 0 | 11 | | ||
| 58 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 0 | 0 | 12 | | ||
| 59 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 0 | 13 | | ||
| 60 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 14 | | ||
| 61 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 15 | | ||
| 62 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 16 | | ||
| 63 | */ | ||
| 64 | |||
| 65 | #ifdef MASTER_IS_ON_RIGHT /*right side*/ | ||
| 66 | |||
| 67 | keyframe_animation_t KITT_Scanner_animation = { | ||
| 68 | .num_frames = 2, | ||
| 69 | .loop = true, | ||
| 70 | .frame_lengths = { | ||
| 71 | CROSSFADE_TIME * BOTHSIDESCAN, | ||
| 72 | CROSSFADE_TIME * BOTHSIDESCAN, | ||
| 73 | }, | ||
| 74 | .frame_functions = { | ||
| 75 | KITT_scan_one_side_left_to_right, | ||
| 76 | KITT_scan_one_side_right_to_left, | ||
| 77 | }, | ||
| 78 | }; | ||
| 79 | |||
| 80 | bool KITT_scan_one_side_left_to_right(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 81 | (void)state; | ||
| 82 | float frame_length = animation->frame_lengths[animation->current_frame]; | ||
| 83 | float current_pos = frame_length - animation->time_left_in_frame; | ||
| 84 | int phase = current_pos/(frame_length/BOTHSIDESCAN); | ||
| 85 | int row = 0; | ||
| 86 | gdispGClear(LED_DISPLAY, ONE_QUARTER); | ||
| 87 | gdispGDrawPixel(LED_DISPLAY, 14-phase, row, FULL_ON); | ||
| 88 | gdispGDrawPixel(LED_DISPLAY, 15-phase, row, THREE_QUARTER); | ||
| 89 | gdispGDrawPixel(LED_DISPLAY, 16-phase, row, HALF_ON); | ||
| 90 | gdispGDrawPixel(LED_DISPLAY, 6, row, ONE_QUARTER); | ||
| 91 | return true; | ||
| 92 | } | ||
| 93 | |||
| 94 | bool KITT_scan_one_side_right_to_left(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 95 | (void)state; | ||
| 96 | float frame_length = animation->frame_lengths[animation->current_frame]; | ||
| 97 | float current_pos = frame_length - animation->time_left_in_frame; | ||
| 98 | int phase = current_pos/(frame_length/BOTHSIDESCAN); | ||
| 99 | int row = 0; | ||
| 100 | gdispGClear(LED_DISPLAY, ONE_QUARTER); | ||
| 101 | gdispGDrawPixel(LED_DISPLAY, phase, row, FULL_ON); | ||
| 102 | gdispGDrawPixel(LED_DISPLAY, phase-1, row, THREE_QUARTER); | ||
| 103 | gdispGDrawPixel(LED_DISPLAY, phase-2, row, HALF_ON); | ||
| 104 | gdispGDrawPixel(LED_DISPLAY, 6, row, ONE_QUARTER); | ||
| 105 | return true; | ||
| 106 | } | ||
| 107 | #else /*left side*/ | ||
| 108 | keyframe_animation_t KITT_Scanner_animation = { | ||
| 109 | .num_frames = 2, | ||
| 110 | .loop = true, | ||
| 111 | .frame_lengths = { | ||
| 112 | CROSSFADE_TIME * BOTHSIDESCAN, | ||
| 113 | CROSSFADE_TIME * BOTHSIDESCAN, | ||
| 114 | }, | ||
| 115 | .frame_functions = { | ||
| 116 | KITT_scan_one_side_left_to_right, | ||
| 117 | KITT_scan_one_side_right_to_left, | ||
| 118 | }, | ||
| 119 | }; | ||
| 120 | |||
| 121 | bool KITT_scan_one_side_left_to_right(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 122 | (void)state; | ||
| 123 | float frame_length = animation->frame_lengths[animation->current_frame]; | ||
| 124 | float current_pos = frame_length - animation->time_left_in_frame; | ||
| 125 | int phase = current_pos/(frame_length/BOTHSIDESCAN); | ||
| 126 | int row = 0; | ||
| 127 | gdispGClear(LED_DISPLAY, ONE_QUARTER); | ||
| 128 | gdispGDrawPixel(LED_DISPLAY, phase, row, FULL_ON); | ||
| 129 | gdispGDrawPixel(LED_DISPLAY, phase-1, row, THREE_QUARTER); | ||
| 130 | gdispGDrawPixel(LED_DISPLAY, phase-2, row, HALF_ON); | ||
| 131 | gdispGDrawPixel(LED_DISPLAY, 6, row, ONE_QUARTER); | ||
| 132 | return true; | ||
| 133 | } | ||
| 134 | |||
| 135 | bool KITT_scan_one_side_right_to_left(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 136 | (void)state; | ||
| 137 | float frame_length = animation->frame_lengths[animation->current_frame]; | ||
| 138 | float current_pos = frame_length - animation->time_left_in_frame; | ||
| 139 | int phase = current_pos/(frame_length/BOTHSIDESCAN); | ||
| 140 | int row = 0; | ||
| 141 | gdispGClear(LED_DISPLAY, ONE_QUARTER); | ||
| 142 | gdispGDrawPixel(LED_DISPLAY, (14 - phase), row, FULL_ON); | ||
| 143 | gdispGDrawPixel(LED_DISPLAY, 14 - (phase-1), row, THREE_QUARTER); | ||
| 144 | gdispGDrawPixel(LED_DISPLAY, 14 - (phase-2), row, HALF_ON); | ||
| 145 | gdispGDrawPixel(LED_DISPLAY, 6, row, ONE_QUARTER); | ||
| 146 | return true; | ||
| 147 | } | ||
| 148 | #endif | ||
| 16 | 149 | ||
| 17 | #define RED 0 | 150 | #define RED 0 |
| 18 | #define ORANGE 21 | 151 | #define ORANGE 21 |
| @@ -37,13 +170,19 @@ static void get_visualizer_layer_and_color(visualizer_state_t* state) { | |||
| 37 | /* if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) { | 170 | /* if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) { |
| 38 | saturation = 255; | 171 | saturation = 255; |
| 39 | } */ | 172 | } */ |
| 40 | if (state->status.layer & 0x100) { | 173 | if (state->status.layer & 0x200) { |
| 174 | state->target_lcd_color = LCD_COLOR(GREEN, saturation, 0xFF); | ||
| 175 | state->layer_text = "MOUSE"; | ||
| 176 | } | ||
| 177 | else if (state->status.layer & 0x100) { | ||
| 41 | state->target_lcd_color = LCD_COLOR(MAGENTA, saturation, 0xFF); | 178 | state->target_lcd_color = LCD_COLOR(MAGENTA, saturation, 0xFF); |
| 42 | state->layer_text = "Shortcuts Layer"; | 179 | state->layer_text = "Shortcuts Layer"; |
| 43 | } | 180 | } |
| 44 | else if (state->status.layer & 0x80) { | 181 | else if (state->status.layer & 0x80) { |
| 45 | state->target_lcd_color = LCD_COLOR(VIOLET, saturation, 0xFF); | 182 | state->target_lcd_color = LCD_COLOR(VIOLET, saturation, 0xFF); |
| 46 | state->layer_text = "Plover"; | 183 | state->layer_text = "Plover"; |
| 184 | start_keyframe_animation(&KITT_Scanner_animation); | ||
| 185 | |||
| 47 | } | 186 | } |
| 48 | else if (state->status.layer & 0x40) { | 187 | else if (state->status.layer & 0x40) { |
| 49 | state->target_lcd_color = LCD_COLOR(RASPBERRY, saturation, 0xFF); | 188 | state->target_lcd_color = LCD_COLOR(RASPBERRY, saturation, 0xFF); |
| @@ -68,5 +207,7 @@ static void get_visualizer_layer_and_color(visualizer_state_t* state) { | |||
| 68 | else { | 207 | else { |
| 69 | state->target_lcd_color = LCD_COLOR(YELLOW, saturation, 0xFF); | 208 | state->target_lcd_color = LCD_COLOR(YELLOW, saturation, 0xFF); |
| 70 | state->layer_text = "Qwerty"; | 209 | state->layer_text = "Qwerty"; |
| 210 | stop_keyframe_animation(&KITT_Scanner_animation); | ||
| 211 | start_keyframe_animation(&Fade_in_all_leds); | ||
| 71 | } | 212 | } |
| 72 | } \ No newline at end of file | 213 | } |
