Skip to content

Commit

Permalink
0.8.141
Browse files Browse the repository at this point in the history
* fix display IP in ePaper display (ETH or WiFi, static or DHCP) #1439
  • Loading branch information
lumapu committed Aug 16, 2024
1 parent d14d783 commit f90aacc
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* increased maximum number of alarms to 50 for ESP32 #1470
* fix German translation #1688
* fix display of delete and edit buttons in `/setup` #1372
* fix display IP in ePaper display (ETH or WiFi, static or DHCP) #1439

# RELEASE 0.8.140 - 2024-08-16

Expand Down
4 changes: 4 additions & 0 deletions src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ class app : public IApp, public ah::Scheduler {
return mNetwork->isApActive();
}

bool isNetworkConnected() override {
return mNetwork->isConnected();
}

void setRebootFlag() override {
once(std::bind(&app::tickReboot, this), 3, "rboot");
}
Expand Down
1 change: 1 addition & 0 deletions src/appInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class IApp {
virtual String getIp(void) = 0;
virtual String getMac(void) = 0;
virtual bool isApActive(void) = 0;
virtual bool isNetworkConnected() = 0;

virtual uint32_t getUptime() = 0;
virtual uint32_t getTimestamp() = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/hm/hmInverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const calcFunc_t<T> calcFunctions[] = {
template <class REC_TYP>
class Inverter {
public: /*types*/
#ifdef(ESP32)
#if defined(ESP32)
constexpr static uint8_t MaxAlarmNum = 50;
#else
constexpr static uint8_t MaxAlarmNum = 10;
Expand Down
2 changes: 1 addition & 1 deletion src/network/AhoyNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AhoyNetwork {
}

bool isConnected() const {
return (mStatus == NetworkState::CONNECTED);
return ((mStatus == NetworkState::CONNECTED) || (mStatus == NetworkState::GOT_IP));
}

bool updateNtpTime(void) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/Display/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class Display {
}
#if defined(ESP32)
else if (DISP_TYPE_T10_EPAPER == mCfg->type) {
mEpaper.loop((totalPower), totalYieldDay, totalYieldTotal, nrprod);
mEpaper.loop((totalPower), totalYieldDay, totalYieldTotal, nrprod, mApp->getIp(), mApp->isNetworkConnected());
mRefreshCycle++;

if (mRefreshCycle > 2880) { // 15 * 2280 = 44300s = 12h
Expand Down
16 changes: 9 additions & 7 deletions src/plugins/Display/Display_ePaper.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "Display_ePaper.h"

#if defined(ESP32)
#include <WiFi.h>
#include "../../utils/helper.h"
#include "imagedata.h"
#include "defines.h"
Expand All @@ -13,7 +12,9 @@ static const uint32_t spiClk = 4000000; // 4 MHz
SPIClass hspi(HSPI);
#endif

DisplayEPaper::DisplayEPaper() {
DisplayEPaper::DisplayEPaper()
: mNetworkConnected {false}
{
mDisplayRotation = 2;
mHeadFootPadding = 16;
memset(_fmtText, 0, EPAPER_MAX_TEXT_LEN);
Expand Down Expand Up @@ -122,8 +123,8 @@ void DisplayEPaper::headlineIP() {
_display->fillScreen(GxEPD_BLACK);

do {
if ((WiFi.isConnected() == true) && (WiFi.localIP() > 0)) {
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "%s", WiFi.localIP().toString().c_str());
if (mNetworkConnected == true) {
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "%s", _settedIP.c_str());
} else {
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, STR_NO_WIFI);
}
Expand Down Expand Up @@ -289,14 +290,15 @@ void DisplayEPaper::actualPowerPaged(float totalPower, float totalYieldDay, floa
} while (_display->nextPage());
}
//***************************************************************************
void DisplayEPaper::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) {
void DisplayEPaper::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod, String ip, bool networkConnected) {
mNetworkConnected = networkConnected;
if(RefreshStatus::DONE != mRefreshState)
return;

// check if the IP has changed
if (_settedIP != WiFi.localIP().toString()) {
if (_settedIP != ip) {
// save the new IP and call the Headline Function to adapt the Headline
_settedIP = WiFi.localIP().toString();
_settedIP = ip;
headlineIP();
}

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/Display/Display_ePaper.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DisplayEPaper {
void fullRefresh();
void 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);
void config(uint8_t rotation, bool enPowerSave);
void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod);
void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod, String ip, bool networkConnected);
void refreshLoop();
void tickerSecond();

Expand Down Expand Up @@ -66,6 +66,7 @@ class DisplayEPaper {

uint8_t mSecondCnt;
bool mLogoDisplayed;
bool mNetworkConnected;
#if defined(SPI_HAL)
epdHal hal;
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/plugin_lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define STR_OFFLINE "aus"
#define STR_ONLINE "aktiv"
#define STR_NO_INVERTER "kein inverter"
#define STR_NO_WIFI "WLAN nicht verbunden"
#define STR_NO_WIFI "Netzwerk nicht verbunden"
#define STR_VERSION "Version"
#define STR_ACTIVE_INVERTERS "aktive WR"
#define STR_TODAY "heute"
Expand All @@ -23,7 +23,7 @@
#define STR_OFFLINE "eteint"
#define STR_ONLINE "online"
#define STR_NO_INVERTER "pas d'onduleur"
#define STR_NO_WIFI "WiFi not connected"
#define STR_NO_WIFI "Network not connected"
#define STR_VERSION "Version"
#define STR_ACTIVE_INVERTERS "active Inv"
#define STR_TODAY "today"
Expand All @@ -34,7 +34,7 @@
#define STR_OFFLINE "offline"
#define STR_ONLINE "online"
#define STR_NO_INVERTER "no inverter"
#define STR_NO_WIFI "WiFi not connected"
#define STR_NO_WIFI "Network not connected"
#define STR_VERSION "Version"
#define STR_ACTIVE_INVERTERS "active Inv"
#define STR_TODAY "today"
Expand Down
6 changes: 3 additions & 3 deletions src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,15 +674,15 @@ class RestApi {
// find oldest alarm
uint8_t offset = 0;
uint32_t oldestStart = 0xffffffff;
for(uint8_t i = 0; i < hmInverter::MaxAlarmNum; i++) {
for(uint8_t i = 0; i < Inverter<>::MaxAlarmNum; i++) {
if((iv->lastAlarm[i].start != 0) && (iv->lastAlarm[i].start < oldestStart)) {
offset = i;
oldestStart = iv->lastAlarm[i].start;
}
}

for(uint8_t i = 0; i < hmInverter::MaxAlarmNum; i++) {
uint8_t pos = (i + offset) % hmInverter::MaxAlarmNum;
for(uint8_t i = 0; i < Inverter<>::MaxAlarmNum; i++) {
uint8_t pos = (i + offset) % Inverter<>::MaxAlarmNum;
alarm[pos][F("code")] = iv->lastAlarm[pos].code;
alarm[pos][F("str")] = iv->getAlarmStr(iv->lastAlarm[pos].code);
alarm[pos][F("start")] = iv->lastAlarm[pos].start;
Expand Down

0 comments on commit f90aacc

Please sign in to comment.