mirror of
https://github.com/lumapu/ahoy.git
synced 2025-08-06 09:58:23 +02:00
parent
e039820dba
commit
77b1f96c03
21 changed files with 290 additions and 273 deletions
|
@ -20,6 +20,7 @@ SPIClass hspi(HSPI);
|
|||
DisplayEPaper::DisplayEPaper() {
|
||||
mDisplayRotation = 2;
|
||||
mHeadFootPadding = 16;
|
||||
memset(_fmtText, 0, EPAPER_MAX_TEXT_LEN);
|
||||
}
|
||||
|
||||
|
||||
|
@ -114,9 +115,9 @@ void DisplayEPaper::headlineIP() {
|
|||
|
||||
do {
|
||||
if ((WiFi.isConnected() == true) && (WiFi.localIP() > 0)) {
|
||||
snprintf(_fmtText, sizeof(_fmtText), "%s", WiFi.localIP().toString().c_str());
|
||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "%s", WiFi.localIP().toString().c_str());
|
||||
} else {
|
||||
snprintf(_fmtText, sizeof(_fmtText), "WiFi not connected");
|
||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "WiFi not connected");
|
||||
}
|
||||
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||
uint16_t x = ((_display->width() - tbw) / 2) - tbx;
|
||||
|
@ -137,7 +138,7 @@ void DisplayEPaper::lastUpdatePaged() {
|
|||
_display->fillScreen(GxEPD_BLACK);
|
||||
do {
|
||||
if (NULL != mUtcTs) {
|
||||
snprintf(_fmtText, sizeof(_fmtText), ah::getDateTimeStr(gTimezone.toLocal(*mUtcTs)).c_str());
|
||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, ah::getDateTimeStr(gTimezone.toLocal(*mUtcTs)).c_str());
|
||||
|
||||
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||
uint16_t x = ((_display->width() - tbw) / 2) - tbx;
|
||||
|
@ -158,7 +159,7 @@ void DisplayEPaper::versionFooter() {
|
|||
_display->setPartialWindow(0, _display->height() - mHeadFootPadding, _display->width(), mHeadFootPadding);
|
||||
_display->fillScreen(GxEPD_BLACK);
|
||||
do {
|
||||
snprintf(_fmtText, sizeof(_fmtText), "Version: %s", _version);
|
||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "Version: %s", _version);
|
||||
|
||||
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||
uint16_t x = ((_display->width() - tbw) / 2) - tbx;
|
||||
|
@ -179,7 +180,7 @@ void DisplayEPaper::offlineFooter() {
|
|||
_display->fillScreen(GxEPD_BLACK);
|
||||
do {
|
||||
if (NULL != mUtcTs) {
|
||||
snprintf(_fmtText, sizeof(_fmtText), "offline");
|
||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "offline");
|
||||
|
||||
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||
uint16_t x = ((_display->width() - tbw) / 2) - tbx;
|
||||
|
@ -203,13 +204,13 @@ void DisplayEPaper::actualPowerPaged(float totalPower, float totalYieldDay, floa
|
|||
do {
|
||||
// actual Production
|
||||
if (totalPower > 9999) {
|
||||
snprintf(_fmtText, sizeof(_fmtText), "%.1f kW", (totalPower / 1000));
|
||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "%.1f kW", (totalPower / 1000));
|
||||
_changed = true;
|
||||
} else if ((totalPower > 0) && (totalPower <= 9999)) {
|
||||
snprintf(_fmtText, sizeof(_fmtText), "%.0f W", totalPower);
|
||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "%.0f W", totalPower);
|
||||
_changed = true;
|
||||
} else
|
||||
snprintf(_fmtText, sizeof(_fmtText), "offline");
|
||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "offline");
|
||||
|
||||
if ((totalPower == 0) && (mEnPowerSave)) {
|
||||
_display->fillRect(0, mHeadFootPadding, 200, 200, GxEPD_BLACK);
|
||||
|
@ -264,7 +265,7 @@ void DisplayEPaper::actualPowerPaged(float totalPower, float totalYieldDay, floa
|
|||
// Inverter online
|
||||
_display->setFont(&FreeSans12pt7b);
|
||||
y = _display->height() - (mHeadFootPadding + 10);
|
||||
snprintf(_fmtText, sizeof(_fmtText), " %d online", isprod);
|
||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, " %d online", isprod);
|
||||
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||
_display->drawInvertedBitmap(10, y - tbh, myWR, 20, 20, GxEPD_BLACK);
|
||||
x = ((_display->width() - tbw - 20) / 2) - tbx;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue