Add LedDisplay_UpdateAll()

This commit is contained in:
László Monda
2018-04-28 16:21:54 +02:00
parent b97841fdae
commit 8856c484b6
6 changed files with 28 additions and 12 deletions

View File

@@ -145,8 +145,7 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
AlphanumericSegmentsBrightness = alphanumericSegmentsBrightness; AlphanumericSegmentsBrightness = alphanumericSegmentsBrightness;
KeyBacklightBrightness = keyBacklightBrightness; KeyBacklightBrightness = keyBacklightBrightness;
Slaves[SlaveId_LeftLedDriver].isConnected = false; LedSlaveDriver_UpdateLedValues();
Slaves[SlaveId_RightLedDriver].isConnected = false;
// Update mouse key speeds // Update mouse key speeds

View File

@@ -23,7 +23,7 @@ void SwitchKeymapById(uint8_t index)
CurrentKeymapIndex = index; CurrentKeymapIndex = index;
ValidatedUserConfigBuffer.offset = AllKeymaps[index].offset; ValidatedUserConfigBuffer.offset = AllKeymaps[index].offset;
ParseKeymap(&ValidatedUserConfigBuffer, index, AllKeymapsCount, AllMacrosCount); ParseKeymap(&ValidatedUserConfigBuffer, index, AllKeymapsCount, AllMacrosCount);
LedDisplay_SetCurrentKeymapText(); LedDisplay_UpdateText();
} }
bool SwitchKeymapByAbbreviation(uint8_t length, char *abbrev) bool SwitchKeymapByAbbreviation(uint8_t length, char *abbrev)

View File

@@ -85,12 +85,6 @@ void LedDisplay_SetText(uint8_t length, const char* text)
} }
} }
void LedDisplay_SetCurrentKeymapText(void)
{
keymap_reference_t *currentKeymap = AllKeymaps + CurrentKeymapIndex;
LedDisplay_SetText(currentKeymap->abbreviationLen, currentKeymap->abbreviation);
}
void LedDisplay_SetLayer(layer_id_t layerId) void LedDisplay_SetLayer(layer_id_t layerId)
{ {
for (uint8_t i = 13; i <= 45; i += 16) { for (uint8_t i = 13; i <= 45; i += 16) {
@@ -119,3 +113,15 @@ void LedDisplay_UpdateIcons(void)
LedDisplay_SetIcon(i, ledIconStates[i]); LedDisplay_SetIcon(i, ledIconStates[i]);
} }
} }
void LedDisplay_UpdateText(void)
{
keymap_reference_t *currentKeymap = AllKeymaps + CurrentKeymapIndex;
LedDisplay_SetText(currentKeymap->abbreviationLen, currentKeymap->abbreviation);
}
void LedDisplay_UpdateAll(void)
{
LedDisplay_UpdateIcons();
LedDisplay_UpdateText();
}

View File

@@ -24,10 +24,11 @@
// Functions: // Functions:
void LedDisplay_SetText(uint8_t length, const char* text); void LedDisplay_SetText(uint8_t length, const char* text);
void LedDisplay_SetCurrentKeymapText(void);
void LedDisplay_SetLayer(layer_id_t layerId); void LedDisplay_SetLayer(layer_id_t layerId);
bool LedDisplay_GetIcon(led_display_icon_t icon); bool LedDisplay_GetIcon(led_display_icon_t icon);
void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled); void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled);
void LedDisplay_UpdateIcons(void); void LedDisplay_UpdateIcons(void);
void LedDisplay_UpdateText(void);
void LedDisplay_UpdateAll(void);
#endif #endif

View File

@@ -62,6 +62,15 @@ static uint8_t setShutdownModeNormalBuffer[] = {LED_DRIVER_REGISTER_SHUTDOWN, SH
static uint8_t setFrame1Buffer[] = {LED_DRIVER_REGISTER_FRAME, LED_DRIVER_FRAME_1}; static uint8_t setFrame1Buffer[] = {LED_DRIVER_REGISTER_FRAME, LED_DRIVER_FRAME_1};
static uint8_t updatePwmRegistersBuffer[PWM_REGISTER_BUFFER_LENGTH]; static uint8_t updatePwmRegistersBuffer[PWM_REGISTER_BUFFER_LENGTH];
void LedSlaveDriver_UpdateLedValues(void)
{
for (uint8_t ledDriverId=0; ledDriverId<=LedDriverId_Last; ledDriverId++) {
memset(LedDriverValues[ledDriverId], KeyBacklightBrightness, LED_DRIVER_LED_COUNT);
}
LedDisplay_UpdateAll();
}
void LedSlaveDriver_Init(uint8_t ledDriverId) void LedSlaveDriver_Init(uint8_t ledDriverId)
{ {
if (ledDriverId == ISO_KEY_LED_DRIVER_ID && IS_ISO) { if (ledDriverId == ISO_KEY_LED_DRIVER_ID && IS_ISO) {
@@ -74,8 +83,7 @@ void LedSlaveDriver_Init(uint8_t ledDriverId)
memset(LedDriverValues[ledDriverId], KeyBacklightBrightness, LED_DRIVER_LED_COUNT); memset(LedDriverValues[ledDriverId], KeyBacklightBrightness, LED_DRIVER_LED_COUNT);
if (ledDriverId == LedDriverId_Left) { if (ledDriverId == LedDriverId_Left) {
LedDisplay_UpdateIcons(); LedDisplay_UpdateAll();
LedDisplay_SetCurrentKeymapText();
} }
} }

View File

@@ -23,6 +23,7 @@
typedef enum { typedef enum {
LedDriverId_Right, LedDriverId_Right,
LedDriverId_Left, LedDriverId_Left,
LedDriverId_Last = LedDriverId_Left,
} led_driver_id_t; } led_driver_id_t;
typedef enum { typedef enum {
@@ -49,6 +50,7 @@
// Functions: // Functions:
void LedSlaveDriver_UpdateLedValues(void);
void LedSlaveDriver_Init(uint8_t ledDriverId); void LedSlaveDriver_Init(uint8_t ledDriverId);
status_t LedSlaveDriver_Update(uint8_t ledDriverId); status_t LedSlaveDriver_Update(uint8_t ledDriverId);