Lift out the LED brightness into a global

Instead of passing the same constant to LedDisplay_SetLayerLed() all the time,
lift it out into a global.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This commit is contained in:
Gergely Nagy
2016-12-13 23:23:16 +01:00
parent 2a7edbce6f
commit a59dcd1662
3 changed files with 8 additions and 4 deletions

View File

@@ -82,7 +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, 0xff);
LedDisplay_SetLayerLed(ActiveLayer);
return false;
break;
default:

View File

@@ -4,8 +4,10 @@
#define LAYER_LED_FIRST FRAME_REGISTER_PWM_FIRST + 13
#define LAYER_LED_DISTANCE 16
void LedDisplay_SetLayerLed(uint8_t layerId, uint8_t brightness) {
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), brightness * (layerId == i + 1));
LedDriver_WriteRegister(I2C_ADDRESS_LED_DRIVER_LEFT, LAYER_LED_FIRST + (i * LAYER_LED_DISTANCE), LedDisplayBrightness * (layerId == i + 1));
}
}

View File

@@ -3,6 +3,8 @@
#include "led_driver.h"
void LedDisplay_SetLayerLed(uint8_t layerId, uint8_t brightness);
extern uint8_t LedDisplayBrightness;
void LedDisplay_SetLayerLed(uint8_t layerId);
#endif