mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 02:09:30 +02:00
Code review naming
This commit is contained in:
parent
79e98c997d
commit
93b6a3941e
4 changed files with 29 additions and 29 deletions
|
@ -19,7 +19,7 @@
|
||||||
#include "src/devboard/webserver/webserver.h"
|
#include "src/devboard/webserver/webserver.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Preferences preferences; // Parameter storage
|
Preferences settings; // Store user settings
|
||||||
|
|
||||||
// Interval settings
|
// Interval settings
|
||||||
int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers
|
int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers
|
||||||
|
@ -105,7 +105,7 @@ bool inverterAllowsContactorClosing = true;
|
||||||
void setup() {
|
void setup() {
|
||||||
init_serial();
|
init_serial();
|
||||||
|
|
||||||
init_storage();
|
init_stored_settings();
|
||||||
|
|
||||||
#ifdef WEBSERVER
|
#ifdef WEBSERVER
|
||||||
init_webserver();
|
init_webserver();
|
||||||
|
@ -174,35 +174,35 @@ void init_serial() {
|
||||||
Serial.println("__ OK __");
|
Serial.println("__ OK __");
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_storage() {
|
void init_stored_settings() {
|
||||||
preferences.begin("batterySettings", false);
|
settings.begin("batterySettings", false);
|
||||||
|
|
||||||
#ifdef CLEAR_SAVED_SETTINGS
|
#ifndef LOAD_SAVED_SETTINGS_ON_BOOT
|
||||||
preferences.clear(); // If this clear function is executed, no parameters will be read from storage
|
settings.clear(); // If this clear function is executed, no settings will be read from storage
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint16_t temp = 0;
|
static uint16_t temp = 0;
|
||||||
temp = preferences.getUInt("BATTERY_WH_MAX", false);
|
temp = settings.getUInt("BATTERY_WH_MAX", false);
|
||||||
if (temp != 0) {
|
if (temp != 0) {
|
||||||
BATTERY_WH_MAX = temp;
|
BATTERY_WH_MAX = temp;
|
||||||
}
|
}
|
||||||
temp = preferences.getUInt("MAXPERCENTAGE", false);
|
temp = settings.getUInt("MAXPERCENTAGE", false);
|
||||||
if (temp != 0) {
|
if (temp != 0) {
|
||||||
MAXPERCENTAGE = temp;
|
MAXPERCENTAGE = temp;
|
||||||
}
|
}
|
||||||
temp = preferences.getUInt("MINPERCENTAGE", false);
|
temp = settings.getUInt("MINPERCENTAGE", false);
|
||||||
if (temp != 0) {
|
if (temp != 0) {
|
||||||
MINPERCENTAGE = temp;
|
MINPERCENTAGE = temp;
|
||||||
}
|
}
|
||||||
temp = preferences.getUInt("MAXCHARGEAMP", false);
|
temp = settings.getUInt("MAXCHARGEAMP", false);
|
||||||
if (temp != 0) {
|
if (temp != 0) {
|
||||||
MAXCHARGEAMP = temp;
|
MAXCHARGEAMP = temp;
|
||||||
}
|
}
|
||||||
temp = preferences.getUInt("MAXDISCHARGEAMP", false);
|
temp = settings.getUInt("MAXDISCHARGEAMP", false);
|
||||||
if (temp != 0) {
|
if (temp != 0) {
|
||||||
MAXDISCHARGEAMP = temp;
|
MAXDISCHARGEAMP = temp;
|
||||||
}
|
}
|
||||||
preferences.end();
|
settings.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_CAN() {
|
void init_CAN() {
|
||||||
|
@ -706,12 +706,12 @@ void init_serialDataLink() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void storeParameters() {
|
void storeSettings() {
|
||||||
preferences.begin("batterySettings", false);
|
settings.begin("batterySettings", false);
|
||||||
preferences.putUInt("BATTERY_WH_MAX", BATTERY_WH_MAX);
|
settings.putUInt("BATTERY_WH_MAX", BATTERY_WH_MAX);
|
||||||
preferences.putUInt("MAXPERCENTAGE", MAXPERCENTAGE);
|
settings.putUInt("MAXPERCENTAGE", MAXPERCENTAGE);
|
||||||
preferences.putUInt("MINPERCENTAGE", MINPERCENTAGE);
|
settings.putUInt("MINPERCENTAGE", MINPERCENTAGE);
|
||||||
preferences.putUInt("MAXCHARGEAMP", MAXCHARGEAMP);
|
settings.putUInt("MAXCHARGEAMP", MAXCHARGEAMP);
|
||||||
preferences.putUInt("MAXDISCHARGEAMP", MAXDISCHARGEAMP);
|
settings.putUInt("MAXDISCHARGEAMP", MAXDISCHARGEAMP);
|
||||||
preferences.end();
|
settings.end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
//#define RENAULT_ZOE_BATTERY
|
//#define RENAULT_ZOE_BATTERY
|
||||||
//#define SANTA_FE_PHEV_BATTERY
|
//#define SANTA_FE_PHEV_BATTERY
|
||||||
//#define TESLA_MODEL_3_BATTERY
|
//#define TESLA_MODEL_3_BATTERY
|
||||||
#define TEST_FAKE_BATTERY
|
//#define TEST_FAKE_BATTERY
|
||||||
|
|
||||||
/* Select inverter communication protocol. See Wiki for which to use with your inverter: https://github.com/dalathegreat/BYD-Battery-Emulator-For-Gen24/wiki */
|
/* Select inverter communication protocol. See Wiki for which to use with your inverter: https://github.com/dalathegreat/BYD-Battery-Emulator-For-Gen24/wiki */
|
||||||
//#define BYD_CAN //Enable this line to emulate a "BYD Battery-Box Premium HVS" over CAN Bus
|
//#define BYD_CAN //Enable this line to emulate a "BYD Battery-Box Premium HVS" over CAN Bus
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
//#define SERIAL_LINK_RECEIVER //Enable this line to receive battery data over RS485 pins from another Lilygo (This LilyGo interfaces with inverter)
|
//#define SERIAL_LINK_RECEIVER //Enable this line to receive battery data over RS485 pins from another Lilygo (This LilyGo interfaces with inverter)
|
||||||
//#define SERIAL_LINK_TRANSMITTER //Enable this line to send battery data over RS485 pins to another Lilygo (This LilyGo interfaces with battery)
|
//#define SERIAL_LINK_TRANSMITTER //Enable this line to send battery data over RS485 pins to another Lilygo (This LilyGo interfaces with battery)
|
||||||
#define WEBSERVER //Enable this line to enable WiFi, and to run the webserver. See USER_SETTINGS.cpp for the Wifi settings.
|
#define WEBSERVER //Enable this line to enable WiFi, and to run the webserver. See USER_SETTINGS.cpp for the Wifi settings.
|
||||||
//#define CLEAR_SAVED_SETTINGS //Enable this line to clear all data that has been saved via the webserver page
|
#define LOAD_SAVED_SETTINGS_ON_BOOT //Enable this line to read settings stored via the webserver on boot
|
||||||
|
|
||||||
/* Battery limits: These are set in the USER_SETTINGS.cpp file, or later on via the Webserver */
|
/* Battery limits: These are set in the USER_SETTINGS.cpp file, or later on via the Webserver */
|
||||||
extern volatile uint16_t BATTERY_WH_MAX;
|
extern volatile uint16_t BATTERY_WH_MAX;
|
||||||
|
|
|
@ -68,7 +68,7 @@ void init_webserver() {
|
||||||
if (request->hasParam("value")) {
|
if (request->hasParam("value")) {
|
||||||
String value = request->getParam("value")->value();
|
String value = request->getParam("value")->value();
|
||||||
BATTERY_WH_MAX = value.toInt();
|
BATTERY_WH_MAX = value.toInt();
|
||||||
storeParameters();
|
storeSettings();
|
||||||
request->send(200, "text/plain", "Updated successfully");
|
request->send(200, "text/plain", "Updated successfully");
|
||||||
} else {
|
} else {
|
||||||
request->send(400, "text/plain", "Bad Request");
|
request->send(400, "text/plain", "Bad Request");
|
||||||
|
@ -80,7 +80,7 @@ void init_webserver() {
|
||||||
if (request->hasParam("value")) {
|
if (request->hasParam("value")) {
|
||||||
String value = request->getParam("value")->value();
|
String value = request->getParam("value")->value();
|
||||||
MAXPERCENTAGE = value.toInt() * 10;
|
MAXPERCENTAGE = value.toInt() * 10;
|
||||||
storeParameters();
|
storeSettings();
|
||||||
request->send(200, "text/plain", "Updated successfully");
|
request->send(200, "text/plain", "Updated successfully");
|
||||||
} else {
|
} else {
|
||||||
request->send(400, "text/plain", "Bad Request");
|
request->send(400, "text/plain", "Bad Request");
|
||||||
|
@ -92,7 +92,7 @@ void init_webserver() {
|
||||||
if (request->hasParam("value")) {
|
if (request->hasParam("value")) {
|
||||||
String value = request->getParam("value")->value();
|
String value = request->getParam("value")->value();
|
||||||
MINPERCENTAGE = value.toInt() * 10;
|
MINPERCENTAGE = value.toInt() * 10;
|
||||||
storeParameters();
|
storeSettings();
|
||||||
request->send(200, "text/plain", "Updated successfully");
|
request->send(200, "text/plain", "Updated successfully");
|
||||||
} else {
|
} else {
|
||||||
request->send(400, "text/plain", "Bad Request");
|
request->send(400, "text/plain", "Bad Request");
|
||||||
|
@ -104,7 +104,7 @@ void init_webserver() {
|
||||||
if (request->hasParam("value")) {
|
if (request->hasParam("value")) {
|
||||||
String value = request->getParam("value")->value();
|
String value = request->getParam("value")->value();
|
||||||
MAXCHARGEAMP = value.toInt() * 10;
|
MAXCHARGEAMP = value.toInt() * 10;
|
||||||
storeParameters();
|
storeSettings();
|
||||||
request->send(200, "text/plain", "Updated successfully");
|
request->send(200, "text/plain", "Updated successfully");
|
||||||
} else {
|
} else {
|
||||||
request->send(400, "text/plain", "Bad Request");
|
request->send(400, "text/plain", "Bad Request");
|
||||||
|
@ -116,7 +116,7 @@ void init_webserver() {
|
||||||
if (request->hasParam("value")) {
|
if (request->hasParam("value")) {
|
||||||
String value = request->getParam("value")->value();
|
String value = request->getParam("value")->value();
|
||||||
MAXDISCHARGEAMP = value.toInt() * 10;
|
MAXDISCHARGEAMP = value.toInt() * 10;
|
||||||
storeParameters();
|
storeSettings();
|
||||||
request->send(200, "text/plain", "Updated successfully");
|
request->send(200, "text/plain", "Updated successfully");
|
||||||
} else {
|
} else {
|
||||||
request->send(400, "text/plain", "Bad Request");
|
request->send(400, "text/plain", "Bad Request");
|
||||||
|
|
|
@ -128,7 +128,7 @@ void onOTAEnd(bool success);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
String formatPowerValue(String label, T value, String unit, int precision);
|
String formatPowerValue(String label, T value, String unit, int precision);
|
||||||
|
|
||||||
extern void storeParameters();
|
extern void storeSettings();
|
||||||
extern void restoreParameters();
|
extern void restoreSettings();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue