diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2017-06-18 10:15:02 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-18 10:15:02 -0400 |
| commit | 51a86b85f35769533124d209c990aee18965ea6b (patch) | |
| tree | 9951b7b99125472ffc4c4af15a764a0083dc1297 /quantum | |
| parent | 7feadbd66d5c80b1c39c565864bb1af0d1e87874 (diff) | |
| parent | 086aad0d7e5770e0be36498e5f569af5a23b111c (diff) | |
| download | qmk_firmware-51a86b85f35769533124d209c990aee18965ea6b.tar.gz qmk_firmware-51a86b85f35769533124d209c990aee18965ea6b.zip | |
Merge pull request #1361 from fredizzimo/ergodox_infinity_backlight
Add Ergodox Infinity backlight support
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/visualizer/led_keyframes.c | 14 | ||||
| -rw-r--r-- | quantum/visualizer/led_keyframes.h | 3 | ||||
| -rw-r--r-- | quantum/visualizer/visualizer.c | 34 | ||||
| -rw-r--r-- | quantum/visualizer/visualizer.h | 9 | ||||
| -rw-r--r-- | quantum/visualizer/visualizer.mk | 3 |
5 files changed, 57 insertions, 6 deletions
diff --git a/quantum/visualizer/led_keyframes.c b/quantum/visualizer/led_keyframes.c index 2dacd990d..c14491e5e 100644 --- a/quantum/visualizer/led_keyframes.c +++ b/quantum/visualizer/led_keyframes.c | |||
| @@ -127,3 +127,17 @@ bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer | |||
| 127 | gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); | 127 | gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); |
| 128 | return false; | 128 | return false; |
| 129 | } | 129 | } |
| 130 | |||
| 131 | bool led_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 132 | (void)state; | ||
| 133 | (void)animation; | ||
| 134 | gdispGSetPowerMode(LED_DISPLAY, powerOff); | ||
| 135 | return false; | ||
| 136 | } | ||
| 137 | |||
| 138 | bool led_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 139 | (void)state; | ||
| 140 | (void)animation; | ||
| 141 | gdispGSetPowerMode(LED_DISPLAY, powerOn); | ||
| 142 | return false; | ||
| 143 | } | ||
diff --git a/quantum/visualizer/led_keyframes.h b/quantum/visualizer/led_keyframes.h index a68943041..a59a4f37d 100644 --- a/quantum/visualizer/led_keyframes.h +++ b/quantum/visualizer/led_keyframes.h | |||
| @@ -35,6 +35,9 @@ bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* | |||
| 35 | bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state); | 35 | bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state); |
| 36 | bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state); | 36 | bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state); |
| 37 | 37 | ||
| 38 | bool led_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 39 | bool led_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 40 | |||
| 38 | extern keyframe_animation_t led_test_animation; | 41 | extern keyframe_animation_t led_test_animation; |
| 39 | 42 | ||
| 40 | 43 | ||
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 6f134097f..486ff25b3 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c | |||
| @@ -58,8 +58,11 @@ SOFTWARE. | |||
| 58 | static visualizer_keyboard_status_t current_status = { | 58 | static visualizer_keyboard_status_t current_status = { |
| 59 | .layer = 0xFFFFFFFF, | 59 | .layer = 0xFFFFFFFF, |
| 60 | .default_layer = 0xFFFFFFFF, | 60 | .default_layer = 0xFFFFFFFF, |
| 61 | .mods = 0xFF, | ||
| 62 | .leds = 0xFFFFFFFF, | 61 | .leds = 0xFFFFFFFF, |
| 62 | #ifdef BACKLIGHT_ENABLE | ||
| 63 | .backlight_level = 0, | ||
| 64 | #endif | ||
| 65 | .mods = 0xFF, | ||
| 63 | .suspended = false, | 66 | .suspended = false, |
| 64 | #ifdef VISUALIZER_USER_DATA_SIZE | 67 | #ifdef VISUALIZER_USER_DATA_SIZE |
| 65 | .user_data = {0} | 68 | .user_data = {0} |
| @@ -72,6 +75,9 @@ static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboa | |||
| 72 | status1->mods == status2->mods && | 75 | status1->mods == status2->mods && |
| 73 | status1->leds == status2->leds && | 76 | status1->leds == status2->leds && |
| 74 | status1->suspended == status2->suspended | 77 | status1->suspended == status2->suspended |
| 78 | #ifdef BACKLIGHT_ENABLE | ||
| 79 | && status1->backlight_level == status2->backlight_level | ||
| 80 | #endif | ||
| 75 | #ifdef VISUALIZER_USER_DATA_SIZE | 81 | #ifdef VISUALIZER_USER_DATA_SIZE |
| 76 | && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 | 82 | && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 |
| 77 | #endif | 83 | #endif |
| @@ -279,6 +285,18 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
| 279 | bool enabled = visualizer_enabled; | 285 | bool enabled = visualizer_enabled; |
| 280 | if (force_update || !same_status(&state.status, ¤t_status)) { | 286 | if (force_update || !same_status(&state.status, ¤t_status)) { |
| 281 | force_update = false; | 287 | force_update = false; |
| 288 | #if BACKLIGHT_ENABLE | ||
| 289 | if(current_status.backlight_level != state.status.backlight_level) { | ||
| 290 | if (current_status.backlight_level != 0) { | ||
| 291 | gdispGSetPowerMode(LED_DISPLAY, powerOn); | ||
| 292 | uint16_t percent = (uint16_t)current_status.backlight_level * 100 / BACKLIGHT_LEVELS; | ||
| 293 | gdispGSetBacklight(LED_DISPLAY, percent); | ||
| 294 | } | ||
| 295 | else { | ||
| 296 | gdispGSetPowerMode(LED_DISPLAY, powerOff); | ||
| 297 | } | ||
| 298 | } | ||
| 299 | #endif | ||
| 282 | if (visualizer_enabled) { | 300 | if (visualizer_enabled) { |
| 283 | if (current_status.suspended) { | 301 | if (current_status.suspended) { |
| 284 | stop_all_keyframe_animations(); | 302 | stop_all_keyframe_animations(); |
| @@ -309,7 +327,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
| 309 | update_keyframe_animation(animations[i], &state, delta, &sleep_time); | 327 | update_keyframe_animation(animations[i], &state, delta, &sleep_time); |
| 310 | } | 328 | } |
| 311 | } | 329 | } |
| 312 | #ifdef LED_ENABLE | 330 | #ifdef BACKLIGHT_ENABLE |
| 313 | gdispGFlush(LED_DISPLAY); | 331 | gdispGFlush(LED_DISPLAY); |
| 314 | #endif | 332 | #endif |
| 315 | 333 | ||
| @@ -372,7 +390,7 @@ void visualizer_init(void) { | |||
| 372 | #ifdef LCD_ENABLE | 390 | #ifdef LCD_ENABLE |
| 373 | LCD_DISPLAY = get_lcd_display(); | 391 | LCD_DISPLAY = get_lcd_display(); |
| 374 | #endif | 392 | #endif |
| 375 | #ifdef LED_ENABLE | 393 | #ifdef BACKLIGHT_ENABLE |
| 376 | LED_DISPLAY = get_led_display(); | 394 | LED_DISPLAY = get_led_display(); |
| 377 | #endif | 395 | #endif |
| 378 | 396 | ||
| @@ -445,6 +463,9 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uin | |||
| 445 | .default_layer = default_state, | 463 | .default_layer = default_state, |
| 446 | .mods = mods, | 464 | .mods = mods, |
| 447 | .leds = leds, | 465 | .leds = leds, |
| 466 | #ifdef BACKLIGHT_ENABLE | ||
| 467 | .backlight_level = current_status.backlight_level, | ||
| 468 | #endif | ||
| 448 | .suspended = current_status.suspended, | 469 | .suspended = current_status.suspended, |
| 449 | }; | 470 | }; |
| 450 | #ifdef VISUALIZER_USER_DATA_SIZE | 471 | #ifdef VISUALIZER_USER_DATA_SIZE |
| @@ -467,3 +488,10 @@ void visualizer_resume(void) { | |||
| 467 | current_status.suspended = false; | 488 | current_status.suspended = false; |
| 468 | update_status(true); | 489 | update_status(true); |
| 469 | } | 490 | } |
| 491 | |||
| 492 | #ifdef BACKLIGHT_ENABLE | ||
| 493 | void backlight_set(uint8_t level) { | ||
| 494 | current_status.backlight_level = level; | ||
| 495 | update_status(true); | ||
| 496 | } | ||
| 497 | #endif | ||
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h index d6f279e10..1c567440f 100644 --- a/quantum/visualizer/visualizer.h +++ b/quantum/visualizer/visualizer.h | |||
| @@ -34,6 +34,10 @@ SOFTWARE. | |||
| 34 | #include "lcd_backlight.h" | 34 | #include "lcd_backlight.h" |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | #ifdef BACKLIGHT_ENABLE | ||
| 38 | #include "backlight.h" | ||
| 39 | #endif | ||
| 40 | |||
| 37 | // use this function to merge both real_mods and oneshot_mods in a uint16_t | 41 | // use this function to merge both real_mods and oneshot_mods in a uint16_t |
| 38 | uint8_t visualizer_get_mods(void); | 42 | uint8_t visualizer_get_mods(void); |
| 39 | 43 | ||
| @@ -65,9 +69,12 @@ struct keyframe_animation_t; | |||
| 65 | typedef struct { | 69 | typedef struct { |
| 66 | uint32_t layer; | 70 | uint32_t layer; |
| 67 | uint32_t default_layer; | 71 | uint32_t default_layer; |
| 68 | uint8_t mods; | ||
| 69 | uint32_t leds; // See led.h for available statuses | 72 | uint32_t leds; // See led.h for available statuses |
| 73 | uint8_t mods; | ||
| 70 | bool suspended; | 74 | bool suspended; |
| 75 | #ifdef BACKLIGHT_ENABLE | ||
| 76 | uint8_t backlight_level; | ||
| 77 | #endif | ||
| 71 | #ifdef VISUALIZER_USER_DATA_SIZE | 78 | #ifdef VISUALIZER_USER_DATA_SIZE |
| 72 | uint8_t user_data[VISUALIZER_USER_DATA_SIZE]; | 79 | uint8_t user_data[VISUALIZER_USER_DATA_SIZE]; |
| 73 | #endif | 80 | #endif |
diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk index 5f710124b..6f97603bd 100644 --- a/quantum/visualizer/visualizer.mk +++ b/quantum/visualizer/visualizer.mk | |||
| @@ -42,9 +42,8 @@ SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c | |||
| 42 | OPT_DEFS += -DLCD_BACKLIGHT_ENABLE | 42 | OPT_DEFS += -DLCD_BACKLIGHT_ENABLE |
| 43 | endif | 43 | endif |
| 44 | 44 | ||
| 45 | ifeq ($(strip $(LED_ENABLE)), yes) | 45 | ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) |
| 46 | SRC += $(VISUALIZER_DIR)/led_keyframes.c | 46 | SRC += $(VISUALIZER_DIR)/led_keyframes.c |
| 47 | OPT_DEFS += -DLED_ENABLE | ||
| 48 | endif | 47 | endif |
| 49 | 48 | ||
| 50 | include $(GFXLIB)/gfx.mk | 49 | include $(GFXLIB)/gfx.mk |
