-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEEPROM_circular.h
More file actions
38 lines (31 loc) · 1.07 KB
/
EEPROM_circular.h
File metadata and controls
38 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "Arduino.h"
#include <EEPROM.h>
#ifndef EEPROM_C_H
#define EEPROM_C_H
//#define PTRBUFSTART 0
//#define PTRBUFEND(x) PTRBUFSTART+x-1
//#define BBUFEND(x,y,z) PTRBUFEND(x)+y*z
// EEPROM structure:
// 0 - (pointerbufsize-1) - pointer buffer
// pointerbufsize - EESIZE - data buffer
// Number of elemnts in buffer:
// bufsize=(EESIZE-PTRBUFSIZE)/ELEMENTSIZE
class EEPROM_C {
// buffer pointers
public:
EEPROM_C(byte b, byte p, byte s);
byte pptr; // index of next element in pointer buffer
// unsigned int bufaddr; // address in data buffer for next element (read from pointer buffer)
byte *bufelement; // pointer to the current elememt array
byte elementsize; // size of one element
byte bufsize; // size (elements count) of buffer
byte pointerbufsize; // size (elements count) of pointer buffer
byte indexbuffer; // index of buffer element
// find active pointer in pointer buffer
void FindPtr();
// read element from address in pointer buffer
void ReadBufElement();
// write element from address in pointer buffer
void WriteBufElement();
};
#endif