EEPROMextent
Arduino EEPROM library
CircularBuffer.hpp
1 //-------------------------------------------------------------------
2 #ifndef __EEPROM_CircularBuffer_H__
3 #define __EEPROM_CircularBuffer_H__
4 //-------------------------------------------------------------------
5 
6 #include "arduino.h"
7 #include "EEPROMextent.h"
8 
32 {
33 private:
34  int startListPos;
35  byte elementSize;
36  byte replicaNumber;
37 
38 public:
40  CircularBuffer() { this->elementSize = 0; this->replicaNumber = 0; this->startListPos = 0; }
41 
48  int begin(int inStartListPos, byte inElementSize, byte inReplicaNumber)
49  {
50  this->startListPos = inStartListPos; this->elementSize = inElementSize; this->replicaNumber = inReplicaNumber;
51  return (this->elementSize + 1) * this->replicaNumber;
52  }
53 
58  void *read(void* outpObject);
64  void write(void* inpObject, bool inUpdate = false);
68  inline void update(void *inpObject) { write(inpObject, true); }
69 
73  int getStartRead();
77  int startWrite();
78 
80  void clear() const;
81 
82 #ifdef EEPROMEXTENT_DEBUG_MODE
83 
84  void printStatus();
85 #endif
86 
87 private:
88  byte FindEnd();
89 };
90 
91 //-------------------------------------------------------------------
92 #endif
93 //-------------------------------------------------------------------
void update(void *inpObject)
int begin(int inStartListPos, byte inElementSize, byte inReplicaNumber)
void clear() const
void * read(void *outpObject)
void write(void *inpObject, bool inUpdate = false)