Implement ledmap-in-eeprom feature
This commit is contained in:
parent
872c619cdf
commit
b9c65be036
@ -79,7 +79,12 @@ endif
|
||||
ifdef LEDMAP_ENABLE
|
||||
SRC += $(COMMON_DIR)/ledmap.c
|
||||
OPT_DEFS += -DLEDMAP_ENABLE
|
||||
ifdef LEDMAP_IN_EEPROM_ENABLE
|
||||
SRC += $(COMMON_DIR)/ledmap_in_eeprom.c
|
||||
OPT_DEFS += -DLEDMAP_IN_EEPROM_ENABLE
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
ifdef KEYMAP_SECTION_ENABLE
|
||||
OPT_DEFS += -DKEYMAP_SECTION_ENABLE
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "ledmap.h"
|
||||
#include "ledmap_in_eeprom.h"
|
||||
#include "led.h"
|
||||
#include "softpwm_led.h"
|
||||
#include "action_layer.h"
|
||||
|
@ -36,7 +36,8 @@ typedef enum {
|
||||
LEDMAP_SCROLL_LOCK,
|
||||
LEDMAP_COMPOSE,
|
||||
LEDMAP_KANA,
|
||||
LEDMAP_BACKLIGHT
|
||||
LEDMAP_BACKLIGHT = 0x80,
|
||||
LEDMAP_UNCONFIGURED = 0xFF
|
||||
} ledmap_code_t;
|
||||
|
||||
#define LEDMAP_LAYER(x) (x)
|
||||
|
28
common/ledmap_in_eeprom.c
Normal file
28
common/ledmap_in_eeprom.c
Normal file
@ -0,0 +1,28 @@
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include "ledmap.h"
|
||||
#include "ledmap_in_eeprom.h"
|
||||
|
||||
#ifdef LEDMAP_IN_EEPROM_ENABLE
|
||||
|
||||
#undef ledmap_get_code
|
||||
|
||||
static uint8_t ledmap[LED_COUNT];
|
||||
|
||||
void ledmap_in_eeprom_init(void) {
|
||||
// read and check ledmap in eeprom
|
||||
for (uint8_t i = 0; i < LED_COUNT; i++) {
|
||||
ledmap[i] = eeprom_read_byte(EECONFIG_LEDMAP + i);
|
||||
if (ledmap[i] == LEDMAP_UNCONFIGURED) {
|
||||
ledmap[i] = lemap_get_code(i);
|
||||
eeprom_write_byte(EECONFIG_LEDMAP + i, ledmap[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ledmap_in_eeprom_get_code(uint8_t i)
|
||||
{
|
||||
return ledmap[i];
|
||||
}
|
||||
|
||||
#endif
|
20
common/ledmap_in_eeprom.h
Normal file
20
common/ledmap_in_eeprom.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef LEDMAP_IN_EEPROM_H
|
||||
#define LEDMAP_IN_EEPROM_H
|
||||
|
||||
#ifndef EECONFIG_LEDMAP_IN_EEPROM
|
||||
#define EECONFIG_LEDMAP_IN_EEPROM 7
|
||||
#endif
|
||||
|
||||
#define EECONFIG_LEDMAP (uint8_t*)EECONFIG_LEDMAP_IN_EEPROM
|
||||
#define LEDMAP_SIZE (sizeof(uint8_t) * LED_COUNT)
|
||||
|
||||
#ifdef LEDMAP_IN_EEPROM_ENABLE
|
||||
#define ledmap_get_code ledmap_in_eeprom_get_code
|
||||
void ledmap_in_eeprom_init(void);
|
||||
uint8_t ledmap_in_eeprom_get_code(uint8_t index);
|
||||
#else
|
||||
#define ledmap_in_eeprom_init()
|
||||
#define ledmap_in_eeprom_get_code()
|
||||
#endif
|
||||
|
||||
#endif
|
@ -143,6 +143,7 @@ KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor
|
||||
SOFTPWM_LED_ENABLE = yes # Enable SoftPWM to drive backlight
|
||||
BREATHING_LED_ENABLE = yes # Enable breathing backlight
|
||||
LEDMAP_ENABLE = yes # Enable LED mapping
|
||||
LEDMAP_IN_EEPROM_ENABLE = yes # Read LED mapping from eeprom
|
||||
|
||||
|
||||
# Optimize size but this may cause error "relocation truncated to fit"
|
||||
|
Reference in New Issue
Block a user