Repository navigation
Expand file tree
/
Copy pathSettingsStore.cpp
More file actions
69 lines (47 loc) · 2.49 KB
/
Copy pathSettingsStore.cpp
File metadata and controls
69 lines (47 loc) · 2.49 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
#include "SettingsStore.h"
#include <Preferences.h>
#include "Config.h"
namespace {
Preferences g_prefs;
const char *kNamespace = "sbsync";
} // namespace
namespace SettingsStore {
void begin() { g_prefs.begin(kNamespace, false); }
String wifiSsid() { return g_prefs.getString("wifi_ssid", ""); }
String wifiPassword() { return g_prefs.getString("wifi_pass", ""); }
void setWifiCredentials(const String &ssid, const String &password) {
g_prefs.putString("wifi_ssid", ssid);
g_prefs.putString("wifi_pass", password);
}
bool hasWifiCredentials() { return wifiSsid().length() > 0; }
int sdFlushIntervalMinutes() {
return g_prefs.getInt("sd_flush_min", SD_FLUSH_INTERVAL_MIN_DEFAULT);
}
void setSdFlushIntervalMinutes(int minutes) { g_prefs.putInt("sd_flush_min", minutes); }
// NVSのキー名は15文字までという制限があるため、短く省略しています。
int tempWarnLow() { return g_prefs.getInt("t_lo", TEMP_WARN_LOW_DEFAULT); }
int tempWarnHigh() { return g_prefs.getInt("t_hi", TEMP_WARN_HIGH_DEFAULT); }
void setTempWarnLow(int v) { g_prefs.putInt("t_lo", v); }
void setTempWarnHigh(int v) { g_prefs.putInt("t_hi", v); }
int humWarnLow() { return g_prefs.getInt("h_lo", HUM_WARN_LOW_DEFAULT); }
int humWarnHigh() { return g_prefs.getInt("h_hi", HUM_WARN_HIGH_DEFAULT); }
void setHumWarnLow(int v) { g_prefs.putInt("h_lo", v); }
void setHumWarnHigh(int v) { g_prefs.putInt("h_hi", v); }
int co2Warn() { return g_prefs.getInt("co2_warn", CO2_WARN_DEFAULT); }
void setCo2Warn(int v) { g_prefs.putInt("co2_warn", v); }
int batteryWarn() { return g_prefs.getInt("bat_warn", BATTERY_WARN_PERCENT); }
void setBatteryWarn(int v) { g_prefs.putInt("bat_warn", v); }
int orientationMode() { return g_prefs.getInt("orient", ORIENTATION_MODE_DEFAULT); }
void setOrientationMode(int mode) { g_prefs.putInt("orient", mode); }
int brightnessPercent() { return g_prefs.getInt("bright", BACKLIGHT_PERCENT_DEFAULT); }
void setBrightnessPercent(int percent) { g_prefs.putInt("bright", percent); }
int backlightAuto() { return g_prefs.getInt("blauto", BACKLIGHT_AUTO_DEFAULT); }
void setBacklightAuto(int on) { g_prefs.putInt("blauto", on); }
int lightThresholdStep() {
return g_prefs.getInt("lightth", LIGHT_THRESHOLD_STEP_DEFAULT);
}
void setLightThresholdStep(int step) { g_prefs.putInt("lightth", step); }
int groveSensorType() { return g_prefs.getInt("grove", GROVE_SENSOR_NONE); }
void setGroveSensorType(int type) { g_prefs.putInt("grove", type); }
void clearAll() { g_prefs.clear(); }
} // namespace SettingsStore