v2.0: Full localization (6 languages), first-run language screen, aircraft detail overhaul, aircraft-model API fallback, and multiple bugfixes
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
#include "settings_store.h"
|
||||
#include "config.h"
|
||||
#include "sd_mutex.h"
|
||||
#include <SD.h>
|
||||
|
||||
namespace SettingsStore {
|
||||
|
||||
namespace {
|
||||
uint8_t rangeIdx = Config::DEFAULT_RANGE_INDEX;
|
||||
bool inverted = false;
|
||||
bool inverted = true; // Dieses Board braucht invertDisplay(true) fuer korrekte Farben (siehe main.cpp)
|
||||
bool emergencyAlertOn = true;
|
||||
bool proximityAlertOn = true;
|
||||
bool flightLogbookOn = true;
|
||||
bool ledHeartbeatOn = true;
|
||||
uint8_t screenTimeoutMin = 0;
|
||||
bool hideGroundVehiclesOn = true;
|
||||
uint8_t languageIdx = 0;
|
||||
uint8_t unitsModeVal = 0;
|
||||
|
||||
void applyKeyValue(const String& key, const String& value) {
|
||||
if (key == "range_index") {
|
||||
@@ -28,11 +33,24 @@ namespace {
|
||||
flightLogbookOn = (value.toInt() != 0);
|
||||
} else if (key == "led_heartbeat") {
|
||||
ledHeartbeatOn = (value.toInt() != 0);
|
||||
} else if (key == "screen_timeout_min") {
|
||||
int v = value.toInt();
|
||||
if (v >= 0 && v <= 10) screenTimeoutMin = (uint8_t)v;
|
||||
} else if (key == "hide_ground_vehicles") {
|
||||
hideGroundVehiclesOn = (value.toInt() != 0);
|
||||
} else if (key == "language") {
|
||||
int v = value.toInt();
|
||||
if (v >= 0 && v <= 5) languageIdx = (uint8_t)v;
|
||||
} else if (key == "units_mode") {
|
||||
int v = value.toInt();
|
||||
if (v >= 0 && v <= 2) unitsModeVal = (uint8_t)v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void load() {
|
||||
SdMutex::Guard guard;
|
||||
|
||||
if (!SD.exists(Config::SD_SETTINGS_FILE)) return;
|
||||
|
||||
File f = SD.open(Config::SD_SETTINGS_FILE, FILE_READ);
|
||||
@@ -56,6 +74,8 @@ void load() {
|
||||
}
|
||||
|
||||
void save() {
|
||||
SdMutex::Guard guard;
|
||||
|
||||
File f = SD.open(Config::SD_SETTINGS_FILE, FILE_WRITE);
|
||||
if (!f) return;
|
||||
f.printf("range_index=%d\n", rangeIdx);
|
||||
@@ -64,6 +84,10 @@ void save() {
|
||||
f.printf("proximity_alert=%d\n", proximityAlertOn ? 1 : 0);
|
||||
f.printf("flight_logbook=%d\n", flightLogbookOn ? 1 : 0);
|
||||
f.printf("led_heartbeat=%d\n", ledHeartbeatOn ? 1 : 0);
|
||||
f.printf("screen_timeout_min=%d\n", screenTimeoutMin);
|
||||
f.printf("hide_ground_vehicles=%d\n", hideGroundVehiclesOn ? 1 : 0);
|
||||
f.printf("language=%d\n", languageIdx);
|
||||
f.printf("units_mode=%d\n", unitsModeVal);
|
||||
f.close();
|
||||
}
|
||||
|
||||
@@ -111,4 +135,38 @@ void setLedHeartbeatEnabled(bool on) {
|
||||
save();
|
||||
}
|
||||
|
||||
uint8_t screenTimeoutMinutes() { return screenTimeoutMin; }
|
||||
|
||||
void setScreenTimeoutMinutes(uint8_t minutes) {
|
||||
if (minutes <= 10) {
|
||||
screenTimeoutMin = minutes;
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
bool hideGroundVehicles() { return hideGroundVehiclesOn; }
|
||||
|
||||
void setHideGroundVehicles(bool on) {
|
||||
hideGroundVehiclesOn = on;
|
||||
save();
|
||||
}
|
||||
|
||||
uint8_t language() { return languageIdx; }
|
||||
|
||||
void setLanguage(uint8_t lang) {
|
||||
if (lang <= 5) {
|
||||
languageIdx = lang;
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t unitsMode() { return unitsModeVal; }
|
||||
|
||||
void setUnitsMode(uint8_t mode) {
|
||||
if (mode <= 2) {
|
||||
unitsModeVal = mode;
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user