Skip to content

Commit

Permalink
Added force time change
Browse files Browse the repository at this point in the history
Added few test modes
  • Loading branch information
NC22 committed Aug 13, 2024
1 parent 0b441fd commit 2d43573
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 7 deletions.
29 changes: 28 additions & 1 deletion Volna42/src/Env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ void Env::initDefaultTime() {
t = mktime(&tm);
defaultTime = t;
Serial.println(F("Default time reassigned by user config"));
Serial.println(defaultTime);
}

} else {
Expand Down Expand Up @@ -1268,6 +1269,13 @@ bool Env::isOnBattery() {
return lastState.onBattery;
}

/*
Full UI redraw
1. Update formatted time
2. Draw current UI layout according to this time to buffer
3. Send buffer to screen
*/
void Env::updateScreen() {

// if (lastState.partialUpdateTest) {
Expand Down Expand Up @@ -2534,8 +2542,27 @@ void Env::validateConfig(unsigned int version, std::vector<cfgOptionKeys> * upda
lastState.connectTimes = 0;
lastState.wakeUps = 0;

} else if (key == cScreenLandscape || key == cScreenRotate) {
} else if (key == cScreenLandscape || key == cScreenRotate || key == cImagePreset) {

resetPartialData();

} else if (key == cTimestamp) {

#if defined(ESP32)
if(sntp_enabled()) sntp_stop();
#else
sntp_stop();
#endif
yield();

Serial.println(F("Force manual timestamp set. NTP connection stopped."));
lastState.timeConfigured = false;
initDefaultTime();

lastState.timeConfigured = true;

yield();
break;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Volna42/src/Env.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <time.h> // time() ctime()
#include "sys/time.h"


#include <UserDefines.h>
#include <WidgetTypes.h>
#include "Config.h"
Expand All @@ -14,9 +15,11 @@

#if defined(ESP32)
#include <HTTPClient.h>
#include "esp_sntp.h"
// #include <thirdparty/TZ.h>
#else
#include <ESP8266HTTPClient.h>
#include "sntp.h"
// #include <TZ.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion Volna42/src/UserDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@
#define EPD_CLK_PIN -1 // Всегда D5 - GPIO 14 (SCLK) - SPI
#define EPD_DIN_PIN -1 // Всегда D7 - GPIO 13 (MOSI) - SPI

/*
// [Optional, my old setup] | НЕ Основная
// моя старая алт. распиновка, через резистор

/*
#define EPD_BUSY_PIN 2 // D4 - GPIO - 2 (+20кОм резистор на VCC)
#define EPD_RST_PIN 12 // D6 - GPIO - 12 (MISO)
#define EPD_DC_PIN 0 // D3 - GPIO - 0
Expand Down
2 changes: 1 addition & 1 deletion Volna42/src/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// #include <LocaleEn.h>
// #include <ui/out/locale_en/locale.h>

const char productVersion[] PROGMEM = "0.87";
const char productVersion[] PROGMEM = "0.88";

// [Режим точки доступа в случае отсутствия возможности подключится к Wifi]

Expand Down
28 changes: 25 additions & 3 deletions Volna42/src/WebServerEink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,13 +948,35 @@ void WebServerEink::apiTestData() {

env->lastState.extData.isDataValid = true;
env->lastState.extData.t = time(nullptr);
}

} else if (server->arg(i) == "ext_summer" || server->arg(i) == "ext_winter"){

if (server->arg(i) == "ext_winter") {

env->getConfig()->cfgValues[cTimestamp] = "2024-02-03 12:32:04";
env->lastState.extData.temperature = -21.12f;
env->lastState.extData.humidity = 67.8f;

} else {

env->lastState.extData.temperature = 27.12f;
env->lastState.extData.humidity = 50.7f;
env->getConfig()->cfgValues[cTimestamp] = "2024-06-12 15:44:04";
}

env->lastState.extData.bat = 68;
env->lastState.extData.isDataValid = true;
env->lastState.extData.t = time(nullptr);

std::vector<cfgOptionKeys> updatedKeys;
updatedKeys.push_back(cTimestamp);
env->validateConfig(-1, &updatedKeys);
}

break;
}

env->screen->drawUIToBuffer();
env->screen->updateScreen();
env->updateScreen();
server->send(200, "application/json", "{\"status\":\"ok\"}");

}
Expand Down
2 changes: 1 addition & 1 deletion Volna42/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void setup()
if (env.lastState.lowBatTick < 100) {
env.lastState.lowBatTick = 100;
env.screen->drawUILowBat();
env.updateScreen();
env.screen->updateScreen();
}

Serial.println(F("[On battery] LOW POWER or wrong detect voltage - [power off]"));
Expand Down

0 comments on commit 2d43573

Please sign in to comment.