From 14bdd100511e854008b9a7115c0e8035206e4265 Mon Sep 17 00:00:00 2001 From: Grigorii Merkushev Date: Sun, 26 Sep 2021 16:40:54 +0200 Subject: [PATCH] minor updates and fixes --- esp32/src/climate.cpp | 3 ++- esp32/src/config.h | 4 +++- esp32/src/display.cpp | 23 +++++++++++++++-------- esp32/src/display.h | 2 +- esp32/src/main.cpp | 4 ++++ esp32/src/telemetry.cpp | 15 +++++++++++++++ esp32/src/telemetry.h | 1 + 7 files changed, 41 insertions(+), 11 deletions(-) diff --git a/esp32/src/climate.cpp b/esp32/src/climate.cpp index 7bac156..b061a89 100644 --- a/esp32/src/climate.cpp +++ b/esp32/src/climate.cpp @@ -52,7 +52,6 @@ time in UTC { ClimateData data; - // Get temperature event and print its value. sensors_event_t event; dht.temperature().getEvent(&event); if (isnan(event.temperature)) @@ -196,6 +195,8 @@ time in UTC telemetryData.climateConfig.nightTempToleranceWarm = NIGHT_TEMP_TOLERANCE_WARM; telemetryData.climateConfig.nightTempToleranceCold = NIGHT_TEMP_TOLERANCE_COLD; + telemetryData.fullfilled = true; + return telemetryData; } } diff --git a/esp32/src/config.h b/esp32/src/config.h index 3fed960..9bfd428 100644 --- a/esp32/src/config.h +++ b/esp32/src/config.h @@ -2,6 +2,8 @@ #define CONFIG #define SENSORS_COUNT 2 -#define TERRARIUM_ID 3 +#define TERRARIUM_ID 1 + +#define VERSION "v2.0.1" #endif \ No newline at end of file diff --git a/esp32/src/display.cpp b/esp32/src/display.cpp index 053308e..aaee99a 100644 --- a/esp32/src/display.cpp +++ b/esp32/src/display.cpp @@ -11,10 +11,10 @@ namespace Display void render(DisplayData displayData) { // just do clear? - // clearRow(0); - // clearRow(1); - // clearRow(2); - // clearRow(3); + // clearRow(0); + // clearRow(1); + // clearRow(2); + // clearRow(3); renderHarvestInfo(displayData.nextHarvestInSec); renderClimate(displayData); @@ -23,16 +23,23 @@ namespace Display renderSubmissionInfo(displayData.submission); } -void renderSubmissionInfo(bool submission) -{ + void bootScreen(){ + lcd.setCursor(0, 0); + lcd.print("version: "); + lcd.print(VERSION); + } + + void renderSubmissionInfo(bool submission) + { lcd.setCursor(9, 2); lcd.print(" "); lcd.print(" "); - if (submission){ + if (submission) + { lcd.setCursor(9, 2); lcd.print("S"); } -} + } void renderHarvestInfo(int secondsToNextHarvest) { diff --git a/esp32/src/display.h b/esp32/src/display.h index 3d9557c..858b56e 100644 --- a/esp32/src/display.h +++ b/esp32/src/display.h @@ -38,6 +38,6 @@ namespace Display void clearRow(int row); void render(DisplayData displayData); void renderSubmissionInfo(bool submission); - + void bootScreen(); } #endif \ No newline at end of file diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 36ad7cf..8234ab1 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -38,6 +38,8 @@ void setup() Serial.begin(115200); Display::displaySetup(); + Display::bootScreen(); + //connect(); RealTime::setupRtcModule(); @@ -56,6 +58,8 @@ void setup() NULL // Task handle ); + delay(1000); + } void loop() diff --git a/esp32/src/telemetry.cpp b/esp32/src/telemetry.cpp index 56ef117..8b2a4d9 100644 --- a/esp32/src/telemetry.cpp +++ b/esp32/src/telemetry.cpp @@ -8,6 +8,21 @@ namespace Telemetry void send(TelemteryData telemteryData) { + if (!telemteryData.fullfilled){ + Serial.println("sample is not fullfilled yet."); + return; + } + + if (telemteryData.hotSide.t == 0 || telemteryData.coldSide.t == 0){ + Serial.println("sample is not fullfilled yet."); + return; + } + + if (telemteryData.hotSide.h > 100 || telemteryData.hotCenter.h > 100 || telemteryData.coldCenter.h > 100 || telemteryData.coldSide.h > 100){ + Serial.println("sample data has been corrupted (humidity > 100%)."); + return; + } + Net::connect(false); char telemetryEndpoint [200]; diff --git a/esp32/src/telemetry.h b/esp32/src/telemetry.h index ce6c28a..dad661c 100644 --- a/esp32/src/telemetry.h +++ b/esp32/src/telemetry.h @@ -31,6 +31,7 @@ namespace Telemetry ClimateConfig climateConfig; bool heater; HeaterPhase heaterPhase; + bool fullfilled; }; void send(TelemteryData telemteryData);