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.

37 regels
752 B

  1. #include "Config.h"
  2. #include "Debug.h"
  3. #include "Hardware.h"
  4. #define LOGGER_NAME "Config"
  5. namespace config {
  6. Config value;
  7. void write() {
  8. VERBOSE("writeConfig");
  9. hardware::i2c::eeprom.writeBlock(CONFIG_ADDR, value);
  10. VERBOSE_FORMAT("writeConfig", "%s, %s, %d, %d", value.seed, value.version, value.firstEntry, value.lastEntry);
  11. }
  12. void reset() {
  13. VERBOSE("resetConfig");
  14. Config config = {
  15. CONFIG_SEED,
  16. VERSION,
  17. 0,
  18. 0
  19. };
  20. value = config;
  21. write();
  22. }
  23. void read() {
  24. VERBOSE("readConfig");
  25. hardware::i2c::eeprom.readBlock(CONFIG_ADDR, value);
  26. if (!String(CONFIG_SEED).equals(value.seed)) reset();
  27. VERBOSE_FORMAT("readConfig", "%s, %s, %d, %d", value.seed, value.version, value.firstEntry, value.lastEntry);
  28. }
  29. }