No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

34 líneas
700 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. hardware::i2c::eeprom.writeBlock(CONFIG_ADDR, value);
  9. VERBOSE_FORMAT("writeConfig", "%s, %s, %d, %d", value.seed, value.version, value.firstEntry, value.lastEntry);
  10. }
  11. void reset() {
  12. VERBOSE("resetConfig");
  13. Config config = {
  14. CONFIG_SEED,
  15. VERSION,
  16. 0,
  17. 0
  18. };
  19. value = config;
  20. write();
  21. }
  22. void read() {
  23. hardware::i2c::eeprom.readBlock(CONFIG_ADDR, value);
  24. if (!String(CONFIG_SEED).equals(value.seed)) reset();
  25. VERBOSE_FORMAT("readConfig", "%s, %s, %d, %d", value.seed, value.version, value.firstEntry, value.lastEntry);
  26. }
  27. }