From 93b53a10d92e8b3493288c663d5c40ccb064a64a Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 18 Jan 2024 23:21:59 +0100 Subject: [PATCH] 0.8.59 * merge PR: solve display settings dependencies #1369 * fix language typos #1346 * full update of ePaper after booting #1107 * fix MqTT yield day reset even if `pause inverter during nighttime` isn't active #1368 --- src/CHANGES.md | 6 ++++++ src/app.cpp | 21 +++++++++++++++++++-- src/app.h | 4 +++- src/defines.h | 2 +- src/plugins/Display/Display.h | 4 ++-- src/plugins/Display/Display_ePaper.cpp | 10 +++++----- src/plugins/Display/Display_ePaper.h | 1 - src/publisher/pubMqtt.h | 8 +++++--- src/publisher/pubMqttIvData.h | 10 +++++----- src/web/RestApi.h | 14 +++++++------- src/web/lang.json | 2 +- src/web/web.h | 26 +++++++++++++------------- 12 files changed, 67 insertions(+), 41 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index d4969697..b02c9a96 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,11 @@ # Development Changes +## 0.8.59 - 2024-01-18 +* merge PR: solve display settings dependencies #1369 +* fix language typos #1346 +* full update of ePaper after booting #1107 +* fix MqTT yield day reset even if `pause inverter during nighttime` isn't active #1368 + ## 0.8.58 - 2024-01-17 * fix missing refresh URL #1366 * fix view of grid profile #1365 diff --git a/src/app.cpp b/src/app.cpp index 32a94cea..afe7e896 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -108,7 +108,7 @@ void app::setup() { #endif // Plugins #if defined(PLUGIN_DISPLAY) - if (mConfig->plugin.display.type != DISP_TYPE_T0_NONE) + if (DISP_TYPE_T0_NONE != mConfig->plugin.display.type) #if defined(ESP32) mDisplay.setup(this, &mConfig->plugin.display, &mSys, &mNrfRadio, &mCmtRadio, &mTimestamp); #else @@ -186,7 +186,7 @@ void app::regularTickers(void) { everySec(std::bind(&WebType::tickSecond, &mWeb), "webSc"); // Plugins #if defined(PLUGIN_DISPLAY) - if (mConfig->plugin.display.type != DISP_TYPE_T0_NONE) + if (DISP_TYPE_T0_NONE != mConfig->plugin.display.type) everySec(std::bind(&DisplayType::tickerSecond, &mDisplay), "disp"); #endif every(std::bind(&PubSerialType::tick, &mPubSerial), 5, "uart"); @@ -352,6 +352,14 @@ void app::tickSunrise(void) { #endif } +//----------------------------------------------------------------------------- +void app::notAvailChanged(void) { + #if defined(ENABLE_MQTT) + if (mMqttEnabled) + mMqtt.notAvailChanged(mAllIvNotAvail); + #endif +} + //----------------------------------------------------------------------------- void app::tickZeroValues(void) { zeroIvValues(!CHECK_AVAIL, SKIP_YIELD_DAY); @@ -403,6 +411,7 @@ void app::tickMidnight(void) { //----------------------------------------------------------------------------- void app::tickSend(void) { + bool notAvail = true; uint8_t fill = mCommunication.getFillState(); uint8_t max = mCommunication.getMaxFill(); if((max-MAX_NUM_INVERTERS) <= fill) { @@ -428,6 +437,9 @@ void app::tickSend(void) { if(!iv->radio->isChipConnected()) continue; + if(InverterStatus::OFF != iv->status) + notAvail = false; + iv->tickSend([this, iv](uint8_t cmd, bool isDevControl) { if(isDevControl) mCommunication.addImportant(iv, cmd); @@ -437,6 +449,10 @@ void app::tickSend(void) { } } + if(mAllIvNotAvail != notAvail) + once(std::bind(&app::notAvailChanged, this), 1, "avail"); + mAllIvNotAvail = notAvail; + updateLed(); } @@ -535,6 +551,7 @@ void app::resetSystem(void) { #endif mSendFirst = true; + mAllIvNotAvail = true; mSunrise = 0; mSunset = 0; diff --git a/src/app.h b/src/app.h index c9a2a9cc..aba05e00 100644 --- a/src/app.h +++ b/src/app.h @@ -319,7 +319,7 @@ class app : public IApp, public ah::Scheduler { #endif /*ENABLE_MQTT*/ #endif #if defined(PLUGIN_DISPLAY) - if(mConfig->plugin.display.type != DISP_TYPE_T0_NONE) + if(DISP_TYPE_T0_NONE != mConfig->plugin.display.type) mDisplay.payloadEventListener(cmd); #endif updateLed(); @@ -366,6 +366,7 @@ class app : public IApp, public ah::Scheduler { void tickMinute(void); void tickZeroValues(void); void tickMidnight(void); + void notAvailChanged(void); HmSystemType mSys; HmRadio<> mNrfRadio; @@ -402,6 +403,7 @@ class app : public IApp, public ah::Scheduler { uint8_t mSendLastIvId; bool mSendFirst; + bool mAllIvNotAvail; bool mNetworkConnected; diff --git a/src/defines.h b/src/defines.h index 5e479970..8262def3 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 58 +#define VERSION_PATCH 59 //------------------------------------- typedef struct { diff --git a/src/plugins/Display/Display.h b/src/plugins/Display/Display.h index 1748f4dd..5df55aab 100644 --- a/src/plugins/Display/Display.h +++ b/src/plugins/Display/Display.h @@ -93,7 +93,7 @@ class Display { private: void DataScreen() { - if (mCfg->type == DISP_TYPE_T0_NONE) + if (DISP_TYPE_T0_NONE == mCfg->type) return; float totalPower = 0.0; @@ -175,7 +175,7 @@ class Display { mMono->disp(); } #if defined(ESP32) && !defined(ETHERNET) - else if (mCfg->type == DISP_TYPE_T10_EPAPER) { + else if (DISP_TYPE_T10_EPAPER == mCfg->type) { mEpaper.loop((totalPower), totalYieldDay, totalYieldTotal, nrprod); mRefreshCycle++; } diff --git a/src/plugins/Display/Display_ePaper.cpp b/src/plugins/Display/Display_ePaper.cpp index b59e2f36..964034ea 100644 --- a/src/plugins/Display/Display_ePaper.cpp +++ b/src/plugins/Display/Display_ePaper.cpp @@ -27,10 +27,10 @@ DisplayEPaper::DisplayEPaper() { void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, uint32_t *utcTs, const char *version) { mUtcTs = utcTs; - mRefreshState = RefreshStatus::BLACK; - mSecondCnt = 2; + mRefreshState = RefreshStatus::LOGO; + mSecondCnt = 0; - if (type == DISP_TYPE_T10_EPAPER) { + if (DISP_TYPE_T10_EPAPER == type) { Serial.begin(115200); _display = new GxEPD2_BW(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY)); @@ -64,9 +64,9 @@ void DisplayEPaper::fullRefresh() { void DisplayEPaper::refreshLoop() { switch(mRefreshState) { case RefreshStatus::LOGO: - mFirst = false; _display->fillScreen(GxEPD_BLACK); _display->drawBitmap(0, 0, logo, 200, 200, GxEPD_WHITE); + _display->display(false); // full update mNextRefreshState = RefreshStatus::PARTITIALS; mRefreshState = RefreshStatus::WAIT; break; @@ -81,7 +81,7 @@ void DisplayEPaper::refreshLoop() { if(mSecondCnt == 0) { _display->fillScreen(GxEPD_WHITE); mNextRefreshState = RefreshStatus::PARTITIALS; - mRefreshState = (mFirst) ? RefreshStatus::LOGO : RefreshStatus::WAIT; + mRefreshState = RefreshStatus::WAIT; } break; diff --git a/src/plugins/Display/Display_ePaper.h b/src/plugins/Display/Display_ePaper.h index 14dd8564..0e077601 100644 --- a/src/plugins/Display/Display_ePaper.h +++ b/src/plugins/Display/Display_ePaper.h @@ -58,7 +58,6 @@ class DisplayEPaper { const char* _version; RefreshStatus mRefreshState, mNextRefreshState; uint8_t mSecondCnt; - bool mFirst = true; }; #endif // ESP32 diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 48300b30..bfab381b 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -156,12 +156,14 @@ class PubMqtt { snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "comm_disabled"); publish(mSubTopic, (((*mUtcTimestamp > (sunset + offsE)) || (*mUtcTimestamp < (sunrise + offsM))) ? dict[STR_TRUE] : dict[STR_FALSE]), true); - if(isSunrise) - mSendIvData.resetYieldDay(); - return true; } + void notAvailChanged(bool allNotAvail) { + if(!allNotAvail) + mSendIvData.resetYieldDay(); + } + bool tickerComm(bool disabled) { if (!mClient.connected()) return false; diff --git a/src/publisher/pubMqttIvData.h b/src/publisher/pubMqttIvData.h index c6fc5d10..a096ebc6 100644 --- a/src/publisher/pubMqttIvData.h +++ b/src/publisher/pubMqttIvData.h @@ -30,11 +30,11 @@ class PubMqttIvData { mRTRDataHasBeenSent = false; - mTable[IDLE] = &PubMqttIvData::stateIdle; - mTable[START] = &PubMqttIvData::stateStart; - mTable[FIND_NXT_IV] = &PubMqttIvData::stateFindNxtIv; - mTable[SEND_DATA] = &PubMqttIvData::stateSend; - mTable[SEND_TOTALS] = &PubMqttIvData::stateSendTotals; + mTable[IDLE] = &PubMqttIvData::stateIdle; + mTable[START] = &PubMqttIvData::stateStart; + mTable[FIND_NXT_IV] = &PubMqttIvData::stateFindNxtIv; + mTable[SEND_DATA] = &PubMqttIvData::stateSend; + mTable[SEND_TOTALS] = &PubMqttIvData::stateSendTotals; } void loop() { diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 2b808361..8cf1a41e 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -689,13 +689,13 @@ class RestApi { obj[F("disp_cont")] = (uint8_t)mConfig->plugin.display.contrast; obj[F("disp_graph_ratio")] = (uint8_t)mConfig->plugin.display.graph_ratio; obj[F("disp_graph_size")] = (uint8_t)mConfig->plugin.display.graph_size; - obj[F("disp_clk")] = (mConfig->plugin.display.type == DISP_TYPE_T0_NONE) ? DEF_PIN_OFF : mConfig->plugin.display.disp_clk; - obj[F("disp_data")] = (mConfig->plugin.display.type == DISP_TYPE_T0_NONE) ? DEF_PIN_OFF : mConfig->plugin.display.disp_data; - obj[F("disp_cs")] = (mConfig->plugin.display.type < DISP_TYPE_T3_PCD8544_84X48) ? DEF_PIN_OFF : mConfig->plugin.display.disp_cs; - obj[F("disp_dc")] = (mConfig->plugin.display.type < DISP_TYPE_T3_PCD8544_84X48) ? DEF_PIN_OFF : mConfig->plugin.display.disp_dc; - obj[F("disp_rst")] = (mConfig->plugin.display.type < DISP_TYPE_T3_PCD8544_84X48) ? DEF_PIN_OFF : mConfig->plugin.display.disp_reset; - obj[F("disp_bsy")] = (mConfig->plugin.display.type < DISP_TYPE_T10_EPAPER) ? DEF_PIN_OFF : mConfig->plugin.display.disp_busy; - obj[F("pir_pin")] = mConfig->plugin.display.pirPin; + obj[F("disp_clk")] = mConfig->plugin.display.disp_clk; + obj[F("disp_data")] = mConfig->plugin.display.disp_data; + obj[F("disp_cs")] = mConfig->plugin.display.disp_cs; + obj[F("disp_dc")] = mConfig->plugin.display.disp_dc; + obj[F("disp_rst")] = mConfig->plugin.display.disp_reset; + obj[F("disp_bsy")] = mConfig->plugin.display.disp_busy; + obj[F("pir_pin")] = mConfig->plugin.display.pirPin; } void getMqttInfo(JsonObject obj) { diff --git a/src/web/lang.json b/src/web/lang.json index f0c5dbd0..4eee86a9 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -1071,7 +1071,7 @@ { "token": "WARN_DIFF_ENV", "en": "your environment does not match the update file!", - "de": "Die ausgewählte Firmware passt uU. nicht zum Chipsatz!" + "de": "Die ausgewählte Firmware passt u.U. nicht zum Chipsatz!" }, { "token": "CONTIUE", diff --git a/src/web/web.h b/src/web/web.h index 0391e449..a6db6a71 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -601,23 +601,23 @@ class Web { mConfig->plugin.display.type = request->arg("disp_typ").toInt(); mConfig->plugin.display.contrast = (mConfig->plugin.display.type == DISP_TYPE_T0_NONE) || // contrast available only according optionsMap in setup.html, otherwise default value (mConfig->plugin.display.type == DISP_TYPE_T10_EPAPER) ? 140 : request->arg("disp_cont").toInt(); - mConfig->plugin.display.screenSaver = ((mConfig->plugin.display.type == DISP_TYPE_T1_SSD1306_128X64) || // screensaver available only according optionsMap in setup.html, otherwise default value - (mConfig->plugin.display.type == DISP_TYPE_T2_SH1106_128X64) || - (mConfig->plugin.display.type == DISP_TYPE_T4_SSD1306_128X32) || - (mConfig->plugin.display.type == DISP_TYPE_T5_SSD1306_64X48) || - (mConfig->plugin.display.type == DISP_TYPE_T6_SSD1309_128X64)) ? request->arg("disp_screensaver").toInt() : 1; - mConfig->plugin.display.graph_ratio = ((mConfig->plugin.display.type == DISP_TYPE_T1_SSD1306_128X64) || // display graph available only according optionsMap in setup.html, otherwise has to be 0 - (mConfig->plugin.display.type == DISP_TYPE_T2_SH1106_128X64) || - (mConfig->plugin.display.type == DISP_TYPE_T3_PCD8544_84X48) || - (mConfig->plugin.display.type == DISP_TYPE_T6_SSD1309_128X64)) ? request->arg("disp_graph_ratio").toInt() : 0; + mConfig->plugin.display.screenSaver = ((mConfig->plugin.display.type == DISP_TYPE_T1_SSD1306_128X64) // screensaver available only according optionsMap in setup.html, otherwise default value + || (mConfig->plugin.display.type == DISP_TYPE_T2_SH1106_128X64) + || (mConfig->plugin.display.type == DISP_TYPE_T4_SSD1306_128X32) + || (mConfig->plugin.display.type == DISP_TYPE_T5_SSD1306_64X48) + || (mConfig->plugin.display.type == DISP_TYPE_T6_SSD1309_128X64)) ? request->arg("disp_screensaver").toInt() : 0; + mConfig->plugin.display.graph_ratio = ((mConfig->plugin.display.type == DISP_TYPE_T1_SSD1306_128X64) // display graph available only according optionsMap in setup.html, otherwise has to be 0 + || (mConfig->plugin.display.type == DISP_TYPE_T2_SH1106_128X64) + || (mConfig->plugin.display.type == DISP_TYPE_T3_PCD8544_84X48) + || (mConfig->plugin.display.type == DISP_TYPE_T6_SSD1309_128X64)) ? request->arg("disp_graph_ratio").toInt() : 0; // available pins according pinMap in setup.html, otherwise default value mConfig->plugin.display.disp_data = (mConfig->plugin.display.type == DISP_TYPE_T0_NONE) ? DEF_PIN_OFF : request->arg("disp_data").toInt(); mConfig->plugin.display.disp_clk = (mConfig->plugin.display.type == DISP_TYPE_T0_NONE) ? DEF_PIN_OFF : request->arg("disp_clk").toInt(); - mConfig->plugin.display.disp_cs = (mConfig->plugin.display.type != DISP_TYPE_T3_PCD8544_84X48) && - (mConfig->plugin.display.type != DISP_TYPE_T10_EPAPER) ? DEF_PIN_OFF : request->arg("disp_cs").toInt(); - mConfig->plugin.display.disp_dc = (mConfig->plugin.display.type != DISP_TYPE_T3_PCD8544_84X48) && - (mConfig->plugin.display.type != DISP_TYPE_T10_EPAPER) ? DEF_PIN_OFF : request->arg("disp_dc").toInt(); + mConfig->plugin.display.disp_cs = (mConfig->plugin.display.type != DISP_TYPE_T3_PCD8544_84X48) + && (mConfig->plugin.display.type != DISP_TYPE_T10_EPAPER) ? DEF_PIN_OFF : request->arg("disp_cs").toInt(); + mConfig->plugin.display.disp_dc = (mConfig->plugin.display.type != DISP_TYPE_T3_PCD8544_84X48) + && (mConfig->plugin.display.type != DISP_TYPE_T10_EPAPER) ? DEF_PIN_OFF : request->arg("disp_dc").toInt(); mConfig->plugin.display.disp_reset = (mConfig->plugin.display.type != DISP_TYPE_T10_EPAPER) ? DEF_PIN_OFF : request->arg("disp_rst").toInt(); mConfig->plugin.display.disp_busy = (mConfig->plugin.display.type != DISP_TYPE_T10_EPAPER) ? DEF_PIN_OFF : request->arg("disp_bsy").toInt(); mConfig->plugin.display.pirPin = (mConfig->plugin.display.screenSaver != DISP_TYPE_T2_SH1106_128X64) ? DEF_PIN_OFF : request->arg("pir_pin").toInt(); // pir pin only for motion screensaver