diff options
| -rw-r--r-- | keyboards/ergodox/infinity/infinity.c | 29 | ||||
| -rw-r--r-- | keyboards/ergodox/infinity/visualizer.c | 6 |
2 files changed, 29 insertions, 6 deletions
diff --git a/keyboards/ergodox/infinity/infinity.c b/keyboards/ergodox/infinity/infinity.c index 02db67eaf..ecc072abb 100644 --- a/keyboards/ergodox/infinity/infinity.c +++ b/keyboards/ergodox/infinity/infinity.c | |||
| @@ -70,10 +70,33 @@ void lcd_backlight_hal_init(void) { | |||
| 70 | RGB_PORT->PCR[BLUE_PIN] = RGB_MODE; | 70 | RGB_PORT->PCR[BLUE_PIN] = RGB_MODE; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | static uint16_t cie_lightness(uint16_t v) { | ||
| 74 | // The CIE 1931 formula for lightness | ||
| 75 | // Y = luminance (output) 0-1 | ||
| 76 | // L = lightness input 0 - 100 | ||
| 77 | |||
| 78 | // Y = (L* / 902.3) if L* <= 8 | ||
| 79 | // Y = ((L* + 16) / 116)^3 if L* > 8 | ||
| 80 | |||
| 81 | float l = 100.0f * (v / 65535.0f); | ||
| 82 | float y = 0.0f; | ||
| 83 | if (l <= 8.0f) { | ||
| 84 | y = l / 902.3; | ||
| 85 | } | ||
| 86 | else { | ||
| 87 | y = ((l + 16.0f) / 116.0f); | ||
| 88 | y = y * y * y; | ||
| 89 | if (y > 1.0f) { | ||
| 90 | y = 1.0f; | ||
| 91 | } | ||
| 92 | } | ||
| 93 | return y * 65535.0f; | ||
| 94 | } | ||
| 95 | |||
| 73 | void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) { | 96 | void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) { |
| 74 | CHANNEL_RED.CnV = r; | 97 | CHANNEL_RED.CnV = cie_lightness(r); |
| 75 | CHANNEL_GREEN.CnV = g; | 98 | CHANNEL_GREEN.CnV = cie_lightness(g); |
| 76 | CHANNEL_BLUE.CnV = b; | 99 | CHANNEL_BLUE.CnV = cie_lightness(b); |
| 77 | } | 100 | } |
| 78 | 101 | ||
| 79 | __attribute__ ((weak)) | 102 | __attribute__ ((weak)) |
diff --git a/keyboards/ergodox/infinity/visualizer.c b/keyboards/ergodox/infinity/visualizer.c index c8fc3d78e..12336fdc5 100644 --- a/keyboards/ergodox/infinity/visualizer.c +++ b/keyboards/ergodox/infinity/visualizer.c | |||
| @@ -70,8 +70,8 @@ static const uint8_t image_data_lcd_logo[512] = { | |||
| 70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| 73 | static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0x80); | 73 | static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); |
| 74 | static const uint32_t initial_color = LCD_COLOR(0, 0, 0xFF); | 74 | static const uint32_t initial_color = LCD_COLOR(0, 0, 0); |
| 75 | 75 | ||
| 76 | bool display_logo(keyframe_animation_t* animation, visualizer_state_t* state) { | 76 | bool display_logo(keyframe_animation_t* animation, visualizer_state_t* state) { |
| 77 | (void)state; | 77 | (void)state; |
| @@ -155,7 +155,7 @@ static keyframe_animation_t resume_animation = { | |||
| 155 | void initialize_user_visualizer(visualizer_state_t* state) { | 155 | void initialize_user_visualizer(visualizer_state_t* state) { |
| 156 | // The brightness will be dynamically adjustable in the future | 156 | // The brightness will be dynamically adjustable in the future |
| 157 | // But for now, change it here. | 157 | // But for now, change it here. |
| 158 | lcd_backlight_brightness(0x50); | 158 | lcd_backlight_brightness(130); |
| 159 | state->current_lcd_color = initial_color; | 159 | state->current_lcd_color = initial_color; |
| 160 | state->target_lcd_color = logo_background_color; | 160 | state->target_lcd_color = logo_background_color; |
| 161 | start_keyframe_animation(&startup_animation); | 161 | start_keyframe_animation(&startup_animation); |
