Skip to content

Commit ffc980d

Browse files
committed
Extracting MicInfo to separate ElocConfig.hpp file
* No code changes, only movement
1 parent ac92535 commit ffc980d

File tree

3 files changed

+133
-60
lines changed

3 files changed

+133
-60
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Created on Wed Apr 26 2023
3+
*
4+
* Project: International Elephant Project (Wildlife Conservation International)
5+
*
6+
* The MIT License (MIT)
7+
* Copyright (c) 2023 Fabian Lindner
8+
* based on the work of @tbgilson (https://github.com/tbgilson)
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
11+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
12+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
13+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
14+
* subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in all copies or substantial
17+
* portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
20+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
*/
24+
25+
26+
#include <FS.h>
27+
#include "SPIFFS.h"
28+
29+
//BUGME: encapsulate these in a struct & implement a getter
30+
String gMicType="ns";
31+
String gMicBitShift="11";
32+
String gMicGPSCoords="ns";
33+
String gMicPointingDirectionDegrees="ns";
34+
String gMicHeight="ns";
35+
String gMicMountType="ns";
36+
String gMicBluetoothOnOrOff="on";
37+
38+
39+
40+
void writeMicInfo() {
41+
File file2 = SPIFFS.open("/micinfo.txt", FILE_WRITE);
42+
43+
file2.print(gMicType+'\n');
44+
file2.print(gMicBitShift+'\n');
45+
file2.print(gMicGPSCoords+'\n');
46+
file2.print(gMicPointingDirectionDegrees+'\n');
47+
file2.print(gMicHeight+'\n');
48+
file2.print(gMicMountType+'\n');
49+
file2.print(gMicBluetoothOnOrOff+'\n');
50+
file2.close();
51+
Serial.println("micinfo: "+gMicType+" "+gMicBitShift+" "+gMicGPSCoords+" "+gMicPointingDirectionDegrees+" "+gMicHeight+" "+gMicMountType+" "+gMicBluetoothOnOrOff);
52+
53+
54+
55+
56+
57+
}
58+
59+
60+
void readMicInfo() {
61+
if(!(SPIFFS.exists("/micinfo.txt"))){
62+
63+
printf("micinfo.txt not exist");
64+
writeMicInfo();
65+
66+
67+
68+
}
69+
File file2 = SPIFFS.open("/micinfo.txt", FILE_READ);
70+
gMicType=file2.readStringUntil('\n');
71+
gMicType.trim();
72+
gMicBitShift=file2.readStringUntil('\n');
73+
gMicBitShift.trim();
74+
gMicGPSCoords=file2.readStringUntil('\n');
75+
gMicGPSCoords.trim();
76+
gMicPointingDirectionDegrees=file2.readStringUntil('\n');
77+
gMicPointingDirectionDegrees.trim();
78+
gMicHeight=file2.readStringUntil('\n');
79+
gMicHeight.trim();
80+
gMicMountType=file2.readStringUntil('\n');
81+
gMicMountType.trim();
82+
gMicBluetoothOnOrOff=file2.readStringUntil('\n');
83+
gMicBluetoothOnOrOff.trim();
84+
85+
file2.close();
86+
Serial.println("micinfo: "+gMicType+" "+gMicBitShift+" "+gMicGPSCoords+" "+gMicPointingDirectionDegrees+" "+gMicHeight+" "+gMicMountType+" "+gMicBluetoothOnOrOff);
87+
88+
89+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Created on Wed Apr 26 2023
3+
*
4+
* Project: International Elephant Project (Wildlife Conservation International)
5+
*
6+
* The MIT License (MIT)
7+
* Copyright (c) 2023 Fabian Lindner
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
11+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13+
* subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all copies or substantial
16+
* portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
24+
25+
#ifndef ELOCCONFIG_HPP_
26+
#define ELOCCONFIG_HPP_
27+
28+
29+
//BUGME: encapsulate these in a struct & implement a getter
30+
#include "WString.h"
31+
extern String gMicType;
32+
extern String gMicBitShift;
33+
extern String gMicGPSCoords;
34+
extern String gMicPointingDirectionDegrees;
35+
extern String gMicHeight;
36+
extern String gMicMountType;
37+
extern String gMicBluetoothOnOrOff;
38+
39+
40+
void writeMicInfo();
41+
void readMicInfo();
42+
43+
#endif // ELOCCONFIG_HPP_

eloc610LowPowerPartition/src/main.cpp

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "lis3dh.h"
4444
#include "Battery.hpp"
4545
#include "ElocSystem.hpp"
46+
#include "ElocConfig.hpp"
4647
#include "ManualWakeup.hpp"
4748

4849
static const char *TAG = "main";
@@ -62,14 +63,7 @@ int gBufferCount=18; // so 6*4000 = 24k buf len
6263
float gVoltage[] = {0.0f, 0.0f, 0.0f, 0.0f};
6364
//always keep these in same order
6465
String gLocation = "not_set";
65-
String gMicType="ns";
66-
String gMicBitShift="11";
6766
int gbitShift;
68-
String gMicGPSCoords="ns";
69-
String gMicPointingDirectionDegrees="ns";
70-
String gMicHeight="ns";
71-
String gMicMountType="ns";
72-
String gMicBluetoothOnOrOff="on";
7367
bool gDisableBluetoothWhenRecording=false;
7468

7569
////// these are the things you can change for now.
@@ -1434,59 +1428,6 @@ String getSubstring(String data, char separator, int index)
14341428

14351429

14361430

1437-
void writeMicInfo() {
1438-
File file2 = SPIFFS.open("/micinfo.txt", FILE_WRITE);
1439-
1440-
file2.print(gMicType+'\n');
1441-
file2.print(gMicBitShift+'\n');
1442-
file2.print(gMicGPSCoords+'\n');
1443-
file2.print(gMicPointingDirectionDegrees+'\n');
1444-
file2.print(gMicHeight+'\n');
1445-
file2.print(gMicMountType+'\n');
1446-
file2.print(gMicBluetoothOnOrOff+'\n');
1447-
file2.close();
1448-
Serial.println("micinfo: "+gMicType+" "+gMicBitShift+" "+gMicGPSCoords+" "+gMicPointingDirectionDegrees+" "+gMicHeight+" "+gMicMountType+" "+gMicBluetoothOnOrOff);
1449-
1450-
1451-
1452-
1453-
1454-
}
1455-
1456-
1457-
void readMicInfo() {
1458-
if(!(SPIFFS.exists("/micinfo.txt"))){
1459-
1460-
printf("micinfo.txt not exist");
1461-
writeMicInfo();
1462-
1463-
1464-
1465-
}
1466-
File file2 = SPIFFS.open("/micinfo.txt", FILE_READ);
1467-
gMicType=file2.readStringUntil('\n');
1468-
gMicType.trim();
1469-
gMicBitShift=file2.readStringUntil('\n');
1470-
gMicBitShift.trim();
1471-
gMicGPSCoords=file2.readStringUntil('\n');
1472-
gMicGPSCoords.trim();
1473-
gMicPointingDirectionDegrees=file2.readStringUntil('\n');
1474-
gMicPointingDirectionDegrees.trim();
1475-
gMicHeight=file2.readStringUntil('\n');
1476-
gMicHeight.trim();
1477-
gMicMountType=file2.readStringUntil('\n');
1478-
gMicMountType.trim();
1479-
gMicBluetoothOnOrOff=file2.readStringUntil('\n');
1480-
gMicBluetoothOnOrOff.trim();
1481-
1482-
file2.close();
1483-
Serial.println("micinfo: "+gMicType+" "+gMicBitShift+" "+gMicGPSCoords+" "+gMicPointingDirectionDegrees+" "+gMicHeight+" "+gMicMountType+" "+gMicBluetoothOnOrOff);
1484-
1485-
1486-
}
1487-
1488-
1489-
14901431

14911432
void sendSettings() {
14921433
btwrite("#"+String(gSampleRate)+"#"+String(gSecondsPerFile)+"#"+gLocation);

0 commit comments

Comments
 (0)