summaryrefslogtreecommitdiffstats
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 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