diff options
author | jpetermans <tibcmhhm@gmail.com> | 2017-05-24 11:51:20 -0700 |
---|---|---|
committer | jpetermans <tibcmhhm@gmail.com> | 2017-05-24 11:51:20 -0700 |
commit | 2dcd6c38fa478b40a973c9411c3f5b4c87ae0ba7 (patch) | |
tree | 289d5cce94ad5883741f0b637749d87680c14d33 /keyboards/ergodox/infinity/infinity.c | |
parent | d89114400c398b900e27bf324a7973d1e0f25e58 (diff) | |
parent | 7a4ec3bd926865e490fbf7c5ec68d762e998683f (diff) |
Merge remote-tracking branch 'upstream/master' into infinity60
Diffstat (limited to 'keyboards/ergodox/infinity/infinity.c')
-rw-r--r-- | keyboards/ergodox/infinity/infinity.c | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/keyboards/ergodox/infinity/infinity.c b/keyboards/ergodox/infinity/infinity.c index 02db67eaf2..62259ed3f6 100644 --- a/keyboards/ergodox/infinity/infinity.c +++ b/keyboards/ergodox/infinity/infinity.c @@ -70,10 +70,33 @@ void lcd_backlight_hal_init(void) { RGB_PORT->PCR[BLUE_PIN] = RGB_MODE; } +static uint16_t cie_lightness(uint16_t v) { + // The CIE 1931 formula for lightness + // Y = luminance (output) 0-1 + // L = lightness input 0 - 100 + + // Y = (L* / 902.3) if L* <= 8 + // Y = ((L* + 16) / 116)^3 if L* > 8 + + float l = 100.0f * (v / 65535.0f); + float y = 0.0f; + if (l <= 8.0f) { + y = l / 902.3; + } + else { + y = ((l + 16.0f) / 116.0f); + y = y * y * y; + if (y > 1.0f) { + y = 1.0f; + } + } + return y * 65535.0f; +} + void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) { - CHANNEL_RED.CnV = r; - CHANNEL_GREEN.CnV = g; - CHANNEL_BLUE.CnV = b; + CHANNEL_RED.CnV = cie_lightness(r); + CHANNEL_GREEN.CnV = cie_lightness(g); + CHANNEL_BLUE.CnV = cie_lightness(b); } __attribute__ ((weak)) @@ -103,34 +126,48 @@ void matrix_scan_kb(void) { matrix_scan_user(); } +__attribute__ ((weak)) void ergodox_board_led_on(void){ } +__attribute__ ((weak)) void ergodox_right_led_1_on(void){ } +__attribute__ ((weak)) void ergodox_right_led_2_on(void){ } +__attribute__ ((weak)) void ergodox_right_led_3_on(void){ } -void ergodox_right_led_on(uint8_t led){ -} - +__attribute__ ((weak)) void ergodox_board_led_off(void){ } +__attribute__ ((weak)) void ergodox_right_led_1_off(void){ } +__attribute__ ((weak)) void ergodox_right_led_2_off(void){ } +__attribute__ ((weak)) void ergodox_right_led_3_off(void){ } -void ergodox_right_led_off(uint8_t led){ +__attribute__ ((weak)) +void ergodox_right_led_1_set(uint8_t n) { +} + +__attribute__ ((weak)) +void ergodox_right_led_2_set(uint8_t n) { +} + +__attribute__ ((weak)) +void ergodox_right_led_3_set(uint8_t n) { } #ifdef ONEHAND_ENABLE |