Merge with v24.11.7
This commit is contained in:
parent
df1d12d33a
commit
5452a82781
@ -82,6 +82,10 @@ private:
|
||||
String _i18n_current_power_w;
|
||||
String _i18n_yield_total_mwh;
|
||||
String _i18n_yield_total_kwh;
|
||||
String _i18n_powermeter_power_w;
|
||||
String _i18n_powermeter_power_kw;
|
||||
String _i18n_pm_positive_today_kwh;
|
||||
String _i18n_pm_negative_today_kwh;
|
||||
};
|
||||
|
||||
extern DisplayGraphicClass Display;
|
||||
|
||||
@ -23,7 +23,9 @@ public:
|
||||
String& offline,
|
||||
String& power_w, String& power_kw,
|
||||
String& yield_today_wh, String& yield_today_kwh,
|
||||
String& yield_total_kwh, String& yield_total_mwh);
|
||||
String& yield_total_kwh, String& yield_total_mwh,
|
||||
String& yield_powermeter_power_w, String& yield_powermeter_power_kw,
|
||||
String& yield_pm_positive_today_kwh, String& yield_pm_negative_today_kwh);
|
||||
|
||||
private:
|
||||
void readLangPacks();
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
*/
|
||||
#include "Display_Graphic.h"
|
||||
#include "Datastore.h"
|
||||
#include "JsyMk.h"
|
||||
#include "I18n.h"
|
||||
#include "JsyMk.h"
|
||||
#include <NetworkSettings.h>
|
||||
#include <map>
|
||||
#include <time.h>
|
||||
@ -185,6 +185,10 @@ void DisplayGraphicClass::setLocale(const String& locale)
|
||||
_i18n_yield_today_kwh = i18n_yield_today_kwh[idx];
|
||||
_i18n_yield_total_kwh = i18n_yield_total_kwh[idx];
|
||||
_i18n_yield_total_mwh = i18n_yield_total_mwh[idx];
|
||||
_i18n_powermeter_power_w = i18n_powermeter_power_w[idx];
|
||||
_i18n_powermeter_power_kw = i18n_powermeter_power_kw[idx];
|
||||
_i18n_pm_positive_today_kwh = i18n_pm_positive_today_kwh[idx];
|
||||
_i18n_pm_negative_today_kwh = i18n_pm_negative_today_kwh[idx];
|
||||
|
||||
I18n.readDisplayStrings(locale,
|
||||
_i18n_date_format,
|
||||
@ -194,7 +198,11 @@ void DisplayGraphicClass::setLocale(const String& locale)
|
||||
_i18n_yield_today_wh,
|
||||
_i18n_yield_today_kwh,
|
||||
_i18n_yield_total_kwh,
|
||||
_i18n_yield_total_mwh);
|
||||
_i18n_yield_total_mwh,
|
||||
_i18n_powermeter_power_w,
|
||||
_i18n_powermeter_power_kw,
|
||||
_i18n_pm_positive_today_kwh,
|
||||
_i18n_pm_negative_today_kwh);
|
||||
}
|
||||
|
||||
void DisplayGraphicClass::setDiagramMode(DiagramMode_t mode)
|
||||
@ -235,9 +243,11 @@ void DisplayGraphicClass::loop()
|
||||
const char direction = (JsyMk.getFieldValue(0, JsyMkClass::Field_t::NEGATIVE) > 0) ? 'O' : 'I';
|
||||
|
||||
if (watts > 999) {
|
||||
snprintf(_fmtText, sizeof(_fmtText), i18n_powermeter_power_kw[_display_language], direction, watts / 1000);
|
||||
// snprintf(_fmtText, sizeof(_fmtText), i18n_powermeter_power_kw[_display_language], direction, watts / 1000);
|
||||
snprintf(_fmtText, sizeof(_fmtText), _i18n_powermeter_power_kw.c_str(), direction, watts / 1000);
|
||||
} else {
|
||||
snprintf(_fmtText, sizeof(_fmtText), i18n_powermeter_power_w[_display_language], direction, watts);
|
||||
// snprintf(_fmtText, sizeof(_fmtText), i18n_powermeter_power_w[_display_language], direction, watts);
|
||||
snprintf(_fmtText, sizeof(_fmtText), _i18n_powermeter_power_w.c_str(), direction, watts);
|
||||
}
|
||||
printText(_fmtText, 0);
|
||||
}
|
||||
@ -288,28 +298,28 @@ void DisplayGraphicClass::loop()
|
||||
if (displayPowerMeter) {
|
||||
// Daily Input
|
||||
float wattsInput = JsyMk.getFieldValue(0, JsyMkClass::Field_t::TODAY_POSITIVE_ENERGY);
|
||||
snprintf(_fmtText, sizeof(_fmtText), i18n_pm_positive_today_kwh[_display_language], wattsInput);
|
||||
snprintf(_fmtText, sizeof(_fmtText), _i18n_pm_positive_today_kwh.c_str(), wattsInput);
|
||||
printText(_fmtText, 1);
|
||||
|
||||
// Daily Output
|
||||
float wattsOutput = JsyMk.getFieldValue(0, JsyMkClass::Field_t::TODAY_NEGATIVE_ENERGY);
|
||||
snprintf(_fmtText, sizeof(_fmtText), i18n_pm_negative_today_kwh[_display_language], wattsOutput);
|
||||
snprintf(_fmtText, sizeof(_fmtText), _i18n_pm_negative_today_kwh.c_str(), wattsOutput);
|
||||
printText(_fmtText, 2);
|
||||
} else {
|
||||
// Daily production
|
||||
float wattsToday = Datastore.getTotalAcYieldDayEnabled();
|
||||
if (wattsToday >= 10000) {
|
||||
snprintf(_fmtText, sizeof(_fmtText), _i18n_yield_today_kwh.c_str(), wattsToday / 1000);
|
||||
} else {
|
||||
snprintf(_fmtText, sizeof(_fmtText), _i18n_yield_today_wh.c_str(), wattsToday);
|
||||
}
|
||||
printText(_fmtText, 1);
|
||||
// Daily production
|
||||
float wattsToday = Datastore.getTotalAcYieldDayEnabled();
|
||||
if (wattsToday >= 10000) {
|
||||
snprintf(_fmtText, sizeof(_fmtText), _i18n_yield_today_kwh.c_str(), wattsToday / 1000);
|
||||
} else {
|
||||
snprintf(_fmtText, sizeof(_fmtText), _i18n_yield_today_wh.c_str(), wattsToday);
|
||||
}
|
||||
printText(_fmtText, 1);
|
||||
|
||||
// Total production
|
||||
const float wattsTotal = Datastore.getTotalAcYieldTotalEnabled();
|
||||
auto const format = (wattsTotal >= 1000) ? _i18n_yield_total_mwh : _i18n_yield_total_kwh;
|
||||
snprintf(_fmtText, sizeof(_fmtText), format.c_str(), wattsTotal);
|
||||
printText(_fmtText, 2);
|
||||
// Total production
|
||||
const float wattsTotal = Datastore.getTotalAcYieldTotalEnabled();
|
||||
auto const format = (wattsTotal >= 1000) ? _i18n_yield_total_mwh : _i18n_yield_total_kwh;
|
||||
snprintf(_fmtText, sizeof(_fmtText), format.c_str(), wattsTotal);
|
||||
printText(_fmtText, 2);
|
||||
}
|
||||
|
||||
//=====> IP or Date-Time ========
|
||||
|
||||
20
src/I18n.cpp
20
src/I18n.cpp
@ -44,7 +44,9 @@ void I18nClass::readDisplayStrings(
|
||||
String& offline,
|
||||
String& power_w, String& power_kw,
|
||||
String& yield_today_wh, String& yield_today_kwh,
|
||||
String& yield_total_kwh, String& yield_total_mwh)
|
||||
String& yield_total_kwh, String& yield_total_mwh,
|
||||
String& yield_powermeter_power_w, String& yield_powermeter_power_kw,
|
||||
String& yield_pm_positive_today_kwh, String& yield_pm_negative_today_kwh)
|
||||
{
|
||||
auto filename = getFilenameByLocale(locale);
|
||||
if (filename == "") {
|
||||
@ -104,6 +106,22 @@ void I18nClass::readDisplayStrings(
|
||||
yield_total_mwh = displayData["yield_total_mwh"].as<String>();
|
||||
}
|
||||
|
||||
if (displayData["yield_powermeter_power_w"].as<String>() != "null") {
|
||||
yield_powermeter_power_w = displayData["yield_powermeter_power_w"].as<String>();
|
||||
}
|
||||
|
||||
if (displayData["yield_powermeter_power_kw"].as<String>() != "null") {
|
||||
yield_powermeter_power_kw = displayData["yield_powermeter_power_kw"].as<String>();
|
||||
}
|
||||
|
||||
if (displayData["yield_pm_positive_today_kwh"].as<String>() != "null") {
|
||||
yield_pm_positive_today_kwh = displayData["yield_pm_positive_today_kwh"].as<String>();
|
||||
}
|
||||
|
||||
if (displayData["yield_pm_negative_today_kwh"].as<String>() != "null") {
|
||||
yield_pm_negative_today_kwh = displayData["yield_pm_negative_today_kwh"].as<String>();
|
||||
}
|
||||
|
||||
f.close();
|
||||
}
|
||||
|
||||
|
||||
@ -304,7 +304,7 @@ void MqttHandleHassClass::publishPowerMeterField(size_t channel, JsyMkClass::Fie
|
||||
serializeJson(root, buffer);
|
||||
publish(configTopic, buffer);
|
||||
} else {
|
||||
publish(configTopic, {});
|
||||
publish(configTopic, String {});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
13
src/main.cpp
13
src/main.cpp
@ -157,19 +157,6 @@ void setup()
|
||||
JsyMk.init(scheduler);
|
||||
MessageOutput.println("done");
|
||||
|
||||
// Check for default DTU serial
|
||||
MessageOutput.print("Check for default DTU serial... ");
|
||||
if (config.Dtu.Serial == DTU_SERIAL) {
|
||||
MessageOutput.print("generate serial based on ESP chip id: ");
|
||||
const uint64_t dtuId = Utils::generateDtuSerial();
|
||||
MessageOutput.printf("%0x%08x... ",
|
||||
((uint32_t)((dtuId >> 32) & 0xFFFFFFFF)),
|
||||
((uint32_t)(dtuId & 0xFFFFFFFF)));
|
||||
config.Dtu.Serial = dtuId;
|
||||
Configuration.write();
|
||||
}
|
||||
MessageOutput.println("done");
|
||||
|
||||
InverterSettings.init(scheduler);
|
||||
|
||||
Datastore.init(scheduler);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user