diff options
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 02db67eaf..62259ed3f 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)) |
| @@ -103,34 +126,48 @@ void matrix_scan_kb(void) { | |||
| 103 | matrix_scan_user(); | 126 | matrix_scan_user(); |
| 104 | } | 127 | } |
| 105 | 128 | ||
| 129 | __attribute__ ((weak)) | ||
| 106 | void ergodox_board_led_on(void){ | 130 | void ergodox_board_led_on(void){ |
| 107 | } | 131 | } |
| 108 | 132 | ||
| 133 | __attribute__ ((weak)) | ||
| 109 | void ergodox_right_led_1_on(void){ | 134 | void ergodox_right_led_1_on(void){ |
| 110 | } | 135 | } |
| 111 | 136 | ||
| 137 | __attribute__ ((weak)) | ||
| 112 | void ergodox_right_led_2_on(void){ | 138 | void ergodox_right_led_2_on(void){ |
| 113 | } | 139 | } |
| 114 | 140 | ||
| 141 | __attribute__ ((weak)) | ||
| 115 | void ergodox_right_led_3_on(void){ | 142 | void ergodox_right_led_3_on(void){ |
| 116 | } | 143 | } |
| 117 | 144 | ||
| 118 | void ergodox_right_led_on(uint8_t led){ | 145 | __attribute__ ((weak)) |
| 119 | } | ||
| 120 | |||
| 121 | void ergodox_board_led_off(void){ | 146 | void ergodox_board_led_off(void){ |
| 122 | } | 147 | } |
| 123 | 148 | ||
| 149 | __attribute__ ((weak)) | ||
| 124 | void ergodox_right_led_1_off(void){ | 150 | void ergodox_right_led_1_off(void){ |
| 125 | } | 151 | } |
| 126 | 152 | ||
| 153 | __attribute__ ((weak)) | ||
| 127 | void ergodox_right_led_2_off(void){ | 154 | void ergodox_right_led_2_off(void){ |
| 128 | } | 155 | } |
| 129 | 156 | ||
| 157 | __attribute__ ((weak)) | ||
| 130 | void ergodox_right_led_3_off(void){ | 158 | void ergodox_right_led_3_off(void){ |
| 131 | } | 159 | } |
| 132 | 160 | ||
| 133 | void ergodox_right_led_off(uint8_t led){ | 161 | __attribute__ ((weak)) |
| 162 | void ergodox_right_led_1_set(uint8_t n) { | ||
| 163 | } | ||
| 164 | |||
| 165 | __attribute__ ((weak)) | ||
| 166 | void ergodox_right_led_2_set(uint8_t n) { | ||
| 167 | } | ||
| 168 | |||
| 169 | __attribute__ ((weak)) | ||
| 170 | void ergodox_right_led_3_set(uint8_t n) { | ||
| 134 | } | 171 | } |
| 135 | 172 | ||
| 136 | #ifdef ONEHAND_ENABLE | 173 | #ifdef ONEHAND_ENABLE |
