-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrailWave-Preferences.cpp
executable file
·53 lines (49 loc) · 1.44 KB
/
TrailWave-Preferences.cpp
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
#include "TrailWave.h"
void TrailRadio::initPrefs() {
prefs.begin("radioPrefs", false);
if (!prefs.isKey("nvsInit")) {
prefsSave();
prefs.putBool("nvsInit", true);
} else {
prefsLoad();
}
}
void TrailRadio::prefsLoad() {
mode = prefs.getInt("mode");
step = prefs.getULong64("step");
freqA = prefs.getULong64("freqA");
freqB = prefs.getULong64("freqB");
memSelection = prefs.getInt("memSelection");
freqAdjustStep = prefs.getInt("freqAdjustStep");
freq = vfo_is_A ? freqA : freqB;
Serial.print("Loaded mode: ");
Serial.println(mode);
Serial.print("Loaded step: ");
Serial.println(step);
Serial.print("Loaded freqA: ");
Serial.println(freqA);
Serial.print("Loaded freqB: ");
Serial.println(freqB);
displayUpdate();
}
void TrailRadio::prefsSave() {
freqA = vfo_is_A ? freq : freqA;
freqB = !vfo_is_A ? freq : freqB;
prefs.putInt("mode", mode);
prefs.putULong64("step", step);
prefs.putULong64("freqA", freqA);
prefs.putULong64("freqB", freqB);
prefs.putInt("memSelection", memSelection);
prefs.putInt("freqAdjustStep", freqAdjustStep);
Serial.print("Saved mode: ");
Serial.println(mode);
Serial.print("Saved step: ");
Serial.println(step);
Serial.print("Saved freqA: ");
Serial.println(freqA);
Serial.print("Saved freqB: ");
Serial.println(freqB);
}
void TrailRadio::prefsWipe() {
prefs.clear();
}