From 0b6f7f996cbd9f2eddde5413baf937cd70efb5d1 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 14 Nov 2024 17:00:57 +0700 Subject: [PATCH] fix: shine led indicator brightness --- keyboards/zsa/ergodox_ez/m32u4/m32u4.c | 53 ++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/keyboards/zsa/ergodox_ez/m32u4/m32u4.c b/keyboards/zsa/ergodox_ez/m32u4/m32u4.c index c20248bce920..699dc0beacb6 100644 --- a/keyboards/zsa/ergodox_ez/m32u4/m32u4.c +++ b/keyboards/zsa/ergodox_ez/m32u4/m32u4.c @@ -1,18 +1,65 @@ // Copyright 2023 Christopher Courtney, aka Drashna Jael're (@drashna) // SPDX-License-Identifier: GPL-3.0-or-later +#include #include "ergodox_ez.h" +static uint8_t ergodox_right_led_1_duty; +static uint8_t ergodox_right_led_2_duty; +static uint8_t ergodox_right_led_3_duty; + void ergodox_right_led_1_set(uint8_t n) { - OCR1A = n; + ergodox_right_led_1_duty = n; + if (ergodox_right_led_1_duty == 0) { + ergodox_right_led_1_off(); + } else { + ergodox_right_led_1_on(); + } +} + +void ergodox_right_led_1_on(void) { + OCR1A = ergodox_right_led_1_duty; +} + +void ergodox_right_led_1_off(void) { + OCR1A = 0; } + void ergodox_right_led_2_set(uint8_t n) { - OCR1B = n; + ergodox_right_led_2_duty = n; + if (ergodox_right_led_2_duty == 0) { + ergodox_right_led_2_off(); + } else { + ergodox_right_led_2_on(); + } +} + +void ergodox_right_led_2_on(void) { + OCR1B = ergodox_right_led_2_duty; } + +void ergodox_right_led_2_off(void) { + OCR1B = 0; +} + void ergodox_right_led_3_set(uint8_t n) { - OCR1C = n; + ergodox_right_led_3_duty = n; + if (ergodox_right_led_3_duty == 0) { + ergodox_right_led_3_off(); + } else { + ergodox_right_led_3_on(); + } +} + +void ergodox_right_led_3_off(void) { + OCR1C = 0; +} + +void ergodox_right_led_3_on(void) { + OCR1C = ergodox_right_led_3_duty; } + void keyboard_post_init_sub(void) { // keyboard LEDs (see "PWM on ports OC1(A|B|C)" in "teensy-2-0.md") TCCR1A = 0b10101001; // set and configure fast PWM