You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

ledmap_in_eeprom.c 623B

12345678910111213141516171819202122232425262728
  1. #include <avr/pgmspace.h>
  2. #include <avr/eeprom.h>
  3. #include "ledmap.h"
  4. #include "ledmap_in_eeprom.h"
  5. #ifdef LEDMAP_IN_EEPROM_ENABLE
  6. #undef ledmap_get_code
  7. static uint8_t ledmap[LED_COUNT];
  8. void ledmap_in_eeprom_init(void) {
  9. // read and check ledmap in eeprom
  10. for (uint8_t i = 0; i < LED_COUNT; i++) {
  11. ledmap[i] = eeprom_read_byte(EECONFIG_LEDMAP + i);
  12. if (ledmap[i] == LEDMAP_UNCONFIGURED) {
  13. ledmap[i] = lemap_get_code(i);
  14. eeprom_write_byte(EECONFIG_LEDMAP + i, ledmap[i]);
  15. }
  16. }
  17. }
  18. uint8_t ledmap_in_eeprom_get_code(uint8_t i)
  19. {
  20. return ledmap[i];
  21. }
  22. #endif