#include "settings_html.h" #include #include "../../../src/communication/contactorcontrol/comm_contactorcontrol.h" #include "../../charger/CHARGERS.h" #include "../../communication/nvm/comm_nvm.h" #include "../../datalayer/datalayer.h" #include "../../include.h" extern bool settingsUpdated; #ifdef COMMON_IMAGE String battery_options(BatteryType selected) { String options; auto batteries = supported_battery_types(); for (BatteryType type : batteries) { auto name = name_for_type(type); if (name != nullptr) { options += (""; } } return options; } String inverter_options(InverterProtocolType selected) { String options; auto inverters = supported_inverter_protocols(); for (InverterProtocolType type : inverters) { auto name = name_for_type(type); if (name != nullptr) { options += (""; } } return options; } String charger_options(ChargerType selected) { String options; auto chargers = supported_charger_types(); for (ChargerType type : chargers) { auto name = name_for_type(type); if (name != nullptr) { options += (""; } } return options; } #endif void render_checkbox(String& content, const char* label, bool enabled, const char* name) { content += ""; content += " "; content += "

Password: ########

"; #ifdef COMMON_IMAGE BatteryEmulatorSettingsStore settings; // It's important that we read/write settings directly to settings store instead of the run-time values // since the run-time values may have direct effect on operation. content += "
"; content += "
"; content += ""; content += ""; content += ""; // TODO: Generalize settings: define settings in one place and use the definitions to render // UI and handle load/save render_checkbox(content, "Double battery", settings.getBool("DBLBTR"), "dblbtr"); render_checkbox(content, "Contactor control", settings.getBool("CNTCTRL"), "contctrl"); render_checkbox(content, "Contactor control double battery", settings.getBool("CNTCTRLDBL"), "contctrldbl"); render_checkbox(content, "PWM contactor control", settings.getBool("PWMCNTCTRL"), "pwmcontctrl"); render_checkbox(content, "Periodic BMS reset", settings.getBool("PERBMSRESET"), "PERBMSRESET"); render_checkbox(content, "Remote BMS reset", settings.getBool("REMBMSRESET"), "REMBMSRESET"); content += "
"; if (settingsUpdated) { content += "

Settings saved. Reboot to take the settings into use.

"; } content += "
"; #endif if (battery) { content += "

Battery interface: " + battery->interface_name() + "

"; } if (battery2) { content += "

Battery #2 interface: " + battery2->interface_name() + "

"; } if (inverter) { content += "

Inverter interface: " + String(inverter->interface_name()) + "

"; } if (shunt) { content += "

Shunt Interface: " + shunt->interface_name() + "

"; } // Close the block content += ""; // Start a new block with a specific background color content += "
"; // Show current settings with edit buttons and input fields content += "

Battery capacity: " + String(datalayer.battery.info.total_capacity_Wh) + " Wh

"; content += "

Rescale SOC: " + String(datalayer.battery.settings.soc_scaling_active ? "" : "") + "

"; content += "

SOC max percentage: " + String(datalayer.battery.settings.max_percentage / 100.0, 1) + "

"; content += "

SOC min percentage: " + String(datalayer.battery.settings.min_percentage / 100.0, 1) + "

"; content += "

Max charge speed: " + String(datalayer.battery.settings.max_user_set_charge_dA / 10.0, 1) + " A

"; content += "

Max discharge speed: " + String(datalayer.battery.settings.max_user_set_discharge_dA / 10.0, 1) + " A

"; content += "

Manual charge voltage limits: " + String(datalayer.battery.settings.user_set_voltage_limits_active ? "" : "") + "

"; content += "

Target charge voltage: " + String(datalayer.battery.settings.max_user_set_charge_voltage_dV / 10.0, 1) + " V

"; content += "

Target discharge voltage: " + String(datalayer.battery.settings.max_user_set_discharge_voltage_dV / 10.0, 1) + " V

"; // Close the block content += "
"; if (battery && battery->supports_set_fake_voltage()) { content += "
"; content += "

Fake battery voltage: " + String(battery->get_voltage(), 1) + " V

"; content += "
"; } if (battery && battery->supports_manual_balancing()) { // Start a new block with grey background color content += "
"; content += "

Manual LFP balancing: " + String(datalayer.battery.settings.user_requests_balancing ? "" : "") + "

"; content += "

Balancing max time: " + String(datalayer.battery.settings.balancing_time_ms / 60000.0, 1) + " Minutes

"; content += "

Balancing float power: " + String(datalayer.battery.settings.balancing_float_power_W / 1.0, 0) + " W

"; content += "

Max battery voltage: " + String(datalayer.battery.settings.balancing_max_pack_voltage_dV / 10.0, 0) + " V

"; content += "

Max cell voltage: " + String(datalayer.battery.settings.balancing_max_cell_voltage_mV / 1.0, 0) + " mV

"; content += "

Max cell voltage deviation: " + String(datalayer.battery.settings.balancing_max_deviation_cell_voltage_mV / 1.0, 0) + " mV

"; // Close the block content += "
"; } if (charger) { // Start a new block with orange background color content += "
"; content += "

Charger HVDC Enabled: "; if (datalayer.charger.charger_HV_enabled) { content += ""; } else { content += ""; } content += "

"; content += "

Charger Aux12VDC Enabled: "; if (datalayer.charger.charger_aux12V_enabled) { content += ""; } else { content += ""; } content += "

"; content += "

Charger Voltage Setpoint: " + String(datalayer.charger.charger_setpoint_HV_VDC, 1) + " V

"; content += "

Charger Current Setpoint: " + String(datalayer.charger.charger_setpoint_HV_IDC, 1) + " A

"; // Close the block content += "
"; } content += ""; content += ""; return content; } return String(); } const char* getCANInterfaceName(CAN_Interface interface) { switch (interface) { case CAN_NATIVE: return "CAN"; case CANFD_NATIVE: #ifdef USE_CANFD_INTERFACE_AS_CLASSIC_CAN return "CAN-FD Native (Classic CAN)"; #else return "CAN-FD Native"; #endif case CAN_ADDON_MCP2515: return "Add-on CAN via GPIO MCP2515"; case CANFD_ADDON_MCP2518: #ifdef USE_CANFD_INTERFACE_AS_CLASSIC_CAN return "Add-on CAN-FD via GPIO MCP2518 (Classic CAN)"; #else return "Add-on CAN-FD via GPIO MCP2518"; #endif default: return "UNKNOWN"; } }