-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVariables.h
439 lines (365 loc) · 12.7 KB
/
Variables.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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
// https://en.cppreference.com/w/cpp/types/integer
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };
//char Disp_MENU1[] = {'L','O','G',' ','S','T','A','R','T',' ','&',' ','S','T','O','P',' ','M','E','N','U','\0'};
static const char Disp_MENU_NULL[] PROGMEM = "ENTER ESC";
static const char Disp_MENU_ERROR[] PROGMEM = " KEY ERROR ! ";
static const char Disp_MENU1[] PROGMEM = "LOG START & STOP MENU";
static const char Disp_MENU2[] PROGMEM = "LOG SAMPLE TIME MENU ";
static const char Disp_MENU3[] PROGMEM = "DISPLAY STANDBYE MENU";
static const char Disp_MENU4[] PROGMEM = "INFORMATION MENU";
static const char Disp_MENU5[] PROGMEM = "DATE & TIME ADJ. MENU";
static const char Disp_MENU6[] PROGMEM = "ENERGY METER MENU ";
static const char Disp_MENU7[] PROGMEM = "LOG FILE MAXSIZE MENU";
static const char Disp_MENU5_SUB7[] PROGMEM = "Date & Time Updated !";
static const char Disp_MENU6_SUB1[] PROGMEM = "Start Calib? 60 Secs.";
static const char Disp_MENU6_SUB2[] PROGMEM = "Sure To Start Calib.?";
static const char Disp_MENU6_SUB3[] PROGMEM = "Calibration Started !";
static const char Disp_MENU6_SUB4[] PROGMEM = "EU/US Sel. Active:";
static const char Disp_MENU6_SUB42[] PROGMEM = " EU";
static const char Disp_MENU6_SUB43[] PROGMEM = " US";
static const char Disp_MENU6_SUB5[] PROGMEM = "EU 230V / 50 Hz ? ";
static const char Disp_MENU6_SUB6[] PROGMEM = "US 110V / 60 Hz ? ";
static const char Disp_MENU6_SUB7[] PROGMEM = " Updated To";
static const char Disp_MENU6_SUB71[] PROGMEM = " 50 Hz ";
static const char Disp_MENU6_SUB72[] PROGMEM = " 60 Hz ";
//static const char Disp_MENU7_SUB1[] PROGMEM = "Active-> "; //9
static const char Disp_MENU7_SUB1[] PROGMEM = "500 Kbytes ";
static const char Disp_MENU7_SUB2[] PROGMEM = "1 Mbytes ";
static const char Disp_MENU7_SUB3[] PROGMEM = "2 Mbytes ";
static const char Disp_MENU7_SUB4[] PROGMEM = "4 Mbytes ";
static const char Disp_MENU7_SUB5[] PROGMEM = "8 Mbytes ";
static const char Disp_MENU7_SUB6[] PROGMEM = "16 Mbytes ";
static const char Disp_MENU7_SUB7[] PROGMEM = "32 Mbytes ";
static const char Disp_MENU_Enter[] PROGMEM = "Enter -> ";
static const char Disp_MENU_Activ[] PROGMEM = "Active.. ";
static const char Disp_MENU7_SUB8[] PROGMEM = " Sure? If Yes Enter ";
static const char Disp_MENU7_SUB9[] PROGMEM = "File Size Updated ! ";
/*
static const char Disp_MENU7_SUB12[] PROGMEM = " 500 KBytes "; //12
static const char Disp_MENU7_SUB13[] PROGMEM = " 1 MBytes "; //9
static const char Disp_MENU7_SUB14[] PROGMEM = " 2 MBytes "; //9
static const char Disp_MENU7_SUB15[] PROGMEM = " 4 MBytes "; //9
static const char Disp_MENU7_SUB16[] PROGMEM = " 10 MBytes "; //9
static const char Disp_MENU7_SUB17[] PROGMEM = " 20 MBytes "; //9
*/
static const char Disp_MENU1_SUB1[] PROGMEM = "LOG START ";
static const char Disp_MENU1_SUB2[] PROGMEM = "LOG STOP ";
static const char Disp_MENU1_SUB3[] PROGMEM = "LOG Started ! ";
static const char Disp_MENU1_SUB4[] PROGMEM = "LOG Stopped ! ";
static const char Disp_MENU2_SUB[] PROGMEM = "Enter -> "; //9
static const char Disp_MENU2_SUB1[] PROGMEM = " 0.5 Sec "; //12
static const char Disp_MENU2_SUB2[] PROGMEM = " 1 Sec "; //12
static const char Disp_MENU2_SUB3[] PROGMEM = " 2 Sec "; //12
static const char Disp_MENU2_SUB4[] PROGMEM = " 5 Sec "; //12
static const char Disp_MENU2_SUB5[] PROGMEM = " 10 Sec "; //12
static const char Disp_MENU2_SUB6[] PROGMEM = " 20 Sec "; //12
static const char Disp_MENU2_SUB7[] PROGMEM = " 60 Sec "; //12
static const char Disp_MENU2_SUB8[] PROGMEM = " Sure? If Yes Enter ";
static const char Disp_MENU2_SUB9[] PROGMEM = "Sample Time Updated !";
static const char Disp_MENU3_SUBMAIN[] PROGMEM = "STANDBYE ";
static const char Disp_MENU3_SUB1[] PROGMEM = "Enable ";
static const char Disp_MENU3_SUB2[] PROGMEM = "Disable";
static const char Disp_MENU3_SUB3[] PROGMEM = "Updated! On";
static const char Disp_MENU3_SUB4[] PROGMEM = "Updated! Off";
// "LOG START & STOP MENU";
//uId 756E6B77.6F000C05 ->17
//static const char Disp_MENU4_SUB3[] PROGMEM = "Term:115200 8n1 NL&CR";
static const char Disp_MENU4_SUB3_1[] PROGMEM = "uId ";
static const char Disp_MENU4_SUB4[] PROGMEM = "Term:115200 8n1 NL&CR";
static const char SD1_CARD[] PROGMEM = "SD1 Card ";
static const char SD2_CARD[] PROGMEM = "SD2 Card ";
static const char SDHC_CARD[] PROGMEM ="SDHC Card ";
static const char NO_FAT[] PROGMEM ="Fat Problem !";
static const char SD_CARD_ERR[] PROGMEM ="Card Problem !";
static const char SETTINGUP[] PROGMEM = "SettingUp"; //21-3
static const char CALIBRATING[] PROGMEM = "Calibrating";
static const char ICERROR[] PROGMEM = " IC Error";
static const char Repository[] PROGMEM = "https://github.com/ilkerya/Proximab";
static const char Terminal_1[] PROGMEM = "For Adjusting date&time send as below format";
static const char Terminal_2[] PROGMEM = "Year,Month,Date,Hour,Minute;Second";
static const char Terminal_3[] PROGMEM = "2020,05,27,21,14,23";
static const char Terminal_4[] PROGMEM = "For Adjusting serialID send as below format";
static const char Terminal_5[] PROGMEM = "EEEExxxx as4 digit HEX format";
const char *const Terminal_table[] PROGMEM = {Terminal_1, Terminal_2, Terminal_3, Terminal_4, Terminal_5};
#ifdef ENERGYMETER_EXISTS
struct EnergyIcVariables
{
uint8_t Mode = 0;
uint8_t Timer = 0;
bool Error = 0;
bool commscheck;
};
EnergyIcVariables EnergyMeterIC ;
#define FREQUENCY_50HZ 0x0000
#define FREQUENCY_60HZ 0x0010
uint16_t Mains_Frequency = FREQUENCY_50HZ;
#endif
// so variables
String Display_Line1 ="Display.........Line1";
String Display_Line2 ="Display........Line2.";
String Display_Line3 ="Display.......Line3..";
String Display_Line4 ="Display......Line4...";
String Display_Line5 ="Display.....Line5....";
String Display_Line6 ="Display....Line6.....";
String Display_Line7 ="Display...Line7......";
String Display_Line8 ="Display..Line8.......";
uint8_t MainMenu =0;
uint8_t DispRollIndex[4] = {1,0,0,0};
//2 1 0 0
//3 2 1 0
//4 3 2 1
//5 4 3 2
//6 5 4 3
//7 6 5 4
//8 7 6 5
//9 8 7 6
//1 9 8 7
//2 1 9 8
//3 2 1 9
//4 3 2 1
float RL1Min, RL1Max, RL2Min,RL2Max,CompValue;
String RLlVal, RL2Val;
String Relay1str, RlStr2, RlStr4, Relay2str, RlStr6, RlStr8;
#define ELEMENTS 12
const String KeyWords[12] = {"Tmp1","Tmp2","Tmp3","Hum1","Hum2","Hum3","PM25","PM10","Cur","Volt","Powr","PF",};
struct Various{
uint8_t MaxFileSizeSure;
uint8_t SampleTime;
};
Various KeySupport;
struct TaskOrg
{
uint16_t IntTimer_250 = 0;
uint16_t IntTimer_500 = 0;
uint16_t IntTimer_1 = 0;
uint16_t IntTimer_2 = 0;
uint16_t IntTimer_5 = 0;
uint16_t IntTimer_10 = 0;
uint16_t IntTimer_20 = 0;
uint16_t IntTimer_60 = 0;
bool Task_250msec =0;
bool Task_500msec =0;
bool Task_1Sec =0;
bool Task_2Sec =0;
bool Task_5Sec =0;
bool Task_10Sec =0;
bool Task_20Sec =0;
bool Task_60Sec =0;
};
TaskOrg Loop;
#define TASK_500MSEC 1
#define TASK_1SEC 2
#define TASK_2SEC 4
#define TASK_5SEC 8
#define TASK_10SEC 16
#define TASK_20SEC 32
#define TASK_60SEC 64
uint8_t SampleTime = TASK_2SEC; // 250msec 1 // 500 2 // 1Sec 4 // 2sec 8 // 5sec 16 // 10sec 32 // 20sec 64
// the logging file
File logfile;
String dataString = "";
//char LOG_FILE[] = "LOG_xxxx.csv";
char LOG_FILE[] = "Lxxxx_01.csv";
const char ConfigFile[] PROGMEM = "RLConfig.txt";
char Device_Id[5] = {'0','0','0','0','\0'};
char File_Que[3] = {'0','0','\0'};
String Config_Str = "";
struct SDCard_Variables
{
bool LogEnable; // log on or off eski LogStatus
bool LogBootInit; // log on init case eski LogStatusInit
bool Pause; // At SD Problem Try Again
uint16_t PauseTimer;
uint16_t PauseCount;
uint8_t Status;
bool FatError;
float Volume;
};
SDCard_Variables SDCard;
struct FileSize_Variables
{
uint32_t Total; // log on or off
uint32_t MaxSize;
uint8_t Byte; // log on init case
uint8_t Kbyte;
uint8_t Mbyte;
};
FileSize_Variables FileSize;
struct Key_Variables
{
uint32_t Adc = 0;
uint16_t Logger=0;
uint8_t BoardTimeOut = 0;
bool BoardTimeOutEnb = 0;
bool Left_Press = 0;
bool Down_Press = 0;
bool Right_Press = 0;
bool Up_Press = 0;
bool Left_Rel = 0;
bool Down_Rel = 0;
bool Right_Rel = 0;
bool Up_Rel = 0;
bool Error = 0;
bool Released = 0;
uint8_t TimeOut = 0;
bool TimeOutEnb = 0;
};
Key_Variables Key;
struct Sensors
{
uint32_t OnBoard;
uint32_t No1;
uint32_t No2;
uint32_t No3;
} ;
Sensors SensorId;
//2874
//String Sensor_Info_SDS= "";
//char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesdy", "Wedns.", "Thurs.", "Friday", "Satur."};
//static const char SD_Type[4][14] = {"SD1 Card " , "SD2 Card " , "SDHC Card " , "Card Problem !"};
const uint8_t numChars = 32;
char rxarr[numChars]; // an array to store the received data
boolean newData = false;
#define BUF_LENGTH 60
uint8_t PMBuffer[BUF_LENGTH];
struct
{
float Humidity_OnBoard;
float Temperature_OnBoard; // 27
float Humidity_Ch1;
float Temperature_Ch1; // 27
float Humidity_Ch2;
float Temperature_Ch2; // 27
float Humidity_Ch3;
float Temperature_Ch3; // 27
float Current;
float Voltage;
float PowerFactor;
float ActivePower;
float Frequency;
float Pressure; //
float TemperatureBMP; //
float Altitude; //
float PM25=0; //
float PM10=0; //
float WindRaw; // 35
uint16_t WindMPH; // 31
uint16_t WindTemp; // 35
uint16_t Luminosity;
}Values;
#ifdef ACCL_GYRO_SENSOR_EXISTS
struct
{
float x;
float y; // 27
float z; //
}Accelometer;
#endif
/*
struct
{
float x;
float y; // 27
float z; //
}Gyro;
*/
// EEPROM ADDRESSES
#define NVRAM_ID1 4
#define NVRAM_ID2 5
#define NVRAM_ID3 6
#define NVRAM_ID4 7
#define EE_LOGSTATUS 8
#define EE_SAMPLE 10
#define NVRAM_QUE1 14
#define NVRAM_QUE2 15
#define EE_STANDBYE 16
#define EE_FILESIZE 20
#define EE_MAINSFREQ 22
#define EE_ADE_FREQ 32 // eepROM ADRESS
#define HERTZ_50 ON
#define HERTZ_60 OFF
String Str_Time="";
String Str_Date="";
struct
{
uint16_t Year=0;
uint16_t Month=0;
uint16_t Day=0;
uint16_t Hour=0;
uint16_t Minute=0;
uint16_t Second=0;
bool Init=0;
bool RTC_Update=0;
uint16_t Disp_UpdateTimer=0;
uint16_t Disp_Flash=0;
}DateTimeBuf;
struct
{
bool RTC_Update=0;
bool OLED_Init = 0 ;
uint8_t MenuTimeout=0;
uint8_t Flash=0;
uint16_t OLED_Timer = 0;
bool InitDelay = 0;
bool SleepEnable = 0;
uint8_t ValueTimer = 0;
bool ExpSensOnb =0;
bool ExpSens1 =0;
bool ExpSens2 =0;
bool ExpSens3 =0;
uint8_t SensorRollTimer = 0;
uint8_t ReInit_Timer = 2;
bool ReInit_Enable = OFF;
}Display;
/*
unsigned int AD_Value1;
unsigned int AD_Value2;
unsigned int AD_Value3;
unsigned int Current_Mains_Raw;
unsigned int Current_Mains_Raw_Trim;
float Current_Mains;
float Current_MainsAverage;
float Current_Mains_Rms ;
float Current_Mains_Av ;
unsigned int CurrentArray[10];
byte CurrentIndexer = 0;
unsigned int TrimpotAdc ;
unsigned int Mains_Volt_Raw ;
unsigned int Mains_Volt ;
*/
/*
Display.
// for wind sensor
float zeroWindAdjustment = 0.1; // individual adjustment parameter for wind sensor (standard = 0.1)
const double F_A_temp = 1.00857557; // constants for calibration factors of Y=A*X+B equation for air temperature, relative humidity, and globe temperature
const double F_B_temp = -0.872682478; // based on own calibration data - see reference on authors' website
const double F_A_hum = 1.087101959;
const double F_B_hum = -7.173821971;
const double F_A_globe = 0.946524358;
const double F_B_globe = 0.698608493;
float RV_ADunits; // variable for analog signal readings of wind sensor
float RV_ADunits_dev1000; // variable for adjusted analog signal readings of wind sensor
const float T_rev_wind = 21.9; // constants for wind speed calculation - based on own calibration data - see reference on authors' website
const float v_calc_F1 = 15.36921;
const float v_calc_F2 = 0.01788;
const float v_calc_F3 = -29.04560;
const float v_calc_F4 = 1.01536;
double velReading = 0;
double tempReading = 25; //default // variables for sensor readings' temporary storage
*/