1
0
mirror of https://github.com/revspace/operame synced 2024-12-04 13:47:29 +00:00

Show message during SPIFFS format

Also moved startup order around so module error message can be localized
with user language.
This commit is contained in:
Juerd Waalboer 2021-01-26 07:16:24 +01:00
parent 69ddf8054a
commit 29d873d268
2 changed files with 38 additions and 15 deletions

View File

@ -267,25 +267,41 @@ int get_co2() {
void setup() {
Serial.begin(115200);
Serial.println("Operame start");
SPIFFS.begin(true);
digitalWrite(pin_backlight, HIGH);
display.init();
display.fillScreen(TFT_BLACK);
display.setRotation(1);
sprite.createSprite(display.width(), display.height());
OperameLanguage::select(T, LANGUAGE);
if (!SPIFFS.begin(false)) {
display_lines(T.first_run, TFT_MAGENTA);
if (!SPIFFS.format()) {
display_big(T.error_format, TFT_RED);
delay(20*1000);
}
}
pinMode(pin_portalbutton, INPUT_PULLUP);
pinMode(pin_demobutton, INPUT_PULLUP);
pinMode(pin_pcb_ok, INPUT_PULLUP);
pinMode(pin_backlight, OUTPUT);
digitalWrite(pin_backlight, HIGH);
display.init();
display.fillScreen(TFT_BLACK);
display.setRotation(1);
sprite.createSprite(display.width(), display.height());
WiFiSettings.hostname = "operame-";
WiFiSettings.language = LANGUAGE;
WiFiSettings.begin();
OperameLanguage::select(T, WiFiSettings.language);
while (digitalRead(pin_pcb_ok)) {
display_big(T.error_module, TFT_RED);
delay(1000);
}
display_logo();
delay(2000);
hwserial1.begin(9600, SERIAL_8N1, pin_sensor_rx, pin_sensor_tx);
if (aqc_get_co2() >= 0) {
@ -298,14 +314,7 @@ void setup() {
Serial.println("Using MHZ driver.");
}
display_logo();
delay(2000);
WiFiSettings.hostname = "operame-";
WiFiSettings.language = LANGUAGE;
WiFiSettings.begin();
OperameLanguage::select(T, WiFiSettings.language);
for (auto& str : T.portal_instructions[0]) {
str.replace("{ssid}", WiFiSettings.hostname);
}
@ -328,7 +337,6 @@ void setup() {
mqtt_template = WiFiSettings.string("operame_mqtt_template", "{} PPM", T.config_mqtt_template);
WiFiSettings.info(T.config_template_info);
WiFiSettings.onConnect = [] {
display_big(T.connecting, TFT_BLUE);
check_portalbutton();

View File

@ -12,6 +12,7 @@ struct Texts {
*error_timeout,
*error_sensor,
*error_wifi,
*error_format,
*config_wifi,
*config_ota,
*config_co2_warning,
@ -29,6 +30,7 @@ struct Texts {
*wait
;
std::vector<std::list<String>> portal_instructions;
std::list<String> first_run;
};
std::map<const String, const String> languages {
@ -54,6 +56,7 @@ bool select(Texts& T, String language) {
T.error_timeout = "Time's up";
T.error_sensor = "sensor error";
T.error_wifi = "WiFi failed!";
T.error_format = "Formatting failed";
T.wait = "wait...";
T.config_wifi = "Use WiFi connection";
T.config_ota = "Enable wireless reprogramming. (Uses portal password!)";
@ -93,6 +96,11 @@ bool select(Texts& T, String language) {
"when you're done."
}
};
T.first_run = {
"DO NOT TURN OFF",
"Initializing",
"flash memory.",
};
return true;
}
@ -103,6 +111,7 @@ bool select(Texts& T, String language) {
T.error_timeout = "Tijd verstreken";
T.error_sensor = "sensorfout";
T.error_wifi = "WiFi mislukt!";
T.error_format = "Formatteren mislukt";
T.wait = "wacht...";
T.config_wifi = "WiFi-verbinding gebruiken";
T.config_ota = "Draadloos herprogrammeren inschakelen. (Gebruikt portaalwachtwoord!)";
@ -142,6 +151,12 @@ bool select(Texts& T, String language) {
"als u klaar bent."
}
};
T.first_run = {
"NIET",
"UITSCHAKELEN",
"Flashgeheugen",
"wordt voorbereid."
};
return true;
}