Code review naming

This commit is contained in:
Daniel 2024-01-29 20:03:36 +02:00
parent 79e98c997d
commit 93b6a3941e
4 changed files with 29 additions and 29 deletions

View file

@ -19,7 +19,7 @@
#include "src/devboard/webserver/webserver.h"
#endif
Preferences preferences; // Parameter storage
Preferences settings; // Store user settings
// Interval settings
int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers
@ -105,7 +105,7 @@ bool inverterAllowsContactorClosing = true;
void setup() {
init_serial();
init_storage();
init_stored_settings();
#ifdef WEBSERVER
init_webserver();
@ -174,35 +174,35 @@ void init_serial() {
Serial.println("__ OK __");
}
void init_storage() {
preferences.begin("batterySettings", false);
void init_stored_settings() {
settings.begin("batterySettings", false);
#ifdef CLEAR_SAVED_SETTINGS
preferences.clear(); // If this clear function is executed, no parameters will be read from storage
#ifndef LOAD_SAVED_SETTINGS_ON_BOOT
settings.clear(); // If this clear function is executed, no settings will be read from storage
#endif
static uint16_t temp = 0;
temp = preferences.getUInt("BATTERY_WH_MAX", false);
temp = settings.getUInt("BATTERY_WH_MAX", false);
if (temp != 0) {
BATTERY_WH_MAX = temp;
}
temp = preferences.getUInt("MAXPERCENTAGE", false);
temp = settings.getUInt("MAXPERCENTAGE", false);
if (temp != 0) {
MAXPERCENTAGE = temp;
}
temp = preferences.getUInt("MINPERCENTAGE", false);
temp = settings.getUInt("MINPERCENTAGE", false);
if (temp != 0) {
MINPERCENTAGE = temp;
}
temp = preferences.getUInt("MAXCHARGEAMP", false);
temp = settings.getUInt("MAXCHARGEAMP", false);
if (temp != 0) {
MAXCHARGEAMP = temp;
}
temp = preferences.getUInt("MAXDISCHARGEAMP", false);
temp = settings.getUInt("MAXDISCHARGEAMP", false);
if (temp != 0) {
MAXDISCHARGEAMP = temp;
}
preferences.end();
settings.end();
}
void init_CAN() {
@ -706,12 +706,12 @@ void init_serialDataLink() {
#endif
}
void storeParameters() {
preferences.begin("batterySettings", false);
preferences.putUInt("BATTERY_WH_MAX", BATTERY_WH_MAX);
preferences.putUInt("MAXPERCENTAGE", MAXPERCENTAGE);
preferences.putUInt("MINPERCENTAGE", MINPERCENTAGE);
preferences.putUInt("MAXCHARGEAMP", MAXCHARGEAMP);
preferences.putUInt("MAXDISCHARGEAMP", MAXDISCHARGEAMP);
preferences.end();
void storeSettings() {
settings.begin("batterySettings", false);
settings.putUInt("BATTERY_WH_MAX", BATTERY_WH_MAX);
settings.putUInt("MAXPERCENTAGE", MAXPERCENTAGE);
settings.putUInt("MINPERCENTAGE", MINPERCENTAGE);
settings.putUInt("MAXCHARGEAMP", MAXCHARGEAMP);
settings.putUInt("MAXDISCHARGEAMP", MAXDISCHARGEAMP);
settings.end();
}

View file

@ -17,7 +17,7 @@
//#define RENAULT_ZOE_BATTERY
//#define SANTA_FE_PHEV_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 */
//#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_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 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 */
extern volatile uint16_t BATTERY_WH_MAX;

View file

@ -68,7 +68,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
BATTERY_WH_MAX = value.toInt();
storeParameters();
storeSettings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
@ -80,7 +80,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
MAXPERCENTAGE = value.toInt() * 10;
storeParameters();
storeSettings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
@ -92,7 +92,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
MINPERCENTAGE = value.toInt() * 10;
storeParameters();
storeSettings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
@ -104,7 +104,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
MAXCHARGEAMP = value.toInt() * 10;
storeParameters();
storeSettings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
@ -116,7 +116,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
MAXDISCHARGEAMP = value.toInt() * 10;
storeParameters();
storeSettings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");

View file

@ -128,7 +128,7 @@ void onOTAEnd(bool success);
template <typename T>
String formatPowerValue(String label, T value, String unit, int precision);
extern void storeParameters();
extern void restoreParameters();
extern void storeSettings();
extern void restoreSettings();
#endif