2014-07-23 01:02:14 +00:00
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
#include <avr/eeprom.h>
|
|
|
|
#include "ledmap_in_eeprom.h"
|
|
|
|
|
|
|
|
#ifdef LEDMAP_IN_EEPROM_ENABLE
|
|
|
|
|
|
|
|
#undef ledmap_get_code
|
|
|
|
|
2014-11-25 09:23:16 +00:00
|
|
|
static ledmap_t ledmap[LED_COUNT];
|
2014-07-23 01:02:14 +00:00
|
|
|
|
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++) {
|
2014-11-25 09:23:16 +00:00
|
|
|
ledmap[i].code = eeprom_read_word(EECONFIG_LEDMAP + i);
|
|
|
|
/* ledmap[i].code = LEDMAP_UNCONFIGURED; */
|
|
|
|
if (ledmap[i].code == LEDMAP_UNCONFIGURED) {
|
2014-07-24 06:03:58 +00:00
|
|
|
ledmap[i] = ledmap_get_code(i);
|
2014-11-25 09:23:16 +00:00
|
|
|
eeprom_write_word(EECONFIG_LEDMAP + i, ledmap[i].code);
|
2014-07-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-24 06:03:58 +00:00
|
|
|
void write_ledmap_to_eeprom(void)
|
|
|
|
{
|
|
|
|
for (uint8_t i = 0; i < LED_COUNT; i++) {
|
2014-11-25 09:23:16 +00:00
|
|
|
eeprom_write_word(EECONFIG_LEDMAP + i, ledmap_get_code(i).code);
|
2014-07-24 06:03:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-25 09:23:16 +00:00
|
|
|
ledmap_t ledmap_in_eeprom_get_code(uint8_t i)
|
2014-07-23 01:02:14 +00:00
|
|
|
{
|
|
|
|
return ledmap[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|