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

123456789101112131415161718192021222324252627282930313233343536
  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. {
  10. for (uint8_t i = 0; i < LED_COUNT; i++) {
  11. ledmap[i] = eeprom_read_byte(EECONFIG_LEDMAP + i);
  12. //ledmap[i] = LEDMAP_UNCONFIGURED;
  13. if (ledmap[i] == LEDMAP_UNCONFIGURED) {
  14. ledmap[i] = ledmap_get_code(i);
  15. eeprom_write_byte(EECONFIG_LEDMAP + i, ledmap[i]);
  16. }
  17. }
  18. }
  19. void write_ledmap_to_eeprom(void)
  20. {
  21. for (uint8_t i = 0; i < LED_COUNT; i++) {
  22. eeprom_write_byte(EECONFIG_LEDMAP + i, ledmap_get_code(i));
  23. }
  24. }
  25. uint8_t ledmap_in_eeprom_get_code(uint8_t i)
  26. {
  27. return ledmap[i];
  28. }
  29. #endif