7 #include "CircularBuffer.hpp" 18 byte CircularBuffer::FindEnd()
28 int prevpos = this->startListPos + this->replicaNumber - 1;
29 byte prev = EEPROMextent.
readByte(prevpos);
31 for (
int i = 0; i < this->replicaNumber; i++)
33 int pos = this->startListPos + i;
37 if (prev + 1 != EEPROMextent.
readByte(pos))
38 return prevpos - this->startListPos;
51 byte place = this->FindEnd();
52 eeprom_read_block((uint8_t *)outpData, (
const uint8_t *)INT64 (this->startListPos + this->replicaNumber + (this->elementSize * place)), this->elementSize);
59 byte place = this->FindEnd();
60 byte itemNb = EEPROMextent.
readByte(this->startListPos + place);
63 if (place >= this->replicaNumber)
68 EEPROMextent.
updateByte(this->startListPos + place, ++itemNb);
69 eeprom_update_block((
const uint8_t *)inpData, (uint8_t *)INT64 (this->startListPos + this->replicaNumber + (this->elementSize * place)), this->elementSize);
73 EEPROMextent.
writeByte(this->startListPos + place, ++itemNb);
74 eeprom_write_block((
const uint8_t *)inpData, (uint8_t *)INT64 (this->startListPos + this->replicaNumber + (this->elementSize * place)), this->elementSize);
80 EEPROMextent.
clear(this->startListPos, (this->elementSize + 1) * this->replicaNumber);
85 byte place = this->FindEnd();
86 return this->startListPos + this->replicaNumber + (this->elementSize * place);
91 byte place = this->FindEnd();
92 byte itemNb = EEPROMextent.
readByte(this->startListPos + place);
95 if (place >= this->replicaNumber)
98 EEPROMextent.
updateByte(this->startListPos + place, ++itemNb);
100 return this->startListPos + this->replicaNumber + (this->elementSize * place);
107 #ifdef EEPROMEXTENT_DEBUG_MODE 108 void CircularBuffer::printStatus()
110 Serial.print(F(
"CB Status : "));
111 for (
int i = 0; i < this->replicaNumber; i++)
113 Serial.print(F(
"|"));
114 Serial.print(EEPROMextent.
readByte(this->startListPos + i));
116 Serial.println(F(
"|"));
void updateByte(int address, uint8_t value)
void write(void *inpObject, bool inUpdate = false)
void clear(int address, int inSize, byte inFillCharacter = 0)
void writeByte(int address, uint8_t value)
void * read(void *outpObject)
uint8_t readByte(int address)