diff --git a/right/src/keyboard_layout.c b/right/src/keyboard_layout.c index 5a459a9..4cabe19 100644 --- a/right/src/keyboard_layout.c +++ b/right/src/keyboard_layout.c @@ -1,5 +1,5 @@ #include "keyboard_layout.h" -#include "led_driver.h" +#include "led_display.h" #include "layer.h" static uint8_t keyMasks[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE]; @@ -82,6 +82,7 @@ bool handleKey(uhk_key_t key, int scancodeIdx, usb_keyboard_report_t *report, co if (key_toggled_off(prevKeyStates, currKeyStates, keyId)) { ActiveLayer = LAYER_ID_BASE; } + LedDisplay_SetLayerLed(ActiveLayer); return false; break; default: diff --git a/right/src/led_display.c b/right/src/led_display.c new file mode 100644 index 0000000..176b6ca --- /dev/null +++ b/right/src/led_display.c @@ -0,0 +1,13 @@ +#include "led_display.h" +#include "layer.h" + +#define LAYER_LED_FIRST FRAME_REGISTER_PWM_FIRST + 13 +#define LAYER_LED_DISTANCE 16 + +uint8_t LedDisplayBrightness = 0xff; + +void LedDisplay_SetLayerLed(uint8_t layerId) { + for (uint8_t i = 0; i < LAYER_COUNT; i++) { + LedDriver_WriteRegister(I2C_ADDRESS_LED_DRIVER_LEFT, LAYER_LED_FIRST + (i * LAYER_LED_DISTANCE), LedDisplayBrightness * (layerId == i + 1)); + } +} diff --git a/right/src/led_display.h b/right/src/led_display.h new file mode 100644 index 0000000..c2434bb --- /dev/null +++ b/right/src/led_display.h @@ -0,0 +1,10 @@ +#ifndef __LED_DISPLAY_H__ +#define __LED_DISPLAY_H__ + + #include "led_driver.h" + + extern uint8_t LedDisplayBrightness; + + void LedDisplay_SetLayerLed(uint8_t layerId); + +#endif