aboutsummaryrefslogtreecommitdiff
path: root/keyboards/ergodox/infinity/infinity.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/ergodox/infinity/infinity.c')
-rw-r--r--keyboards/ergodox/infinity/infinity.c51
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
73static 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
73void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) { 96void 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))
106void ergodox_board_led_on(void){ 130void ergodox_board_led_on(void){
107} 131}
108 132
133__attribute__ ((weak))
109void ergodox_right_led_1_on(void){ 134void ergodox_right_led_1_on(void){
110} 135}
111 136
137__attribute__ ((weak))
112void ergodox_right_led_2_on(void){ 138void ergodox_right_led_2_on(void){
113} 139}
114 140
141__attribute__ ((weak))
115void ergodox_right_led_3_on(void){ 142void ergodox_right_led_3_on(void){
116} 143}
117 144
118void ergodox_right_led_on(uint8_t led){ 145__attribute__ ((weak))
119}
120
121void ergodox_board_led_off(void){ 146void ergodox_board_led_off(void){
122} 147}
123 148
149__attribute__ ((weak))
124void ergodox_right_led_1_off(void){ 150void ergodox_right_led_1_off(void){
125} 151}
126 152
153__attribute__ ((weak))
127void ergodox_right_led_2_off(void){ 154void ergodox_right_led_2_off(void){
128} 155}
129 156
157__attribute__ ((weak))
130void ergodox_right_led_3_off(void){ 158void ergodox_right_led_3_off(void){
131} 159}
132 160
133void ergodox_right_led_off(uint8_t led){ 161__attribute__ ((weak))
162void ergodox_right_led_1_set(uint8_t n) {
163}
164
165__attribute__ ((weak))
166void ergodox_right_led_2_set(uint8_t n) {
167}
168
169__attribute__ ((weak))
170void ergodox_right_led_3_set(uint8_t n) {
134} 171}
135 172
136#ifdef ONEHAND_ENABLE 173#ifdef ONEHAND_ENABLE