mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-01 10:11:37 +02:00
fix time for ePaper
This commit is contained in:
parent
6dbb88e27e
commit
c27c5e136b
3 changed files with 14 additions and 9 deletions
|
@ -32,7 +32,7 @@ class Display {
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
mRefreshCycle = 0;
|
mRefreshCycle = 0;
|
||||||
mEpaper.config(mCfg->rot);
|
mEpaper.config(mCfg->rot);
|
||||||
mEpaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion);
|
mEpaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mUtcTs, mVersion);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "../../utils/helper.h"
|
||||||
#include "imagedata.h"
|
#include "imagedata.h"
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
|
@ -22,7 +23,9 @@ 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, const char *version) {
|
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;
|
||||||
|
|
||||||
if (type > 9) {
|
if (type > 9) {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
_display = new GxEPD2_BW<GxEPD2_150_BN, GxEPD2_150_BN::HEIGHT>(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY));
|
_display = new GxEPD2_BW<GxEPD2_150_BN, GxEPD2_150_BN::HEIGHT>(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY));
|
||||||
|
@ -105,14 +108,15 @@ void DisplayEPaper::lastUpdatePaged() {
|
||||||
_display->setPartialWindow(0, _display->height() - mHeadFootPadding, _display->width(), mHeadFootPadding);
|
_display->setPartialWindow(0, _display->height() - mHeadFootPadding, _display->width(), mHeadFootPadding);
|
||||||
_display->fillScreen(GxEPD_BLACK);
|
_display->fillScreen(GxEPD_BLACK);
|
||||||
do {
|
do {
|
||||||
time_t now = time(nullptr);
|
if (NULL != mUtcTs) {
|
||||||
strftime(_fmtText, sizeof(_fmtText), "%d.%m.%Y %H:%M", localtime(&now));
|
snprintf(_fmtText, sizeof(_fmtText), ah::getDateTimeStr(gTimezone.toLocal(*mUtcTs)).c_str());
|
||||||
|
|
||||||
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||||
uint16_t x = ((_display->width() - tbw) / 2) - tbx;
|
uint16_t x = ((_display->width() - tbw) / 2) - tbx;
|
||||||
|
|
||||||
_display->setCursor(x, (_display->height() - 3));
|
_display->setCursor(x, (_display->height() - 3));
|
||||||
_display->println(_fmtText);
|
_display->println(_fmtText);
|
||||||
|
}
|
||||||
} while (_display->nextPage());
|
} while (_display->nextPage());
|
||||||
}
|
}
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
|
@ -30,7 +30,7 @@ class DisplayEPaper {
|
||||||
public:
|
public:
|
||||||
DisplayEPaper();
|
DisplayEPaper();
|
||||||
void fullRefresh();
|
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, const char* version);
|
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);
|
void config(uint8_t rotation);
|
||||||
void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod);
|
void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod);
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ class DisplayEPaper {
|
||||||
const char* _settedIP;
|
const char* _settedIP;
|
||||||
uint8_t mHeadFootPadding;
|
uint8_t mHeadFootPadding;
|
||||||
GxEPD2_GFX* _display;
|
GxEPD2_GFX* _display;
|
||||||
|
uint32_t *mUtcTs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue