From 455d29a6fa807ac1f2abda8b35fcd36259b41d89 Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 12 Jan 2024 00:00:52 +0100 Subject: [PATCH] 0.8.52 * possible fix of 'division by zero' #1345 * fix lang #1348 #1346 * fix timestamp `max AC power` #1324 * fix stylesheet overlay `max AC power` #1324 * fix download link #1340 * fix history graph * try to fix #1331 --- src/CHANGES.md | 9 +++++++++ src/defines.h | 2 +- src/hm/hmInverter.h | 8 ++++---- src/plugins/Display/Display_Mono.h | 15 +++++++++------ src/plugins/Display/Display_Mono_128X32.h | 4 ++-- src/plugins/Display/Display_Mono_128X64.h | 8 ++++---- src/plugins/Display/Display_Mono_64X48.h | 2 +- src/plugins/Display/Display_Mono_84X48.h | 2 +- src/plugins/history.h | 18 ++++++++++-------- src/publisher/pubMqttIvData.h | 2 +- src/web/html/history.html | 12 ++++++++---- src/web/html/index.html | 2 +- src/web/html/setup.html | 4 ++-- src/web/html/style.css | 2 +- src/web/html/visualization.html | 4 ++-- src/web/lang.json | 15 +++++++++++++++ 16 files changed, 71 insertions(+), 38 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index ca123e3b..34ea7b72 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,14 @@ # Development Changes +## 0.8.52 - 2024-01-11 +* possible fix of 'division by zero' #1345 +* fix lang #1348 #1346 +* fix timestamp `max AC power` #1324 +* fix stylesheet overlay `max AC power` #1324 +* fix download link #1340 +* fix history graph +* try to fix #1331 + ## 0.8.51 - 2024-01-10 * fix translation #1346 * further improve sending active power control command faster #1332 diff --git a/src/defines.h b/src/defines.h index 91fee041..e6a1d147 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 51 +#define VERSION_PATCH 52 //------------------------------------- typedef struct { diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 1f623d85..7bbf1019 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -961,8 +961,10 @@ static T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0) { acMaxPower = iv->getValue(i, rec); } } - if(acPower > acMaxPower) + if(acPower > acMaxPower) { + iv->tsMaxAcPower = *iv->timestamp; return acPower; + } } return acMaxPower; } @@ -981,10 +983,8 @@ static T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0) { dcMaxPower = iv->getValue(i, rec); } } - if(dcPower > dcMaxPower) { - iv->tsMaxAcPower = *iv->timestamp; + if(dcPower > dcMaxPower) return dcPower; - } } return dcMaxPower; } diff --git a/src/plugins/Display/Display_Mono.h b/src/plugins/Display/Display_Mono.h index 008f7378..a0d46d11 100644 --- a/src/plugins/Display/Display_Mono.h +++ b/src/plugins/Display/Display_Mono.h @@ -166,7 +166,10 @@ class DisplayMono { } uint8_t sss2pgpos(uint seconds_since_start) { - return(seconds_since_start * (mPgWidth - 1) / (mDisplayData->pGraphEndTime - mDisplayData->pGraphStartTime)); + uint32_t diff = (mDisplayData->pGraphEndTime - mDisplayData->pGraphStartTime); + if(diff) + return (seconds_since_start * (mPgWidth - 1) / diff); + return 0; } void calcPowerGraphValues() { @@ -175,6 +178,8 @@ class DisplayMono { mPgTimeOfDay = (mDisplayData->utcTs > mDisplayData->pGraphStartTime) ? mDisplayData->utcTs - mDisplayData->pGraphStartTime : 0; // current time of day with respect to current sunrise time if (oldTimeOfDay > mPgTimeOfDay) // new day -> reset old data resetPowerGraph(); + if(0 == mPgPeriod) + mPgPeriod = 1; mPgLastPos = std::min((uint8_t) (mPgTimeOfDay * (mPgWidth - 1) / mPgPeriod), (uint8_t) (mPgWidth - 1)); // current datapoint based on currenct time of day } @@ -190,15 +195,13 @@ class DisplayMono { uint8_t getPowerGraphXpos(uint8_t p) { if ((p <= mPgLastPos) && (mPgLastPos > 0)) return((p * (mPgWidth - 1)) / mPgLastPos); // scaling of x-axis - else - return(0); + return 0; } uint8_t getPowerGraphYpos(uint8_t p) { - if (p < mPgWidth) + if ((p < mPgWidth) && (mPgMaxPwr > 0)) return((mPgData[p] * (uint32_t) mPgHeight / mPgMaxPwr)); // scaling of data to graph height - else - return(0); + return 0; } void plotPowerGraph(uint8_t xoff, uint8_t yoff) { diff --git a/src/plugins/Display/Display_Mono_128X32.h b/src/plugins/Display/Display_Mono_128X32.h index 6ab21a6b..e904769f 100644 --- a/src/plugins/Display/Display_Mono_128X32.h +++ b/src/plugins/Display/Display_Mono_128X32.h @@ -1,5 +1,5 @@ //----------------------------------------------------------------------------- -// 2023 Ahoy, https://ahoydtu.de +// 2024 Ahoy, https://ahoydtu.de // Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed //----------------------------------------------------------------------------- @@ -107,7 +107,7 @@ class DisplayMono128X32 : public DisplayMono { void printText(const char *text, uint8_t line) { setFont(line); - uint8_t dispX = mLineXOffsets[line] + pixelShiftRange / 2 + mPixelshift; + uint8_t dispX = mLineXOffsets[line] + (pixelShiftRange / 2) + mPixelshift; if (isTwoRowLine(line)) { String stringText = String(text); diff --git a/src/plugins/Display/Display_Mono_128X64.h b/src/plugins/Display/Display_Mono_128X64.h index 2d5c13c2..34f35834 100644 --- a/src/plugins/Display/Display_Mono_128X64.h +++ b/src/plugins/Display/Display_Mono_128X64.h @@ -193,13 +193,13 @@ class DisplayMono128X64 : public DisplayMono { mDisplay->setFont(u8g2_font_ncenB10_symbols10_ahoy); char sym[]=" "; sym[0] = mDisplayData->RadioSymbol?'A':'E'; // NRF - mDisplay->drawStr(widthShrink / 2 + mPixelshift, mLineYOffsets[l_RSSI], sym); + mDisplay->drawStr((widthShrink / 2) + mPixelshift, mLineYOffsets[l_RSSI], sym); if (mDisplayData->MQTTSymbol) sym[0] = 'J'; // MQTT else sym[0] = mDisplayData->WifiSymbol?'B':'F'; // Wifi - mDisplay->drawStr(mDispWidth - mDisplay->getStrWidth(sym) - widthShrink / 2 + mPixelshift, mLineYOffsets[l_RSSI], sym); + mDisplay->drawStr(mDispWidth - mDisplay->getStrWidth(sym) - (widthShrink / 2) + mPixelshift, mLineYOffsets[l_RSSI], sym); mDisplay->sendBuffer(); mExtra++; @@ -241,8 +241,8 @@ class DisplayMono128X64 : public DisplayMono { mLineYOffsets[i] = yOff; dsc = mDisplay->getDescent(); yOff -= dsc; - if (l_Time == i) // prevent time and status line to touch - yOff++; // -> one pixels space + if (l_Time == i) // prevent time and status line to touch + yOff++; // -> one pixels space i++; } while(l_MAX_LINES>i); } diff --git a/src/plugins/Display/Display_Mono_64X48.h b/src/plugins/Display/Display_Mono_64X48.h index 68aa3cc4..a4ddc6ad 100644 --- a/src/plugins/Display/Display_Mono_64X48.h +++ b/src/plugins/Display/Display_Mono_64X48.h @@ -96,7 +96,7 @@ class DisplayMono64X48 : public DisplayMono { } void printText(const char *text, uint8_t line) { - uint8_t dispX = mLineXOffsets[line] + pixelShiftRange/2 + mPixelshift; + uint8_t dispX = mLineXOffsets[line] + pixelShiftRange / 2 + mPixelshift; setFont(line); mDisplay->drawStr(dispX, mLineYOffsets[line], text); diff --git a/src/plugins/Display/Display_Mono_84X48.h b/src/plugins/Display/Display_Mono_84X48.h index d9f1d98d..175fa17e 100644 --- a/src/plugins/Display/Display_Mono_84X48.h +++ b/src/plugins/Display/Display_Mono_84X48.h @@ -1,5 +1,5 @@ //----------------------------------------------------------------------------- -// 2023 Ahoy, https://ahoydtu.de +// 2024 Ahoy, https://ahoydtu.de // Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed //----------------------------------------------------------------------------- diff --git a/src/plugins/history.h b/src/plugins/history.h index 9ed7860d..c4d3ab35 100644 --- a/src/plugins/history.h +++ b/src/plugins/history.h @@ -28,7 +28,7 @@ class HistoryData { uint16_t dispIdx; // index for 1st Element to display from WattArr bool wrapped; // ring buffer for watt history - std::array data; + std::array data; void reset() { loopCnt = 0; @@ -78,13 +78,15 @@ class HistoryData { mMaximumDay = roundf(maxPwr); } - if (*mTs > mApp->getSunset()) { - if ((!mDayStored) && (yldDay > 0)) { - addValue(&mYieldDay, roundf(yldDay)); - mDayStored = true; - } - } else if (*mTs > mApp->getSunrise()) - mDayStored = false; + if((++mYieldDay.loopCnt % mYieldDay.refreshCycle) == 0) { + if (*mTs > mApp->getSunset()) { + if ((!mDayStored) && (yldDay > 0)) { + addValue(&mYieldDay, roundf(yldDay)); + mDayStored = true; + } + } else if (*mTs > mApp->getSunrise()) + mDayStored = false; + } } uint16_t valueAt(HistoryStorageType type, uint16_t i) { diff --git a/src/publisher/pubMqttIvData.h b/src/publisher/pubMqttIvData.h index 0a59fdd6..9a76d646 100644 --- a/src/publisher/pubMqttIvData.h +++ b/src/publisher/pubMqttIvData.h @@ -141,7 +141,7 @@ class PubMqttIvData { // calculate total values for RealTimeRunData_Debug if (CH0 == rec->assign[mPos].ch) { - if(mIv->getStatus() != InverterStatus::OFF) { + if(mIv->getStatus() > InverterStatus::OFF) { if(mIv->config->add2Total) { mTotalFound = true; switch (rec->assign[mPos].fieldId) { diff --git a/src/web/html/history.html b/src/web/html/history.html index d0f33755..975a02ed 100644 --- a/src/web/html/history.html +++ b/src/web/html/history.html @@ -44,19 +44,23 @@ function parseHistory(obj, namePrefix, execOnce) { mRefresh = obj.refresh var data = Object.assign({}, obj.value) - var numDataPts = data.length + numDataPts = Object.keys(data).length if (true == execOnce) { - let s = svg(null, (numDataPts + 2) * 2, mChartHeight, "chart"); + let s = document.createElementNS(svgns, "svg"); + s.setAttribute("class", "chart"); + s.setAttribute("width", (numDataPts + 2) * 2); + s.setAttribute("height", mChartHeight); s.setAttribute("role", "img"); + let g = document.createElementNS(svgns, "g"); s.appendChild(g); for (var i = 0; i < numDataPts; i++) { val = data[i]; let rect = document.createElementNS(svgns, "rect"); rect.setAttribute("id", namePrefix+"Rect" + i); - rect.setAttribute("x", String(i * 2) + ""); - rect.setAttribute("width", String(2) + ""); + rect.setAttribute("x", i * 2); + rect.setAttribute("width", 2); g.appendChild(rect); } document.getElementById(namePrefix+"Chart").appendChild(s); diff --git a/src/web/html/index.html b/src/web/html/index.html index 99a42089..e7b7afc4 100644 --- a/src/web/html/index.html +++ b/src/web/html/index.html @@ -26,7 +26,7 @@
  • {#DISCUSS} Discord
  • {#REPORT} {#ISSUES}
  • {#CONTRIBUTE} {#DOCUMENTATION}
  • -
  • Download & Test {#DEV_FIRMWARE}, {#DEV_CHANGELOG}
  • +
  • Download & Test {#DEV_FIRMWARE}, {#DEV_CHANGELOG}
  • {#DON_MAKE} {#DONATION}
  • diff --git a/src/web/html/setup.html b/src/web/html/setup.html index 62c52b3a..e75faf5b 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -269,7 +269,7 @@
    Discovery Config (homeassistant)
    - +
    @@ -309,7 +309,7 @@
    {#BTN_REBOOT_SUCCESSFUL_SAVE}
    - +
    diff --git a/src/web/html/style.css b/src/web/html/style.css index ef581ffa..395fcb99 100644 --- a/src/web/html/style.css +++ b/src/web/html/style.css @@ -666,7 +666,7 @@ div.hr { } -.tooltip{ +.tooltip:hover { position: relative; } .tooltip:hover:after { diff --git a/src/web/html/visualization.html b/src/web/html/visualization.html index 15b0c7b5..b99501f3 100644 --- a/src/web/html/visualization.html +++ b/src/web/html/visualization.html @@ -138,7 +138,7 @@ ml("div", {class: "row mt-2"},[ numMid(obj.ch[0][11], "W", "{#MAX_AC_POWER}", {class: "fs-6 tooltip", data: maxAcPwr}), numMid(obj.ch[0][8], "W", "{#DC_POWER}"), - numMid(obj.ch[0][0], "V", "{#DC_VOLTAGE}"), + numMid(obj.ch[0][0], "V", "{#AC_VOLTAGE}"), numMid(obj.ch[0][1], "A", "{#AC_CURRENT}"), numMid(obj.ch[0][3], "Hz", "{#FREQUENCY}"), numMid(obj.ch[0][9], "%", "{#EFFICIENCY}"), @@ -362,7 +362,7 @@ var v = getGridValue(glob); if(null === g) { if(0 == obj.grid.length) { - content.push(ml("div", {class: "row"}, ml("div", {class: "col"}, ml("p", {}, "{#PROFILE_NOT_READ}?")))) + content.push(ml("div", {class: "row"}, ml("div", {class: "col"}, ml("p", {}, "{#PROFILE_NOT_READ}")))) } else { content.push(ml("div", {class: "row"}, ml("div", {class: "col"}, ml("h5", {}, "{#UNKNOWN_PROFILE}")))) content.push(ml("div", {class: "row"}, ml("div", {class: "col"}, ml("p", {}, "{#OPEN_ISSUE}.")))) diff --git a/src/web/lang.json b/src/web/lang.json index 42c5e98a..6717306d 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -433,6 +433,16 @@ "en": "Line 1-4", "de": "Zeile 1-4" }, + { + "token": "BTN_SAVE", + "en": "save", + "de": "speichern" + }, + { + "token": "BTN_SEND", + "en": "send", + "de": "senden" + }, { "token": "BTN_REBOOT_SUCCESSFUL_SAVE", "en": "Reboot device after successful save", @@ -1118,6 +1128,11 @@ "en": "DC Voltage", "de": "DC Spannung" }, + { + "token": "AC_VOLTAGE", + "en": "AC Voltage", + "de": "Netzspannung" + }, { "token": "AC_CURRENT", "en": "AC Current",