Skip to content

Commit

Permalink
hard cutoff update
Browse files Browse the repository at this point in the history
  • Loading branch information
sblantipodi committed Apr 18, 2024
1 parent 6eee2b7 commit 43f2c7f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
3 changes: 1 addition & 2 deletions include/SolarStation.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ NeoPixelBus<NeoRgbFeature, NeoWs2812xMethod> *ledsEsp32 = NULL;

/****************** GLOBAL VARS ******************/
// MQTT publish retry until ack received
const int MQTT_PUBLISH_MAX_RETRY = 240; // max retry for MQTT publish
int number_of_attemps = 0;
bool onStateAckReceived = false;
unsigned long onStateNowMillis = 0;
Expand Down Expand Up @@ -118,7 +117,7 @@ bool waterPumpCutOff = true;
bool espCutOff = false;
int batteryLevelOnboot = -1;

const int FORCE_DEEP_SLEEP_TIME = 900000; // force deepSleep after 15 minutes
const int FORCE_DEEP_SLEEP_TIME = 3600000; // force deepSleep after 1 hour

// variable used for faster delay instead of arduino delay(), this custom delay prevent a lot of problem and memory leak
const int TENSECONDSPERIOD = 10000;
Expand Down
4 changes: 2 additions & 2 deletions include/Version.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

// AUTO GENERATED FILE, DO NOT EDIT
#ifndef VERSION
#define VERSION "1.12.38"
#define VERSION "1.12.39"
#endif
#ifndef BUILD_TIMESTAMP
#define BUILD_TIMESTAMP "2024-04-17 10:32:26.764800"
#define BUILD_TIMESTAMP "2024-04-18 20:24:27.606487"
#endif

3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ upload_speed = ${common_env_data.upload_speed}
board_build.filesystem = littlefs
monitor_filters = esp32_exception_decoder
;build_type = debug
monitor_port = COM27
monitor_port = COM8
;upload_port = COM27
upload_protocol = espota
upload_port = 192.168.1.59
Expand All @@ -94,6 +94,7 @@ lib_ldf_mode = deep
extra_scripts = post:platformio_version_increment/esp32_create_factory_bin_post.py
${common_env_data.extra_scripts}
lib_extra_dirs = ${common_env_data.lib_extra_dirs}
; '-D MAX_RECONNECT=4000' equals to 30 minutes more or less
build_flags =
-D TARGET_SOLAR_WS
'-D ARDUINO_USB_MODE=1'
Expand Down
14 changes: 7 additions & 7 deletions src/SolarStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ void setup() {
}

void turnOffBuiltInLed() {
ledsEsp32 = new NeoPixelBus<NeoRgbFeature, NeoWs2812xMethod>(1, OLED_RESET);
if (ledsEsp32 == NULL) {
Serial.println(F("OUT OF MEMORY"));
} else {
ledsEsp32->Begin();
ledsEsp32->Show();
ledsEsp32 = new NeoPixelBus<NeoRgbFeature, NeoWs2812xMethod>(1, OLED_RESET);
if (ledsEsp32 == nullptr) {
Serial.println(F("OUT OF MEMORY"));
}
ledsEsp32->Begin();
}
ledsEsp32->SetPixelColor(0, {0, 0, 0});
ledsEsp32->Show();
Expand Down Expand Up @@ -415,10 +415,10 @@ void espDeepSleep(bool hardCutOff) {
// force deepSleep after 15 minutes
void forceDeepSleep() {

if((millis() > nowMillisForceDeepSleepStatus + FORCE_DEEP_SLEEP_TIME) || (number_of_attemps >= MQTT_PUBLISH_MAX_RETRY)){
if(millis() > nowMillisForceDeepSleepStatus + FORCE_DEEP_SLEEP_TIME){
nowMillisForceDeepSleepStatus = millis();
digitalWrite(WATER_PUMP_PIN, LOW);
espDeepSleep(false, false);
espDeepSleep(false, true);
}

}
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.38
1.12.39

0 comments on commit 43f2c7f

Please sign in to comment.