1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
tmk_keyboard_custom/common/ledmap_in_eeprom.c

37 lines
785 B
C
Raw Normal View History

2014-07-23 01:02:14 +00:00
#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];
2014-07-24 06:03:58 +00:00
void ledmap_in_eeprom_init(void)
{
2014-07-23 01:02:14 +00:00
for (uint8_t i = 0; i < LED_COUNT; i++) {
ledmap[i] = eeprom_read_byte(EECONFIG_LEDMAP + i);
2014-07-24 06:03:58 +00:00
ledmap[i] = LEDMAP_UNCONFIGURED;
2014-07-23 01:02:14 +00:00
if (ledmap[i] == LEDMAP_UNCONFIGURED) {
2014-07-24 06:03:58 +00:00
ledmap[i] = ledmap_get_code(i);
2014-07-23 01:02:14 +00:00
eeprom_write_byte(EECONFIG_LEDMAP + i, ledmap[i]);
}
}
}
2014-07-24 06:03:58 +00:00
void write_ledmap_to_eeprom(void)
{
for (uint8_t i = 0; i < LED_COUNT; i++) {
eeprom_write_byte(EECONFIG_LEDMAP + i, ledmap_get_code(i));
}
}
2014-07-23 01:02:14 +00:00
uint8_t ledmap_in_eeprom_get_code(uint8_t i)
{
return ledmap[i];
}
#endif