forked from Open-Acidification/TankController
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEEPROM_TC.h
More file actions
152 lines (145 loc) · 6.42 KB
/
Copy pathEEPROM_TC.h
File metadata and controls
152 lines (145 loc) · 6.42 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#pragma once
#include "model/TC_util.h"
class EEPROM_TC {
public:
static EEPROM_TC* instance();
// read and write
float eepromReadFloat(uint16_t address);
int32_t eepromReadInt(uint16_t address);
void eepromWriteFloat(uint16_t address, float value);
void eepromWriteInt(uint16_t address, int32_t value);
void resetEEPROM();
// accessor methods
float getAmplitude(); // not used
float getThermalCorrection(); // adjustment to temperature probe
float getFrequency(); // not used
uint16_t getGoogleSheetInterval(); // how often to send data using PushingBox
float getGranularity(); // not used
bool getHeat(); // boolean for heater (true) or chiller (false)
bool getIgnoreBadPHSlope(); // whether to warn about an out-of-range calibration
bool getIgnoreBadThermalCorrection(); // whether to warn about an out-of-range calibration
float getKD(); // constants used for PID to calculate bubbler timer
float getKI(); // constants used for PID to calculate bubbler timer
float getKP(); // constants used for PID to calculate bubbler timer
void getMac(uint8_t* bytes); // used for DHCP request for IP address
float getMaxDataAge(); // not used
float getPh(); // target pH
uint32_t getPhRampTimeStart();
uint32_t getPhRampTimeEnd();
float getRampStartingPh();
uint32_t getPhSineStartTime();
uint32_t getPhSinePeriod();
float getPhSineAmplitude();
uint32_t getThermalRampTimeStart();
uint32_t getThermalRampTimeEnd();
float getThermalRampInitialValue();
float getPhDelay(); // not used
float getPhInterval(); // not used
float getPhSeriesPointer(); // not used
float getPhSeriesSize(); // not used
uint16_t getPHFunctionType();
uint16_t getThermalFunctionType();
uint16_t getTankID(); // unique tank identifier for reporting
uint32_t getThermalSineStartTime();
uint32_t getThermalSinePeriod();
float getThermalSineAmplitude();
float getThermalTarget(); // target temperature
float getTempDelay(); // not used
float getTempInterval(); // not used
float getTempSeriesPointer(); // not used
float getTempSeriesSize(); // not used
// setter methods
void setEEPROMAccessEnabled(bool enabled) {
eepromAccessEnabled = enabled;
}
void setAmplitude(float value);
void setThermalCorrection(float value);
void setFrequency(float value);
void setGoogleSheetInterval(uint16_t value);
void setGranularity(float value);
void setHeat(bool value);
void setIgnoreBadPHSlope(bool value);
void setIgnoreBadThermalCorrection(bool value);
void setKD(float value);
void setKI(float value);
void setKP(float value);
void setMac(uint8_t* bytes);
void setMaxDataAge(float value);
void setPh(float value);
void setPhRampTimeStart(uint32_t value);
void setPhRampTimeEnd(uint32_t value);
void setRampStartingPh(float value);
void setPhSineStartTime(uint32_t value);
void setPhSinePeriod(uint32_t value);
void setPhSineAmplitude(float value);
void setThermalRampTimeStart(uint32_t value);
void setThermalRampTimeEnd(uint32_t value);
void setThermalRampInitialValue(float value);
void setPhDelay(float value);
void setPhInterval(float value);
void setPhSeriesPointer(float value);
void setPhSeriesSize(float value);
void setPHFunctionType(uint16_t value);
void setThermalFunctionType(uint16_t value);
void setTankID(uint16_t value);
void setThermalSineStartTime(uint32_t value);
void setThermalSinePeriod(uint32_t value);
void setThermalSineAmplitude(float value);
void setTemp(float value);
void setTempDelay(float value);
void setTempInterval(float value);
void setTempSeriesPointer(float value);
void setTempSeriesSize(float value);
// other instance methods
void writeRemoteFileHeader(char* buffer, int size, int chunkNumber);
void writeAllToString(char* destination, int size);
private:
bool eepromAccessEnabled = true; // disables read/write functions if false to prevent infinite loop when EEPROM is
// corrupted and causing crashes
// note that while Arduino floats are 4 bytes, we sometimes allow 8 bytes!
// instance variables from v0.197
const uint16_t PH_ADDRESS = 0; // 9.999
const uint16_t THERMAL_TARGET_ADDRESS = 4; // 99.99
const uint16_t TANK_ID_ADDRESS = 8; // 999
const uint16_t THERMAL_CORRECTION_ADDRESS = 12; // 99.99
const uint16_t KP_ADDRESS = 20; // float
const uint16_t KI_ADDRESS = 28; // float
const uint16_t KD_ADDRESS = 36; // float
const uint16_t MAC_ADDRESS = 44; // 8 byte
const uint16_t HEAT_ADDRESS = 52; // bool
// new with v0.2
const uint16_t AMPLITUDE_ADDRESS = 56;
const uint16_t FREQUENCY_ADDRESS = 60;
const uint16_t GRANULARITY_ADDRESS = 64; // granularity for SD logging interval
const uint16_t MAX_DATA_AGE_ADDRESS = 68; // max data age for SD card
const uint16_t PH_SERIES_SIZE_ADDRESS = 72;
const uint16_t PH_SERIES_POINTER_ADDRESS = 76;
const uint16_t TEMP_SERIES_SIZE_ADDRESS = 80;
const uint16_t TEMP_SERIES_POINTER_ADDRESS = 84;
const uint16_t PH_INTERVAL_ADDRESS = 88;
const uint16_t PH_DELAY_ADDRESS = 92;
const uint16_t TEMP_INTERVAL_ADDRESS = 96;
const uint16_t TEMP_DELAY_ADDRESS = 100;
// new with v0.3
const uint16_t GOOGLE_INTERVAL_ADDRESS = 108;
const uint16_t PH_RAMP_STARTING_ADDRESS = 112;
const uint16_t PH_SINE_AMPLITUDE_ADDRESS = 112;
const uint16_t PH_RAMP_TIME_START_ADDRESS = 116;
const uint16_t PH_SINE_START_TIME_ADDRESS = 116;
const uint16_t PH_RAMP_TIME_END_ADDRESS = 120;
const uint16_t PH_SINE_PERIOD_ADDRESS = 120;
const uint16_t THERMAL_RAMP_INITIAL_VALUE_ADDRESS = 124;
const uint16_t THERMAL_SINE_AMPLITUDE_ADDRESS = 124;
const uint16_t THERMAL_RAMP_TIME_START_ADDRESS = 128;
const uint16_t THERMAL_SINE_START_TIME_ADDRESS = 128;
const uint16_t THERMAL_RAMP_TIME_END_ADDRESS = 132;
const uint16_t THERMAL_SINE_PERIOD_ADDRESS = 132;
const uint16_t PH_FUNCTION_TYPE_ADDRESS = 136;
const uint16_t THERMAL_FUNCTION_TYPE_ADDRESS = 140;
// new with v23.8.1
const uint16_t IGNORE_BAD_PH_SLOPE_ADDRESS = 144;
// new with v24.7.1
const uint16_t IGNORE_BAD_THERMAL_CORRECTION_ADDRESS = 148;
// class variables
static EEPROM_TC* _instance;
};