mattdibi / redox-keyboard

Ergonomic split mechanical keyboard
MIT License
1.78k stars 167 forks source link

4th LED on Redox-W receiver ? #24

Closed LucidityCrash closed 5 years ago

LucidityCrash commented 5 years ago

Please tell me what it's for, it's driving me crazy ... I can't see where it is used in QMK ?????

mattdibi commented 5 years ago

Hi, You're right I'm sorry. I should have stated it somewhere... currently it's not used by the default QMK firmware, but you can easily make it work by modifying the sources.

LucidityCrash commented 5 years ago

I'm not really up to speed with full on Arduino coding and bit shifting so sorry if this is stupid but would I achieve this by doing : DDRD |= (1<<1) | (1<<0); PORTD |= (1<<1) | (1<<0);

mattdibi commented 5 years ago

I had this piece of code laying around that should do what you're looking for. Tell me if this works for you.

diff --git a/keyboards/redox_w/redox_w.c b/keyboards/redox_w/redox_w.c
index 75df910..860cfe1 100644
--- a/keyboards/redox_w/redox_w.c
+++ b/keyboards/redox_w/redox_w.c
@@ -9,6 +9,10 @@ void led_init(void) {
        PORTD |= (1<<1);
        DDRF  |= (1<<4) | (1<<5);
        PORTF |= (1<<4) | (1<<5);
+
+    // Caps lock and num lock
+    DDRB |= (1 << 4) | (1 << 5);
+    PORTB &= ~(1 << 4) | ~(1 << 5);
 }

@@ -27,7 +31,16 @@ void matrix_scan_kb(void) {
 }

 void led_set_kb(uint8_t usb_led) {
-
+    if (usb_led & (1<<USB_LED_NUM_LOCK)) {
+        PORTB |= (1<<4);
+    } else {
+        PORTB &= ~(1<<4);
+    }
+    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
+        PORTB |= (1<<5);
+    } else {
+        PORTB &= ~(1<<5);
+    }
 }

 #ifdef ONEHAND_ENABLE
mattdibi commented 5 years ago

Closing as resolved.

mattdibi commented 5 years ago

I need to make a correction!

The correct code to use the 4th LED is here. The code in this example uses the 4th LED as a Caps Lock indicator.

Note that now there's a higher level API to achive the same results but is more readable.

Hope this helps.

pixelbreaker commented 5 years ago

@mattdibi Thanks for the link to the other issue, I've cleaned up my code a LOT now with thenew higher level API. 👍