mirror of
https://github.com/lumapu/ahoy.git
synced 2025-04-29 18:26:21 +02:00
parent
19693d0e9c
commit
c1a9860daa
10 changed files with 97 additions and 19 deletions
|
@ -3,6 +3,7 @@
|
||||||
## 0.8.92 - 2024-03-10
|
## 0.8.92 - 2024-03-10
|
||||||
* fix read back of limit value, now with one decimal place
|
* fix read back of limit value, now with one decimal place
|
||||||
* added grid profile for Mexico #1493
|
* added grid profile for Mexico #1493
|
||||||
|
* added language to display on compile time #1484, #1255, #1479
|
||||||
|
|
||||||
## 0.8.91 - 2024-03-05
|
## 0.8.91 - 2024-03-05
|
||||||
* fix javascript issues #1480
|
* fix javascript issues #1480
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "../../hm/hmSystem.h"
|
#include "../../hm/hmSystem.h"
|
||||||
#include "../../hm/hmRadio.h"
|
#include "../../hm/hmRadio.h"
|
||||||
#include "../../utils/helper.h"
|
#include "../../utils/helper.h"
|
||||||
|
#include "../plugin_lang.h"
|
||||||
#include "Display_Mono.h"
|
#include "Display_Mono.h"
|
||||||
#include "Display_Mono_128X32.h"
|
#include "Display_Mono_128X32.h"
|
||||||
#include "Display_Mono_128X64.h"
|
#include "Display_Mono_128X64.h"
|
||||||
|
|
|
@ -40,20 +40,20 @@ class DisplayMono128X32 : public DisplayMono {
|
||||||
|
|
||||||
printText(mFmtText, 0);
|
printText(mFmtText, 0);
|
||||||
} else {
|
} else {
|
||||||
printText("offline", 0);
|
printText(STR_OFFLINE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "today: %4.0f Wh", mDisplayData->totalYieldDay);
|
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "%s: %4.0f Wh", STR_TODAY, mDisplayData->totalYieldDay);
|
||||||
printText(mFmtText, 1);
|
printText(mFmtText, 1);
|
||||||
|
|
||||||
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "total: %.1f kWh", mDisplayData->totalYieldTotal);
|
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "%s: %.1f kWh", STR_TOTAL, mDisplayData->totalYieldTotal);
|
||||||
printText(mFmtText, 2);
|
printText(mFmtText, 2);
|
||||||
|
|
||||||
IPAddress ip = WiFi.localIP();
|
IPAddress ip = WiFi.localIP();
|
||||||
if (!(mExtra % 10) && (ip))
|
if (!(mExtra % 10) && (ip))
|
||||||
printText(ip.toString().c_str(), 3);
|
printText(ip.toString().c_str(), 3);
|
||||||
else if (!(mExtra % 5)) {
|
else if (!(mExtra % 5)) {
|
||||||
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "%d Inverter on", mDisplayData->nrProducing);
|
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "%s: %d", STR_ACTIVE_INVERTERS, mDisplayData->nrProducing);
|
||||||
printText(mFmtText, 3);
|
printText(mFmtText, 3);
|
||||||
} else if (0 != mDisplayData->utcTs)
|
} else if (0 != mDisplayData->utcTs)
|
||||||
printText(ah::getTimeStr(mDisplayData->utcTs).c_str(), 3);
|
printText(ah::getTimeStr(mDisplayData->utcTs).c_str(), 3);
|
||||||
|
|
|
@ -93,7 +93,7 @@ class DisplayMono128X64 : public DisplayMono {
|
||||||
|
|
||||||
// print Date and time
|
// print Date and time
|
||||||
if (0 != mDisplayData->utcTs)
|
if (0 != mDisplayData->utcTs)
|
||||||
printText(ah::getDateTimeStrShort(mDisplayData->utcTs).c_str(), l_Time, 0xff);
|
printText(ah::getDateTimeStrShort_i18n(mDisplayData->utcTs).c_str(), l_Time, 0xff);
|
||||||
|
|
||||||
if (showLine(l_Status)) {
|
if (showLine(l_Status)) {
|
||||||
// alternatively:
|
// alternatively:
|
||||||
|
@ -108,7 +108,7 @@ class DisplayMono128X64 : public DisplayMono {
|
||||||
int8_t moon_pos = -1;
|
int8_t moon_pos = -1;
|
||||||
setLineFont(l_Status);
|
setLineFont(l_Status);
|
||||||
if (0 == mDisplayData->nrSleeping + mDisplayData->nrProducing)
|
if (0 == mDisplayData->nrSleeping + mDisplayData->nrProducing)
|
||||||
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "no inverter");
|
snprintf(mFmtText, DISP_FMT_TEXT_LEN, STR_NO_INVERTER);
|
||||||
else if (0 == mDisplayData->nrSleeping) {
|
else if (0 == mDisplayData->nrSleeping) {
|
||||||
snprintf(mFmtText, DISP_FMT_TEXT_LEN, " ");
|
snprintf(mFmtText, DISP_FMT_TEXT_LEN, " ");
|
||||||
sun_pos = 0;
|
sun_pos = 0;
|
||||||
|
@ -145,7 +145,7 @@ class DisplayMono128X64 : public DisplayMono {
|
||||||
|
|
||||||
printText(mFmtText, l_TotalPower, 0xff);
|
printText(mFmtText, l_TotalPower, 0xff);
|
||||||
} else {
|
} else {
|
||||||
printText("offline", l_TotalPower, 0xff);
|
printText(STR_OFFLINE, l_TotalPower, 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class DisplayMono64X48 : public DisplayMono {
|
||||||
|
|
||||||
printText(mFmtText, 0);
|
printText(mFmtText, 0);
|
||||||
} else {
|
} else {
|
||||||
printText("offline", 0);
|
printText(STR_OFFLINE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "D: %4.0f Wh", mDisplayData->totalYieldDay);
|
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "D: %4.0f Wh", mDisplayData->totalYieldDay);
|
||||||
|
@ -55,7 +55,7 @@ class DisplayMono64X48 : public DisplayMono {
|
||||||
if (!(mExtra % 10) && (ip))
|
if (!(mExtra % 10) && (ip))
|
||||||
printText(ip.toString().c_str(), 3);
|
printText(ip.toString().c_str(), 3);
|
||||||
else if (!(mExtra % 5)) {
|
else if (!(mExtra % 5)) {
|
||||||
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "active Inv: %d", mDisplayData->nrProducing);
|
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "%s: %d", STR_ACTIVE_INVERTERS, mDisplayData->nrProducing);
|
||||||
printText(mFmtText, 3);
|
printText(mFmtText, 3);
|
||||||
} else if (0 != mDisplayData->utcTs)
|
} else if (0 != mDisplayData->utcTs)
|
||||||
printText(ah::getTimeStr(mDisplayData->utcTs).c_str(), 3);
|
printText(ah::getTimeStr(mDisplayData->utcTs).c_str(), 3);
|
||||||
|
|
|
@ -78,7 +78,7 @@ class DisplayMono84X48 : public DisplayMono {
|
||||||
|
|
||||||
// print Date and time
|
// print Date and time
|
||||||
if (0 != mDisplayData->utcTs)
|
if (0 != mDisplayData->utcTs)
|
||||||
printText(ah::getDateTimeStrShort(mDisplayData->utcTs).c_str(), l_Time, 0xff);
|
printText(ah::getDateTimeStrShort_i18n(mDisplayData->utcTs).c_str(), l_Time, 0xff);
|
||||||
|
|
||||||
if (showLine(l_Status)) {
|
if (showLine(l_Status)) {
|
||||||
// alternatively:
|
// alternatively:
|
||||||
|
@ -90,7 +90,7 @@ class DisplayMono84X48 : public DisplayMono {
|
||||||
// print status of inverters
|
// print status of inverters
|
||||||
else {
|
else {
|
||||||
if (0 == mDisplayData->nrSleeping + mDisplayData->nrProducing)
|
if (0 == mDisplayData->nrSleeping + mDisplayData->nrProducing)
|
||||||
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "no inverter");
|
snprintf(mFmtText, DISP_FMT_TEXT_LEN, STR_NO_INVERTER);
|
||||||
else if (0 == mDisplayData->nrSleeping)
|
else if (0 == mDisplayData->nrSleeping)
|
||||||
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "\x86"); // sun symbol
|
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "\x86"); // sun symbol
|
||||||
else if (0 == mDisplayData->nrProducing)
|
else if (0 == mDisplayData->nrProducing)
|
||||||
|
@ -110,9 +110,8 @@ class DisplayMono84X48 : public DisplayMono {
|
||||||
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "%.0f W", mDisplayData->totalPower);
|
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "%.0f W", mDisplayData->totalPower);
|
||||||
|
|
||||||
printText(mFmtText, l_TotalPower, 0xff);
|
printText(mFmtText, l_TotalPower, 0xff);
|
||||||
} else {
|
} else
|
||||||
printText("offline", l_TotalPower, 0xff);
|
printText(STR_OFFLINE, l_TotalPower, 0xff);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showLine(l_YieldDay)) {
|
if (showLine(l_YieldDay)) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "../../utils/helper.h"
|
#include "../../utils/helper.h"
|
||||||
#include "imagedata.h"
|
#include "imagedata.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
#include "../plugin_lang.h"
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
|
|
||||||
|
@ -120,7 +121,7 @@ void DisplayEPaper::headlineIP() {
|
||||||
if ((WiFi.isConnected() == true) && (WiFi.localIP() > 0)) {
|
if ((WiFi.isConnected() == true) && (WiFi.localIP() > 0)) {
|
||||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "%s", WiFi.localIP().toString().c_str());
|
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "%s", WiFi.localIP().toString().c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "WiFi not connected");
|
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, STR_NO_WIFI);
|
||||||
}
|
}
|
||||||
_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;
|
||||||
|
@ -162,7 +163,7 @@ void DisplayEPaper::versionFooter() {
|
||||||
_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 {
|
||||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "Version: %s", _version);
|
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "%s: %s", STR_VERSION, _version);
|
||||||
|
|
||||||
_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;
|
||||||
|
@ -183,7 +184,7 @@ void DisplayEPaper::offlineFooter() {
|
||||||
_display->fillScreen(GxEPD_BLACK);
|
_display->fillScreen(GxEPD_BLACK);
|
||||||
do {
|
do {
|
||||||
if (NULL != mUtcTs) {
|
if (NULL != mUtcTs) {
|
||||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "offline");
|
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, STR_OFFLINE);
|
||||||
|
|
||||||
_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;
|
||||||
|
@ -213,7 +214,7 @@ void DisplayEPaper::actualPowerPaged(float totalPower, float totalYieldDay, floa
|
||||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "%.0f W", totalPower);
|
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "%.0f W", totalPower);
|
||||||
_changed = true;
|
_changed = true;
|
||||||
} else
|
} else
|
||||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, "offline");
|
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, STR_OFFLINE);
|
||||||
|
|
||||||
if ((totalPower == 0) && (mEnPowerSave)) {
|
if ((totalPower == 0) && (mEnPowerSave)) {
|
||||||
_display->fillRect(0, mHeadFootPadding, 200, 200, GxEPD_BLACK);
|
_display->fillRect(0, mHeadFootPadding, 200, 200, GxEPD_BLACK);
|
||||||
|
@ -268,7 +269,7 @@ void DisplayEPaper::actualPowerPaged(float totalPower, float totalYieldDay, floa
|
||||||
// Inverter online
|
// Inverter online
|
||||||
_display->setFont(&FreeSans12pt7b);
|
_display->setFont(&FreeSans12pt7b);
|
||||||
y = _display->height() - (mHeadFootPadding + 10);
|
y = _display->height() - (mHeadFootPadding + 10);
|
||||||
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, " %d online", isprod);
|
snprintf(_fmtText, EPAPER_MAX_TEXT_LEN, " %d %s", isprod, STR_ONLINE);
|
||||||
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||||
_display->drawInvertedBitmap(10, y - tbh, myWR, 20, 20, GxEPD_BLACK);
|
_display->drawInvertedBitmap(10, y - tbh, myWR, 20, 20, GxEPD_BLACK);
|
||||||
x = ((_display->width() - tbw - 20) / 2) - tbx;
|
x = ((_display->width() - tbw - 20) / 2) - tbx;
|
||||||
|
|
44
src/plugins/plugin_lang.h
Normal file
44
src/plugins/plugin_lang.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// 2024 Ahoy, https://ahoydtu.de
|
||||||
|
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/4.0/deed
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef __PLUGIN_LANG_H__
|
||||||
|
#define __PLUGIN_LANG_H__
|
||||||
|
|
||||||
|
#ifdef LANG_DE
|
||||||
|
#define STR_MONTHNAME_3_CHAR_LIST "ErrJanFebMrzAprMaiJunJulAugSepOktNovDez"
|
||||||
|
#define STR_DAYNAME_3_CHAR_LIST "ErrSonMonDieMitDonFreSam"
|
||||||
|
#define STR_OFFLINE "aus"
|
||||||
|
#define STR_ONLINE "aktiv"
|
||||||
|
#define STR_NO_INVERTER "kein inverter"
|
||||||
|
#define STR_NO_WIFI "WLAN nicht verbunden"
|
||||||
|
#define STR_VERSION "Version"
|
||||||
|
#define STR_ACTIVE_INVERTERS "aktive WR"
|
||||||
|
#define STR_TODAY "heute"
|
||||||
|
#define STR_TODAY "Gesamt"
|
||||||
|
#elif LANG_FR
|
||||||
|
#define STR_MONTHNAME_3_CHAR_LIST "ErrJanFevMarAvrMaiJunJulAouSepOctNovDec"
|
||||||
|
#define STR_DAYNAME_3_CHAR_LIST "ErrDimLunMarMerJeuVenSam"
|
||||||
|
#define STR_OFFLINE "eteint"
|
||||||
|
#define STR_ONLINE "online"
|
||||||
|
#define STR_NO_INVERTER "pas d'onduleur"
|
||||||
|
#define STR_NO_WIFI "WiFi not connected"
|
||||||
|
#define STR_VERSION "Version"
|
||||||
|
#define STR_ACTIVE_INVERTERS "active Inv"
|
||||||
|
#define STR_TODAY "today"
|
||||||
|
#define STR_TODAY "total"
|
||||||
|
#else
|
||||||
|
#define STR_MONTHNAME_3_CHAR_LIST "ErrJanFebMarAprMayJunJulAugSepOctNovDec"
|
||||||
|
#define STR_DAYNAME_3_CHAR_LIST "ErrSunMonTueWedThuFriSat"
|
||||||
|
#define STR_OFFLINE "offline"
|
||||||
|
#define STR_ONLINE "online"
|
||||||
|
#define STR_NO_INVERTER "no inverter"
|
||||||
|
#define STR_NO_WIFI "WiFi not connected"
|
||||||
|
#define STR_VERSION "Version"
|
||||||
|
#define STR_ACTIVE_INVERTERS "active Inv"
|
||||||
|
#define STR_TODAY "today"
|
||||||
|
#define STR_TODAY "total"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*__PLUGIN_LANG_H__*/
|
|
@ -5,6 +5,12 @@
|
||||||
|
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
|
#include "../plugins/plugin_lang.h"
|
||||||
|
|
||||||
|
#define dt_SHORT_STR_LEN_i18n 3 // the length of short strings
|
||||||
|
static char buffer_i18n[dt_SHORT_STR_LEN_i18n + 1]; // must be big enough for longest string and the terminating null
|
||||||
|
const char monthShortNames_P[] PROGMEM = STR_MONTHNAME_3_CHAR_LIST;
|
||||||
|
const char dayShortNames_P[] PROGMEM = STR_DAYNAME_3_CHAR_LIST;
|
||||||
|
|
||||||
namespace ah {
|
namespace ah {
|
||||||
void ip2Arr(uint8_t ip[], const char *ipStr) {
|
void ip2Arr(uint8_t ip[], const char *ipStr) {
|
||||||
|
@ -86,6 +92,31 @@ namespace ah {
|
||||||
return String(str);
|
return String(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char* monthShortStr_i18n(uint8_t month) {
|
||||||
|
for (int i=0; i < dt_SHORT_STR_LEN_i18n; i++)
|
||||||
|
buffer_i18n[i] = pgm_read_byte(&(monthShortNames_P[i + month * dt_SHORT_STR_LEN_i18n]));
|
||||||
|
buffer_i18n[dt_SHORT_STR_LEN_i18n] = 0;
|
||||||
|
return buffer_i18n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char* dayShortStr_i18n(uint8_t day) {
|
||||||
|
for (int i=0; i < dt_SHORT_STR_LEN_i18n; i++)
|
||||||
|
buffer_i18n[i] = pgm_read_byte(&(dayShortNames_P[i + day * dt_SHORT_STR_LEN_i18n]));
|
||||||
|
buffer_i18n[dt_SHORT_STR_LEN_i18n] = 0;
|
||||||
|
return buffer_i18n;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getDateTimeStrShort_i18n(time_t t) {
|
||||||
|
char str[20];
|
||||||
|
if(0 == t)
|
||||||
|
sprintf(str, "n/a");
|
||||||
|
else {
|
||||||
|
sprintf(str, "%3s ", dayShortStr_i18n(dayOfWeek(t)));
|
||||||
|
sprintf(str+4, "%2d.%3s %02d:%02d", day(t), monthShortStr_i18n(month(t)), hour(t), minute(t));
|
||||||
|
}
|
||||||
|
return String(str);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t Serial2u64(const char *val) {
|
uint64_t Serial2u64(const char *val) {
|
||||||
char tmp[3];
|
char tmp[3];
|
||||||
uint64_t ret = 0ULL;
|
uint64_t ret = 0ULL;
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace ah {
|
||||||
double round3(double value);
|
double round3(double value);
|
||||||
String getDateTimeStr(time_t t);
|
String getDateTimeStr(time_t t);
|
||||||
String getDateTimeStrShort(time_t t);
|
String getDateTimeStrShort(time_t t);
|
||||||
|
String getDateTimeStrShort_i18n(time_t t);
|
||||||
String getDateTimeStrFile(time_t t);
|
String getDateTimeStrFile(time_t t);
|
||||||
String getTimeStr(time_t t);
|
String getTimeStr(time_t t);
|
||||||
String getTimeStrMs(uint64_t t);
|
String getTimeStrMs(uint64_t t);
|
||||||
|
|
Loading…
Add table
Reference in a new issue