Repository navigation
Expand file tree
/
Copy pathpocketmage_globals.cpp
More file actions
68 lines (58 loc) · 2.23 KB
/
Copy pathpocketmage_globals.cpp
File metadata and controls
68 lines (58 loc) · 2.23 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
#include <pocketmage.h>
#include <pocketmage_globals.h>
#include <esp_system.h>
// Shared state owned by the SDK. The OS and OTA apps both link against it, so
// these symbols are defined here once and nowhere else.
SPIClass *vspi = nullptr;
SPIClass *hspi = nullptr;
fs::FS *global_fs = nullptr;
Preferences prefs;
AppState CurrentAppState = HOME;
int TIMEOUT = 120;
bool DEBUG_VERBOSE = true;
bool SYSTEM_CLOCK = true;
bool SHOW_YEAR = true;
bool SAVE_POWER = true;
bool ALLOW_NO_MICROSD = true;
bool HOME_ON_BOOT = false;
bool FAST_REFRESH = POCKETMAGE_HW_VERSION == 1;
int OLED_BRIGHTNESS = 255;
int OLED_MAX_FPS = 60;
bool MUTE_BUZZER = false;
bool SD_SPI_COMPATIBILITY = false;
namespace pocketmage {
void loadSettings() {
prefs.begin("PocketMage", true);
TIMEOUT = prefs.getInt("TIMEOUT", 120);
DEBUG_VERBOSE = prefs.getBool("DEBUG_VERBOSE", true);
SYSTEM_CLOCK = prefs.getBool("SYSTEM_CLOCK", true);
SHOW_YEAR = prefs.getBool("SHOW_YEAR", true);
SAVE_POWER = prefs.getBool("SAVE_POWER", true);
ALLOW_NO_MICROSD = prefs.getBool("ALLOW_NO_SD", true);
PM_SDAUTO().setEditingFile(prefs.getString("editingFile", ""));
HOME_ON_BOOT = prefs.getBool("HOME_ON_BOOT", false);
FAST_REFRESH = prefs.getBool("FAST_REFRESH", POCKETMAGE_HW_VERSION == 1);
OLED_BRIGHTNESS = prefs.getInt("OLED_BRIGHTNESS", 255);
OLED_MAX_FPS = prefs.getInt("OLED_MAX_FPS", 60);
MUTE_BUZZER = prefs.getBool("MUTE_BUZZER", false);
SD_SPI_COMPATIBILITY = prefs.getBool("SD_SPI_CMPT", false);
I18n::setLanguage(static_cast<Lang>(prefs.getInt("Language", static_cast<int>(Lang::English))));
prefs.end();
}
void recoverFromCrash() {
esp_reset_reason_t reason = esp_reset_reason();
if (reason != ESP_RST_PANIC && reason != ESP_RST_WDT && reason != ESP_RST_TASK_WDT &&
reason != ESP_RST_INT_WDT) {
return;
}
prefs.begin("PocketMage", false);
prefs.putInt("CurrentAppState", HOME);
prefs.end();
PM_SDAUTO().setEditingFile("");
}
} // namespace pocketmage
// App-visible ABI version, read by external apps to compare the running host
// release with the SDK they were built against (see symbols.list).
// Must match the VERSION file at the repo root: CI fails the build when the
// two drift.
extern "C" const char pocketmage_sdk_version[] = "0.1.0";