Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

34 lignes
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. }