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 798B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <avr/pgmspace.h>
  2. #include <avr/eeprom.h>
  3. #include "ledmap_in_eeprom.h"
  4. #ifdef LEDMAP_IN_EEPROM_ENABLE
  5. #undef ledmap_get_code
  6. static ledmap_t ledmap[LED_COUNT];
  7. void ledmap_in_eeprom_init(void)
  8. {
  9. for (uint8_t i = 0; i < LED_COUNT; i++) {
  10. ledmap[i].code = eeprom_read_word(EECONFIG_LEDMAP + i);
  11. /* ledmap[i].code = LEDMAP_UNCONFIGURED; */
  12. if (ledmap[i].code == LEDMAP_UNCONFIGURED) {
  13. ledmap[i] = ledmap_get_code(i);
  14. eeprom_write_word(EECONFIG_LEDMAP + i, ledmap[i].code);
  15. }
  16. }
  17. }
  18. void write_ledmap_to_eeprom(void)
  19. {
  20. for (uint8_t i = 0; i < LED_COUNT; i++) {
  21. eeprom_write_word(EECONFIG_LEDMAP + i, ledmap_get_code(i).code);
  22. }
  23. }
  24. ledmap_t ledmap_in_eeprom_get_code(uint8_t i)
  25. {
  26. return ledmap[i];
  27. }
  28. #endif