-
Notifications
You must be signed in to change notification settings - Fork 1
/
logger_i2c_eeprom.h
106 lines (95 loc) · 3.13 KB
/
logger_i2c_eeprom.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef _LOGGER_I2C_EEPROM_H
#define _LOGGER_I2C_EEPROM_H
#include <Wire.h>
#include "config.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#include "Wstring.h"
#include "Wiring.h"
#endif
// TWI buffer needs max 2 bytes for eeprom address
// 1 byte for eeprom register address is available in txbuffer
#define I2C_TWIBUFFERSIZE 30
struct FlightDataStruct {
long diffTime;
long altitude;
long temperature;
long pressure;
#ifdef LOG_VOLTAGE
long voltage;
#endif
#if defined ALTIMULTIESP32_ACCELERO || defined ALTIMULTIESP32_ACCELERO_375 || defined ALTIMULTIESP32_ACCELERO_345
long ADXL375accelX;
long ADXL375accelY;
long ADXL375accelZ;
long ADXL345accelX;
long ADXL345accelY;
long ADXL345accelZ;
#endif
};
struct FlightConfigStruct {
long flight_start;
long flight_stop;
};
#define LOGGER_I2C_EEPROM_VERSION "1.0.0"
// The DEFAULT page size. This is overriden if you use the second constructor.
// I2C_EEPROM_PAGESIZE must be multiple of 2 e.g. 16, 32 or 64
// 24LC256 -> 64 bytes
#define LOGGER_I2C_EEPROM_PAGESIZE 128 //64
#define FLIGHT_LIST_START 0
#define FLIGHT_DATA_START 200
class logger_I2C_eeprom
{
public:
/**
* Initializes the EEPROM with a default pagesize of I2C_EEPROM_PAGESIZE.
*/
logger_I2C_eeprom(uint8_t deviceAddress);
//logger_I2C_eeprom(uint8_t deviceAddress, const unsigned int deviceSize);
uint8_t _deviceAddress;
void begin();
void clearFlightList();
void write_byte( unsigned long eeaddress, uint8_t data );
uint8_t read_byte( unsigned long eeaddress );
unsigned long readFlight(unsigned long eeaddress);
//int writeFlight(unsigned long eeaddress);
int readFlightList();
int writeFlightList();
int getLastFlightNbr();
bool eraseLastFlight();
int printFlightList();
void setFlightStartAddress(int flightNbr, long startAddress);
void setFlightEndAddress(int flightNbr, long endAddress);
void setFlightTimeData( long difftime);
long getFlightTimeData();
void setFlightAltitudeData( long altitude);
void setFlightPressureData( long pressure);
#ifdef LOG_VOLTAGE
void setFlightVoltageData(long voltage);
#endif
#if defined ALTIMULTIESP32_ACCELERO || defined ALTIMULTIESP32_ACCELERO_375 || defined ALTIMULTIESP32_ACCELERO_345
void setADXL375accelX(long accelX);
void setADXL375accelY(long accelY);
void setADXL375accelZ(long accelZ);
void setADXL345accelX(long accelX);
void setADXL345accelY(long accelY);
void setADXL345accelZ(long accelZ);
#endif
void setFlightTemperatureData (long temperature);
long getFlightAltitudeData();
long getFlightStart(int flightNbr);
long getFlightStop(int flightNbr);
void printFlightData(int flightNbr);
boolean CanRecord();
unsigned long writeFastFlight(unsigned long eeaddress);
long getSizeOfFlightData();
long getLastFlightEndAddress();
private:
FlightConfigStruct _FlightConfig[25];
FlightDataStruct _FlightData;
uint8_t _pageSize;
};
#endif
// END OF FILE