mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 01:39:30 +02:00
Make LED pattern configurable in Webserver
This commit is contained in:
parent
fba4534ce4
commit
083432da78
6 changed files with 16 additions and 9 deletions
|
@ -173,14 +173,6 @@
|
||||||
//#define MAX_CUSTOM_CELL_VOLTAGE_MV 4250 // 4250 = 4.250V , Maximum cell voltage in millivolts (4250 = 4.250V)
|
//#define MAX_CUSTOM_CELL_VOLTAGE_MV 4250 // 4250 = 4.250V , Maximum cell voltage in millivolts (4250 = 4.250V)
|
||||||
//#define MIN_CUSTOM_CELL_VOLTAGE_MV 2650 // 2650 = 2.650V , Minimum cell voltage in millivolts (2650 = 2.650V)
|
//#define MIN_CUSTOM_CELL_VOLTAGE_MV 2650 // 2650 = 2.650V , Minimum cell voltage in millivolts (2650 = 2.650V)
|
||||||
|
|
||||||
/* LED settings. Optional customization for how the blinking pattern on the LED should behave.
|
|
||||||
* CLASSIC - Slow up/down ramp. If CLASSIC, then a ramp up and ramp down will finish in LED_PERIOD_MS milliseconds
|
|
||||||
* FLOW - Ramp up/down depending on flow of energy
|
|
||||||
* HEARTBEAT - Heartbeat-like LED pattern that reacts to the system state with color and BPM
|
|
||||||
*/
|
|
||||||
#define LED_MODE CLASSIC
|
|
||||||
#define LED_PERIOD_MS 3000
|
|
||||||
|
|
||||||
/* Do not change any code below this line */
|
/* Do not change any code below this line */
|
||||||
/* Only change battery specific settings above and in "USER_SETTINGS.cpp" */
|
/* Only change battery specific settings above and in "USER_SETTINGS.cpp" */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -146,6 +146,7 @@ void init_stored_settings() {
|
||||||
datalayer.system.info.web_logging_active = settings.getBool("WEBENABLED", false);
|
datalayer.system.info.web_logging_active = settings.getBool("WEBENABLED", false);
|
||||||
datalayer.system.info.CAN_SD_logging_active = settings.getBool("CANLOGSD", false);
|
datalayer.system.info.CAN_SD_logging_active = settings.getBool("CANLOGSD", false);
|
||||||
datalayer.system.info.SD_logging_active = settings.getBool("SDLOGENABLED", false);
|
datalayer.system.info.SD_logging_active = settings.getBool("SDLOGENABLED", false);
|
||||||
|
datalayer.battery.status.led_mode = (led_mode_enum)settings.getUInt("LEDMODE", false);
|
||||||
|
|
||||||
// WIFI AP is enabled by default unless disabled in the settings
|
// WIFI AP is enabled by default unless disabled in the settings
|
||||||
wifiap_enabled = settings.getBool("WIFIAPENABLED", true);
|
wifiap_enabled = settings.getBool("WIFIAPENABLED", true);
|
||||||
|
|
|
@ -110,7 +110,7 @@ struct DATALAYER_BATTERY_STATUS_TYPE {
|
||||||
real_bms_status_enum real_bms_status = BMS_DISCONNECTED;
|
real_bms_status_enum real_bms_status = BMS_DISCONNECTED;
|
||||||
|
|
||||||
/** LED mode, customizable by user */
|
/** LED mode, customizable by user */
|
||||||
led_mode_enum led_mode = LED_MODE;
|
led_mode_enum led_mode = CLASSIC;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DATALAYER_BATTERY_SETTINGS_TYPE {
|
struct DATALAYER_BATTERY_SETTINGS_TYPE {
|
||||||
|
|
|
@ -25,6 +25,7 @@ class LED {
|
||||||
void heartbeat_run(void);
|
void heartbeat_run(void);
|
||||||
|
|
||||||
uint8_t up_down(float middle_point_f);
|
uint8_t up_down(float middle_point_f);
|
||||||
|
int LED_PERIOD_MS = 3000;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool led_init(void);
|
bool led_init(void);
|
||||||
|
|
|
@ -93,6 +93,8 @@ String options_from_map(int selected, const TMap& value_name_map) {
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const std::map<int, String> led_modes = {{0, "Classic"}, {1, "Energy Flow"}, {2, "Heartbeat"}};
|
||||||
|
|
||||||
static const std::map<int, String> tesla_countries = {
|
static const std::map<int, String> tesla_countries = {
|
||||||
{21843, "US (USA)"}, {17217, "CA (Canada)"}, {18242, "GB (UK & N Ireland)"},
|
{21843, "US (USA)"}, {17217, "CA (Canada)"}, {18242, "GB (UK & N Ireland)"},
|
||||||
{17483, "DK (Denmark)"}, {17477, "DE (Germany)"}, {16725, "AU (Australia)"}};
|
{17483, "DK (Denmark)"}, {17477, "DE (Germany)"}, {16725, "AU (Australia)"}};
|
||||||
|
@ -571,6 +573,10 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
|
||||||
return options_from_map(settings.getUInt("GTWPACK", 0), tesla_pack);
|
return options_from_map(settings.getUInt("GTWPACK", 0), tesla_pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (var == "LEDMODE") {
|
||||||
|
return options_from_map(settings.getUInt("LEDMODE", 0), led_modes);
|
||||||
|
}
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,6 +978,10 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
||||||
<label>Enable logging via SD card: </label>
|
<label>Enable logging via SD card: </label>
|
||||||
<input type='checkbox' name='SDLOGENABLED' value='on' style='margin-left: 0;' %SDLOGENABLED% />
|
<input type='checkbox' name='SDLOGENABLED' value='on' style='margin-left: 0;' %SDLOGENABLED% />
|
||||||
|
|
||||||
|
<label for='LEDMODE'>Status LED pattern: </label><select name='LEDMODE' id='LEDMODE'>
|
||||||
|
%LEDMODE%
|
||||||
|
</select>
|
||||||
|
|
||||||
<label>Enable MQTT: </label>
|
<label>Enable MQTT: </label>
|
||||||
<input type='checkbox' name='MQTTENABLED' value='on' style='margin-left: 0;' %MQTTENABLED% />
|
<input type='checkbox' name='MQTTENABLED' value='on' style='margin-left: 0;' %MQTTENABLED% />
|
||||||
|
|
||||||
|
|
|
@ -524,6 +524,9 @@ void init_webserver() {
|
||||||
} else if (p->name() == "GTWPACK") {
|
} else if (p->name() == "GTWPACK") {
|
||||||
auto type = atoi(p->value().c_str());
|
auto type = atoi(p->value().c_str());
|
||||||
settings.saveUInt("GTWPACK", type);
|
settings.saveUInt("GTWPACK", type);
|
||||||
|
} else if (p->name() == "LEDMODE") {
|
||||||
|
auto type = atoi(p->value().c_str());
|
||||||
|
settings.saveUInt("LEDMODE", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& boolSetting : boolSettings) {
|
for (auto& boolSetting : boolSettings) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue