Skip to content

Commit

Permalink
0.8.52
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lumapu committed Jan 11, 2024
1 parent 9f39e5c commit 455d29a
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 38 deletions.
9 changes: 9 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 51
#define VERSION_PATCH 52

//-------------------------------------
typedef struct {
Expand Down
8 changes: 4 additions & 4 deletions src/hm/hmInverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
15 changes: 9 additions & 6 deletions src/plugins/Display/Display_Mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
}

Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/Display/Display_Mono_128X32.h
Original file line number Diff line number Diff line change
@@ -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
//-----------------------------------------------------------------------------

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/Display/Display_Mono_128X64.h
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/Display/Display_Mono_64X48.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/Display/Display_Mono_84X48.h
Original file line number Diff line number Diff line change
@@ -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
//-----------------------------------------------------------------------------

Expand Down
18 changes: 10 additions & 8 deletions src/plugins/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t, HISTORY_DATA_ARR_LENGTH + 1> data;
std::array<uint16_t, (HISTORY_DATA_ARR_LENGTH + 1)> data;

void reset() {
loopCnt = 0;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/publisher/pubMqttIvData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 8 additions & 4 deletions src/web/html/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,23 @@ <h3>{#TOTAL_YIELD_PER_DAY}</h3>
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);
Expand Down
2 changes: 1 addition & 1 deletion src/web/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3>{#SUPPORT}:</h3>
<li>{#DISCUSS} <a href="https://discord.gg/WzhxEY62mB">Discord</a></li>
<li>{#REPORT} <a href="https://github.com/lumapu/ahoy/issues" target="_blank">{#ISSUES}</a></li>
<li>{#CONTRIBUTE} <a href="https://github.com/lumapu/ahoy/blob/main/User_Manual.md" target="_blank">{#DOCUMENTATION}</a></li>
<li><a href="https://fw.ahoydtu.de/dev/" target="_blank">Download</a> & Test {#DEV_FIRMWARE}, <a href="https://github.com/lumapu/ahoy/blob/development03/src/CHANGES.md" target="_blank">{#DEV_CHANGELOG}</a></li>
<li><a href="https://fw.ahoydtu.de/fw/dev/" target="_blank">Download</a> & Test {#DEV_FIRMWARE}, <a href="https://github.com/lumapu/ahoy/blob/development03/src/CHANGES.md" target="_blank">{#DEV_CHANGELOG}</a></li>
<li>{#DON_MAKE} <a href="https://paypal.me/lupusch" target="_blank">{#DONATION}</a></li>
</ul>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/web/html/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
<div class="row mb-3">
<div class="col-12 col-sm-3 my-2">Discovery Config (homeassistant)</div>
<div class="col-12 col-sm-9">
<input type="button" name="mqttDiscovery" id="mqttDiscovery" class="btn" value="send" onclick="sendDiscoveryConfig()"/>
<input type="button" name="mqttDiscovery" id="mqttDiscovery" class="btn" value="{#BTN_SEND}" onclick="sendDiscoveryConfig()"/>
<span id="apiResultMqtt"></span>
</div>
</div>
Expand Down Expand Up @@ -309,7 +309,7 @@
<div class="col-8 col-sm-3">{#BTN_REBOOT_SUCCESSFUL_SAVE}</div>
<div class="col-4 col-sm-9">
<input type="checkbox" name="reboot" checked />
<input type="submit" value="save" class="btn right"/>
<input type="submit" value="{#BTN_SAVE}" class="btn right"/>
</div>
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion src/web/html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ div.hr {
}


.tooltip{
.tooltip:hover {
position: relative;
}
.tooltip:hover:after {
Expand Down
4 changes: 2 additions & 2 deletions src/web/html/visualization.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
Expand Down Expand Up @@ -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}."))))
Expand Down
15 changes: 15 additions & 0 deletions src/web/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -1118,6 +1128,11 @@
"en": "DC Voltage",
"de": "DC Spannung"
},
{
"token": "AC_VOLTAGE",
"en": "AC Voltage",
"de": "Netzspannung"
},
{
"token": "AC_CURRENT",
"en": "AC Current",
Expand Down

0 comments on commit 455d29a

Please sign in to comment.