Browse Source

implement GE and FR

pull/1255/head
Wusaweki 2 years ago
committed by you69man
parent
commit
366d8be5e4
  1. 4
      src/plugins/Display/Display_Mono_128X64.h
  2. 4
      src/plugins/Display/Display_Mono_84X48.h
  3. 58
      src/utils/helper.cpp
  4. 6
      src/utils/helper.h

4
src/plugins/Display/Display_Mono_128X64.h

@ -70,12 +70,12 @@ class DisplayMono128X64 : public DisplayMono {
printText(mFmtText, l_TotalPower, 0xff);
} else {
printText("offline", l_TotalPower, 0xff);
printText("---", l_TotalPower, 0xff);
}
// print Date and time
if (0 != mDisplayData->utcTs)
printText(ah::getDateTimeStrShort(gTimezone.toLocal(mDisplayData->utcTs)).c_str(), l_Time, 0xff);
printText(ah::getDateTimeStrShort_i18n(gTimezone.toLocal(mDisplayData->utcTs), ah::LANG_GE).c_str(), l_Time, 0xff);
// dynamic status bar, alternatively:
// print ip address

4
src/plugins/Display/Display_Mono_84X48.h

@ -54,12 +54,12 @@ class DisplayMono84X48 : public DisplayMono {
printText(mFmtText, l_TotalPower, 0xff);
} else {
printText("offline", l_TotalPower, 0xff);
printText("---", l_TotalPower, 0xff);
}
// print Date and time
if (0 != mDisplayData->utcTs)
printText(ah::getDateTimeStrShort(gTimezone.toLocal(mDisplayData->utcTs)).c_str(), l_Time, 0xff);
printText(ah::getDateTimeStrShort_i18n(gTimezone.toLocal(mDisplayData->utcTs), ah::LANG_GE).c_str(), l_Time, 0xff);
// alternatively:
// print ip address

58
src/utils/helper.cpp

@ -61,6 +61,64 @@ namespace ah {
return String(str);
}
#define dt_SHORT_STR_LEN_i18n 3 // the length of short strings
static char buffer[dt_SHORT_STR_LEN_i18n + 1]; // must be big enough for longest string and the terminating null
const char monthShortNames_ge_P[] PROGMEM = "ErrJanFebMrzAprMaiJunJulAugSepOktNovDez";
const char dayShortNames_ge_P[] PROGMEM = "ErrSonMonDi.Mi.Do.Fr.Sam";
const char monthShortNames_fr_P[] PROGMEM = "ErrJanFevMarAvrMaiJunJulAouSepOctNovDec";
const char dayShortNames_fr_P[] PROGMEM = "ErrDimLunMarMerJeuVenSam";
char* monthShortStr_i18n(uint8_t month, enum lang language)
{
const char *monthShortNames_P;
switch (language) {
case LANG_EN:
return(monthShortStr(month));
case LANG_GE:
monthShortNames_P =monthShortNames_ge_P;
break;
case LANG_FR:
monthShortNames_P =monthShortNames_fr_P;
break;
}
for (int i=0; i < dt_SHORT_STR_LEN_i18n; i++)
buffer[i] = pgm_read_byte(&(monthShortNames_P[i + month * dt_SHORT_STR_LEN_i18n]));
buffer[dt_SHORT_STR_LEN_i18n] = 0;
return buffer;
}
char* dayShortStr_i18n(uint8_t day, enum lang language)
{
const char *dayShortNames_P;
switch (language) {
case LANG_EN:
return(dayShortStr(day));
case LANG_GE:
dayShortNames_P = dayShortNames_ge_P;
break;
case LANG_FR:
dayShortNames_P = dayShortNames_fr_P;
break;
}
for (int i=0; i < dt_SHORT_STR_LEN_i18n; i++)
buffer[i] = pgm_read_byte(&(dayShortNames_P[i + day * dt_SHORT_STR_LEN_i18n]));
buffer[dt_SHORT_STR_LEN_i18n] = 0;
return buffer;
}
String getDateTimeStrShort_i18n(time_t t, enum lang language) {
char str[20];
if(0 == t)
sprintf(str, "n/a");
else {
sprintf(str, "%3s ", dayShortStr_i18n(dayOfWeek(t), language));
sprintf(str+4, "%2d.%3s %02d:%02d", day(t), monthShortStr_i18n(month(t), language), hour(t), minute(t));
}
return String(str);
}
String getTimeStr(time_t t) {
char str[9];
if(0 == t)

6
src/utils/helper.h

@ -37,11 +37,17 @@ static Timezone gTimezone(CEST, CET);
} while (0)
namespace ah {
enum lang {
LANG_GE,
LANG_EN,
LANG_FR
};
void ip2Arr(uint8_t ip[], const char *ipStr);
void ip2Char(uint8_t ip[], char *str);
double round3(double value);
String getDateTimeStr(time_t t);
String getDateTimeStrShort(time_t t);
String getDateTimeStrShort_i18n(time_t t, enum lang);
String getDateTimeStrFile(time_t t);
String getTimeStr(time_t t);
String getTimeStrMs(time_t t);

Loading…
Cancel
Save