|
@@ -75,10 +75,8 @@ void PrintCounter::initStats() {
|
75
|
75
|
|
76
|
76
|
saveStats();
|
77
|
77
|
|
78
|
|
- uint16_t crc = 0;
|
79
|
|
- int a = address;
|
80
|
78
|
persistentStore.access_start();
|
81
|
|
- persistentStore.write_data(a, (uint8_t*)0x16, sizeof(uint8_t), &crc);
|
|
79
|
+ persistentStore.write_data(address, (uint8_t)0x16);
|
82
|
80
|
persistentStore.access_finish();
|
83
|
81
|
}
|
84
|
82
|
|
|
@@ -88,16 +86,13 @@ void PrintCounter::loadStats() {
|
88
|
86
|
#endif
|
89
|
87
|
|
90
|
88
|
// Check if the EEPROM block is initialized
|
91
|
|
- uint16_t crc = 0;
|
92
|
|
- int a = address;
|
93
|
|
- uint8_t value;
|
|
89
|
+ uint8_t value = 0;
|
94
|
90
|
persistentStore.access_start();
|
95
|
|
- persistentStore.read_data(a, &value, sizeof(uint8_t), &crc);
|
96
|
|
- if (value != 0x16) initStats();
|
97
|
|
- else {
|
98
|
|
- a = address + sizeof(uint8_t);
|
99
|
|
- persistentStore.read_data(a, (uint8_t*)&data, sizeof(printStatistics), &crc);
|
100
|
|
- }
|
|
91
|
+ persistentStore.read_data(address, &value, sizeof(uint8_t));
|
|
92
|
+ if (value != 0x16)
|
|
93
|
+ initStats();
|
|
94
|
+ else
|
|
95
|
+ persistentStore.read_data(address + sizeof(uint8_t), (uint8_t*)&data, sizeof(printStatistics));
|
101
|
96
|
persistentStore.access_finish();
|
102
|
97
|
loaded = true;
|
103
|
98
|
}
|
|
@@ -111,10 +106,8 @@ void PrintCounter::saveStats() {
|
111
|
106
|
if (!isLoaded()) return;
|
112
|
107
|
|
113
|
108
|
// Saves the struct to EEPROM
|
114
|
|
- uint16_t crc = 0;
|
115
|
|
- int a = (address + sizeof(uint8_t));
|
116
|
109
|
persistentStore.access_start();
|
117
|
|
- persistentStore.write_data(a, (uint8_t*)&data, sizeof(printStatistics), &crc);
|
|
110
|
+ persistentStore.write_data(address + sizeof(uint8_t), (uint8_t*)&data, sizeof(printStatistics));
|
118
|
111
|
persistentStore.access_finish();
|
119
|
112
|
}
|
120
|
113
|
|