]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Add keyboard LED control via Bluetooth
authortmk <nobody@nowhere>
Mon, 22 Sep 2014 05:20:49 +0000 (14:20 +0900)
committertmk <nobody@nowhere>
Mon, 22 Sep 2014 05:20:49 +0000 (14:20 +0900)
keyboard/hhkb_rn42/rn42/rn42.c
keyboard/hhkb_rn42/rn42/rn42.h
keyboard/hhkb_rn42/rn42/rn42_task.c

index bdffad766777af1c965cd070e5f6cf54eadf18fd..1565b4cf1417a582dd87816a525c2ccfc5f5def0 100644 (file)
@@ -101,7 +101,9 @@ bool rn42_linked(void)
 }
 
 
-static uint8_t keyboard_leds(void) { return 0; }
+static uint8_t leds = 0;
+static uint8_t keyboard_leds(void) { return leds; }
+void rn42_set_leds(uint8_t l) { leds = l; }
 
 static void send_keyboard(report_keyboard_t *report)
 {
@@ -199,7 +201,7 @@ host_driver_t rn42_config_driver = {
     config_send_consumer
 };
 
-static uint8_t config_keyboard_leds(void) { return 0; }
+static uint8_t config_keyboard_leds(void) { return leds; }
 static void config_send_keyboard(report_keyboard_t *report) {}
 static void config_send_mouse(report_mouse_t *report) {}
 static void config_send_system(uint16_t data) {}
index 72cbb2d724d9f844df0da03647ba87168e3cd027..5283a3648c256c72a5b1911bbf6eb91722f1d482 100644 (file)
@@ -15,5 +15,6 @@ bool rn42_rts(void);
 void rn42_cts_hi(void);
 void rn42_cts_lo(void);
 bool rn42_linked(void);
+void rn42_set_leds(uint8_t l);
 
 #endif
index 31a415cedfe1ba232553f71fa7b3cce7b4214ab6..c3359ed5069dc62c666fe3a851d3bd4d32b0e956 100644 (file)
@@ -7,6 +7,7 @@
 #include "lufa.h"
 #include "rn42_task.h"
 #include "print.h"
+#include "debug.h"
 #include "timer.h"
 #include "command.h"
 #include "battery.h"
@@ -45,7 +46,6 @@ void rn42_task(void)
             // LED Out report: 0xFE, 0x02, 0x01, <leds>
             // To get the report over UART set bit3 with SH, command.
             static enum {LED_INIT, LED_FE, LED_02, LED_01} state = LED_INIT;
-            xprintf("%02X\n", c);
             switch (state) {
                 case LED_INIT:
                     if (c == 0xFE) state = LED_FE;
@@ -60,8 +60,8 @@ void rn42_task(void)
                     else           state = LED_INIT;
                     break;
                 case LED_01:
-                    // TODO: move to rn42.c and make accessible with keyboard_leds()
-                    xprintf("LED status: %02X\n", c);
+                    dprintf("LED status: %02X\n", c);
+                    rn42_set_leds(c);
                     state = LED_INIT;
                     break;
                 default: