#include "../../datalayer/datalayer.h"
String settings_processor(const String& var) {
if (var == "X") {
String content = "";
//Page format
content += "";
content += "Back to main page ";
// Start a new block with a specific background color
content += "";
content += "
SSID: " + String(ssid.c_str()) +
" Edit ";
content +=
"Password: ######## Edit ";
#ifndef RS485_BATTERY_SELECTED
content += "Battery interface: " +
String(getCANInterfaceName(can_config.battery)) + " ";
#endif
#ifdef RS485_BATTERY_SELECTED
content += "Battery interface: RS485 ";
#endif
#ifdef DOUBLE_BATTERY
content += "Battery #2 interface: " +
String(getCANInterfaceName(can_config.battery_double)) + " ";
#endif // DOUBLE_BATTERY
#ifdef CAN_INVERTER_SELECTED
content += "Inverter interface: " +
String(getCANInterfaceName(can_config.inverter)) + " ";
#endif //CAN_INVERTER_SELECTED
#ifdef MODBUS_INVERTER_SELECTED
content += "Inverter interface: RS485 ";
#endif
#ifdef CAN_SHUNT_SELECTED
content += "Shunt Interface: " +
String(getCANInterfaceName(can_config.shunt)) + " ";
#endif //CAN_SHUNT_SELECTED
// 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 Edit ";
content += "Rescale SOC: " +
String(datalayer.battery.settings.soc_scaling_active ? "✓ "
: "✕ ") +
" Edit ";
content += "SOC max percentage: " + String(datalayer.battery.settings.max_percentage / 100.0, 1) +
" Edit ";
content += "SOC min percentage: " + String(datalayer.battery.settings.min_percentage / 100.0, 1) +
" Edit ";
content += "Max charge speed: " +
String(datalayer.battery.settings.max_user_set_charge_dA / 10.0, 1) +
" A Edit ";
content += "Max discharge speed: " +
String(datalayer.battery.settings.max_user_set_discharge_dA / 10.0, 1) +
" A Edit ";
content += "Manual charge voltage limits: " +
String(datalayer.battery.settings.user_set_voltage_limits_active
? "✓ "
: "✕ ") +
" Edit ";
content +=
"Target charge voltage: " + String(datalayer.battery.settings.max_user_set_charge_voltage_dV / 10.0, 1) +
" V Edit ";
content += "Target discharge voltage: " +
String(datalayer.battery.settings.max_user_set_discharge_voltage_dV / 10.0, 1) +
" V Edit ";
// Close the block
content += "";
#ifdef TEST_FAKE_BATTERY
// Start a new block with blue background color
content += "";
float voltageFloat =
static_cast(datalayer.battery.status.voltage_dV) / 10.0; // Convert to float and divide by 10
content += "Fake battery voltage: " + String(voltageFloat, 1) +
" V Edit ";
// Close the block
content += "
";
#endif
#ifdef TESLA_MODEL_3Y_BATTERY
// Start a new block with grey background color
content += "";
content +=
"
Manual LFP balancing: " +
String(datalayer.battery.settings.user_requests_balancing ? "✓ "
: "✕ ") +
" Edit ";
content +=
"Balancing max time: " + String(datalayer.battery.settings.balancing_time_ms / 60000.0, 1) +
" Minutes Edit ";
content +=
"Balancing float power: " + String(datalayer.battery.settings.balancing_float_power_W / 1.0, 0) +
" W Edit ";
content +=
"Max battery voltage: " + String(datalayer.battery.settings.balancing_max_pack_voltage_dV / 10.0, 0) +
" V Edit ";
content +=
"Max cell voltage: " + String(datalayer.battery.settings.balancing_max_cell_voltage_mV / 1.0, 0) +
" mV Edit ";
content +=
"Max cell voltage deviation: " +
String(datalayer.battery.settings.balancing_max_deviation_cell_voltage_mV / 1.0, 0) +
" mV Edit ";
// Close the block
content += "";
#endif
#if defined CHEVYVOLT_CHARGER || defined NISSANLEAF_CHARGER
// Start a new block with orange background color
content += "";
content += "
Charger HVDC Enabled: ";
if (datalayer.charger.charger_HV_enabled) {
content += "✓ ";
} else {
content += "✕ ";
}
content += " Edit ";
content += "Charger Aux12VDC Enabled: ";
if (datalayer.charger.charger_aux12V_enabled) {
content += "✓ ";
} else {
content += "✕ ";
}
content += " Edit ";
content +=
"Charger Voltage Setpoint: " + String(datalayer.charger.charger_setpoint_HV_VDC, 1) +
" V Edit ";
content +=
"Charger Current Setpoint: " + String(datalayer.charger.charger_setpoint_HV_IDC, 1) +
" A Edit ";
// Close the block
content += "";
#endif
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";
}
}