mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
Add configurable cell/module/etc settings for Pylonish/Solax inverters to use
This commit is contained in:
parent
9816417b21
commit
2f1ff9950c
5 changed files with 112 additions and 1 deletions
|
@ -96,6 +96,13 @@ void init_stored_settings() {
|
|||
user_selected_min_pack_voltage_dV = settings.getUInt("BATTPVMIN", 0);
|
||||
user_selected_max_cell_voltage_mV = settings.getUInt("BATTCVMAX", 0);
|
||||
user_selected_min_cell_voltage_mV = settings.getUInt("BATTCVMIN", 0);
|
||||
user_selected_inverter_cells = settings.getUInt("INVCELLS", 0);
|
||||
user_selected_inverter_modules = settings.getUInt("INVMODULES", 0);
|
||||
user_selected_inverter_cells_per_module = settings.getUInt("INVCELLSPER", 0);
|
||||
user_selected_inverter_voltage_level = settings.getUInt("INVVLEVEL", 0);
|
||||
user_selected_inverter_ah_capacity = settings.getUInt("INVAHCAPACITY", 0);
|
||||
user_selected_inverter_battery_type = settings.getUInt("INVBTYPE", 0);
|
||||
user_selected_inverter_ignore_contactors = settings.getBool("INVICNT", false);
|
||||
|
||||
auto readIf = [](const char* settingName) {
|
||||
auto batt1If = (comm_interface)settings.getUInt(settingName, (int)comm_interface::CanNative);
|
||||
|
|
|
@ -472,6 +472,34 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
|
|||
return String(settings.getUInt("SOFAR_ID", 0));
|
||||
}
|
||||
|
||||
if (var == "INVCELLS") {
|
||||
return String(settings.getUInt("INVCELLS", 0));
|
||||
}
|
||||
|
||||
if (var == "INVMODULES") {
|
||||
return String(settings.getUInt("INVMODULES", 0));
|
||||
}
|
||||
|
||||
if (var == "INVCELLSPER") {
|
||||
return String(settings.getUInt("INVCELLSPER", 0));
|
||||
}
|
||||
|
||||
if (var == "INVVLEVEL") {
|
||||
return String(settings.getUInt("INVVLEVEL", 0));
|
||||
}
|
||||
|
||||
if (var == "INVCAPACITY") {
|
||||
return String(settings.getUInt("INVCAPACITY", 0));
|
||||
}
|
||||
|
||||
if (var == "INVBTYPE") {
|
||||
return String(settings.getUInt("INVBTYPE", 0));
|
||||
}
|
||||
|
||||
if (var == "INVICNT") {
|
||||
return settings.getBool("INVICNT") ? "checked" : "";
|
||||
}
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
|
@ -668,6 +696,16 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
|||
display: contents;
|
||||
}
|
||||
|
||||
form .if-pylonish { display: none; }
|
||||
form[data-inverter="4"] .if-pylonish, form[data-inverter="10"] .if-pylonish, form[data-inverter="19"] .if-pylonish {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
form .if-solax { display: none; }
|
||||
form[data-inverter="18"] .if-solax {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
form .if-mqtt { display: none; }
|
||||
form[data-mqttenabled="true"] .if-mqtt {
|
||||
display: contents;
|
||||
|
@ -736,6 +774,35 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
|||
<input name='SOFAR_ID' type='text' value="%SOFAR_ID%" pattern="^[0-9]{1,2}$" />
|
||||
</div>
|
||||
|
||||
<div class="if-pylonish">
|
||||
<label>Reported cell count (0 for default): </label>
|
||||
<input name='INVCELLS' type='text' value="%INVCELLS%" pattern="^[0-9]+$" />
|
||||
</div>
|
||||
|
||||
<div class="if-pylonish if-solax">
|
||||
<label>Reported module count (0 for default): </label>
|
||||
<input name='INVMODULES' type='text' value="%INVMODULES%" pattern="^[0-9]+$" />
|
||||
</div>
|
||||
|
||||
<div class="if-pylonish">
|
||||
<label>Reported cells per module (0 for default): </label>
|
||||
<input name='INVCELLSPER' type='text' value="%INVCELLSPER%" pattern="^[0-9]+$" />
|
||||
|
||||
<label>Reported voltage level (0 for default): </label>
|
||||
<input name='INVVLEVEL' type='text' value="%INVVLEVEL%" pattern="^[0-9]+$" />
|
||||
|
||||
<label>Reported Ah capacity (0 for default): </label>
|
||||
<input name='INVCAPACITY' type='text' value="%INVCAPACITY%" pattern="^[0-9]+$" />
|
||||
</div>
|
||||
|
||||
<div class="if-solax">
|
||||
<label>Reported battery type (in decimal): </label>
|
||||
<input name='INVBTYPE' type='text' value="%INVBTYPE%" pattern="^[0-9]+$" />
|
||||
|
||||
<label>Inverter should ignore contactors: </label>
|
||||
<input type='checkbox' name='INVICNT' value='on' style='margin-left: 0;' %INVICNT% />
|
||||
</div>
|
||||
|
||||
<label>Charger: </label><select name='charger'>
|
||||
%CHGTYPE%
|
||||
</select>
|
||||
|
|
|
@ -414,7 +414,7 @@ void init_webserver() {
|
|||
|
||||
const char* boolSettingNames[] = {
|
||||
"DBLBTR", "CNTCTRL", "CNTCTRLDBL", "PWMCNTCTRL", "PERBMSRESET", "REMBMSRESET",
|
||||
"CANFDASCAN", "WIFIAPENABLED", "MQTTENABLED", "HADISC", "MQTTTOPICS",
|
||||
"CANFDASCAN", "WIFIAPENABLED", "MQTTENABLED", "HADISC", "MQTTTOPICS", "INVICNT",
|
||||
};
|
||||
|
||||
// Handles the form POST from UI to save settings of the common image
|
||||
|
@ -497,6 +497,24 @@ void init_webserver() {
|
|||
} else if (p->name() == "SOFAR_ID") {
|
||||
auto type = atoi(p->value().c_str());
|
||||
settings.saveUInt("SOFAR_ID", type);
|
||||
} else if (p->name() == "INVCELLS") {
|
||||
auto type = atoi(p->value().c_str());
|
||||
settings.saveUInt("INVCELLS", type);
|
||||
} else if (p->name() == "INVMODULES") {
|
||||
auto type = atoi(p->value().c_str());
|
||||
settings.saveUInt("INVMODULES", type);
|
||||
} else if (p->name() == "INVCELLSPER") {
|
||||
auto type = atoi(p->value().c_str());
|
||||
settings.saveUInt("INVCELLSPER", type);
|
||||
} else if (p->name() == "INVVLEVEL") {
|
||||
auto type = atoi(p->value().c_str());
|
||||
settings.saveUInt("INVVLEVEL", type);
|
||||
} else if (p->name() == "INVCAPACITY") {
|
||||
auto type = atoi(p->value().c_str());
|
||||
settings.saveUInt("INVCAPACITY", type);
|
||||
} else if (p->name() == "INVBTYPE") {
|
||||
auto type = atoi(p->value().c_str());
|
||||
settings.saveUInt("INVBTYPE", (int)type);
|
||||
}
|
||||
|
||||
for (auto& boolSetting : boolSettings) {
|
||||
|
|
|
@ -90,6 +90,15 @@ extern const char* name_for_inverter_type(InverterProtocolType type) {
|
|||
#error "Compile time SELECTED_INVERTER_CLASS should not be defined with COMMON_IMAGE"
|
||||
#endif
|
||||
|
||||
// Some settings that can be used by inverters
|
||||
uint16_t user_selected_inverter_cells = 0;
|
||||
uint16_t user_selected_inverter_modules = 0;
|
||||
uint16_t user_selected_inverter_cells_per_module = 0;
|
||||
uint16_t user_selected_inverter_voltage_level = 0;
|
||||
uint16_t user_selected_inverter_ah_capacity = 0;
|
||||
uint16_t user_selected_inverter_battery_type = 0;
|
||||
bool user_selected_inverter_ignore_contactors = false;
|
||||
|
||||
bool setup_inverter() {
|
||||
if (inverter) {
|
||||
return true;
|
||||
|
|
|
@ -36,4 +36,14 @@ extern InverterProtocol* inverter;
|
|||
// Call to initialize the build-time selected inverter. Safe to call even though inverter was not selected.
|
||||
bool setup_inverter();
|
||||
|
||||
#ifdef COMMON_IMAGE
|
||||
extern uint16_t user_selected_inverter_cells;
|
||||
extern uint16_t user_selected_inverter_modules;
|
||||
extern uint16_t user_selected_inverter_cells_per_module;
|
||||
extern uint16_t user_selected_inverter_voltage_level;
|
||||
extern uint16_t user_selected_inverter_ah_capacity;
|
||||
extern uint16_t user_selected_inverter_battery_type;
|
||||
extern bool user_selected_inverter_ignore_contactors;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue