eeprom_functions.ino 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. void getEEPROMContent() {
  2. int eeprom_address = 0;
  3. byte eeprom_value;
  4. Serial.println(F("EEPROM-Data:"));
  5. Serial.println(F("ADDR\t0\t1\t2\t3\t4\t5\t6\t7"));
  6. int col = 0;
  7. for (int i = 0; i < EEPROM.length(); i++) {
  8. eeprom_value = EEPROM.read(eeprom_address);
  9. if (col == 0) {
  10. Serial.print(eeprom_address);
  11. Serial.print("\t");
  12. }
  13. Serial.print(eeprom_value, DEC);
  14. Serial.print("\t");
  15. eeprom_address = eeprom_address + 1;
  16. if (col >= 7) {
  17. col = 0;
  18. Serial.println();
  19. }
  20. else col++;
  21. }
  22. }
  23. void formatEEPROMArea(int _from, int _len) {
  24. int _to;
  25. _to = _from + _len - 1;
  26. Serial.print(F("EEPROM - formatting area from "));
  27. Serial.print(_from);
  28. Serial.print(F(" to "));
  29. Serial.println(_to);
  30. for (int i = _from; i <= _to; i++) {
  31. Serial.print(".");
  32. EEPROM.update(i, 0);
  33. }
  34. Serial.println("DONE");
  35. }
  36. void formatEEPROM_AllData() {
  37. for (byte i = 0; i < COUNTERS_COUNT; i++) {
  38. formatEEPROMArea(eeprom_addr_area_start_currentReadingImpulses[i], eeprom_addr_area_length_currentReadingImpulses[i]);
  39. formatEEPROMArea(eeprom_addr_currentReading[i], 4);
  40. formatEEPROMArea(eeprom_addr_currentReading_backup1[i], 4);
  41. formatEEPROMArea(eeprom_addr_currentReading_backup2[i], 4);
  42. }
  43. }
  44. void formatEEPROMAreaOfCounter(byte _cNum) {
  45. if (_cNum >= 0 && _cNum < COUNTERS_COUNT) {
  46. formatEEPROMArea(eeprom_addr_currentReading[_cNum], 4);
  47. formatEEPROMArea(eeprom_addr_currentReading_backup1[_cNum], 4);
  48. formatEEPROMArea(eeprom_addr_currentReading_backup2[_cNum], 4);
  49. formatEEPROMArea(eeprom_addr_area_start_currentReadingImpulses[_cNum], eeprom_addr_area_length_currentReadingImpulses[_cNum]);
  50. eeprom_nextoffset_currentReadingImpulses[_cNum] = 0;
  51. eeprom_writecounter_currentReadingImpulses[_cNum] = 1;
  52. }
  53. }