X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=keyboard%2Fhhkb_rn42%2Frn42%2Frn42_task.c;h=6686268624f269bb7a88286b6e5b72e0e7ce46ec;hb=25aee431bd83b46d694293c85a939d476943a5aa;hp=30914452e530296afcac18e7c45c3da5b2eb7b25;hpb=3b81ffc16c8cdf260c25f0778d32c721af4f105c;p=max%2Ftmk_keyboard.git diff --git a/keyboard/hhkb_rn42/rn42/rn42_task.c b/keyboard/hhkb_rn42/rn42/rn42_task.c index 30914452..66862686 100644 --- a/keyboard/hhkb_rn42/rn42/rn42_task.c +++ b/keyboard/hhkb_rn42/rn42/rn42_task.c @@ -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, // 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: @@ -83,11 +83,10 @@ void rn42_task(void) static uint16_t prev_timer = 0; - static uint8_t sec = 0; - // NOTE: not exact 1 sec - if (timer_elapsed(prev_timer) > 1000) { + uint16_t e = timer_elapsed(prev_timer); + if (e > 1000) { /* every second */ - prev_timer = timer_read(); + prev_timer += e/1000*1000; /* Low voltage alert */ uint8_t bs = battery_status(); @@ -110,8 +109,8 @@ void rn42_task(void) } /* every minute */ - if (sec == 0) { - uint32_t t = timer_read32()/1000; + uint32_t t = timer_read32()/1000; + if (t%60 == 0) { uint16_t v = battery_voltage(); uint8_t h = t/3600; uint8_t m = t%3600/60; @@ -121,7 +120,6 @@ void rn42_task(void) xprintf("%02u:%02u:%02u\t%umV\n", (t/3600), (t%3600/60), (t%60), v); */ } - sec++; sec = sec%60; } @@ -199,6 +197,8 @@ bool command_extra(uint8_t code) xprintf("rn42_linked(): %X\n", rn42_linked()); xprintf("rn42_rts(): %X\n", rn42_rts()); xprintf("config_mode: %X\n", config_mode); + xprintf("USB_DeviceState: %X\n", USB_DeviceState); + xprintf("USB_Device_RemoteWakeupEnabled: %X\n", USB_Device_RemoteWakeupEnabled); xprintf("VBUS: %X\n", USBSTA&(1<