Remove old method to compile, all is now Common Image

This commit is contained in:
Daniel Öster 2025-09-01 15:03:56 +03:00
parent ee4b14c770
commit 7ee0eb5e88
53 changed files with 12 additions and 361 deletions

View file

@ -21,25 +21,14 @@ volatile CAN_Configuration can_config = {
.shunt = CAN_NATIVE // (OPTIONAL) Which CAN is your shunt connected to? .shunt = CAN_NATIVE // (OPTIONAL) Which CAN is your shunt connected to?
}; };
#ifdef COMMON_IMAGE
std::string ssid; std::string ssid;
std::string password; std::string password;
std::string passwordAP; std::string passwordAP;
#else
std::string ssid = WIFI_SSID; // Set in USER_SECRETS.h
std::string password = WIFI_PASSWORD; // Set in USER_SECRETS.h
std::string passwordAP = AP_PASSWORD; // Set in USER_SECRETS.h
#endif
const uint8_t wifi_channel = 0; // Set to 0 for automatic channel selection const uint8_t wifi_channel = 0; // Set to 0 for automatic channel selection
#ifdef COMMON_IMAGE
std::string http_username; std::string http_username;
std::string http_password; std::string http_password;
#else
std::string http_username = HTTP_USERNAME; // Set in USER_SECRETS.h
std::string http_password = HTTP_PASSWORD; // Set in USER_SECRETS.h
#endif
// Set your Static IP address. Only used incase WIFICONFIG is set in USER_SETTINGS.h // Set your Static IP address. Only used incase WIFICONFIG is set in USER_SETTINGS.h
IPAddress local_IP(192, 168, 10, 150); IPAddress local_IP(192, 168, 10, 150);
@ -47,13 +36,8 @@ IPAddress gateway(192, 168, 10, 1);
IPAddress subnet(255, 255, 255, 0); IPAddress subnet(255, 255, 255, 0);
// MQTT // MQTT
#ifdef COMMON_IMAGE
std::string mqtt_user; std::string mqtt_user;
std::string mqtt_password; std::string mqtt_password;
#else
std::string mqtt_user = MQTT_USER; // Set in USER_SECRETS.h
std::string mqtt_password = MQTT_PASSWORD; // Set in USER_SECRETS.h
#endif
const char* mqtt_topic_name = const char* mqtt_topic_name =
"BE"; // Custom MQTT topic name. Previously, the name was automatically set to "battery-emulator_esp32-XXXXXX" "BE"; // Custom MQTT topic name. Previously, the name was automatically set to "battery-emulator_esp32-XXXXXX"

View file

@ -6,8 +6,6 @@
/* This file is being transitioned towards COMMON_IMAGE. Use v8.16 if you are taking this software into use! */ /* This file is being transitioned towards COMMON_IMAGE. Use v8.16 if you are taking this software into use! */
//#define COMMON_IMAGE
/* Select hardware used for Battery-Emulator */ /* Select hardware used for Battery-Emulator */
//#define HW_LILYGO //#define HW_LILYGO
//#define HW_STARK //#define HW_STARK

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "RS485Battery.h" #include "RS485Battery.h"
#if !defined(COMMON_IMAGE) && !defined(SELECTED_BATTERY_CLASS)
#error No battery selected! Choose one from the USER_SETTINGS.h file or build COMMON_IMAGE.
#endif
Battery* battery = nullptr; Battery* battery = nullptr;
Battery* battery2 = nullptr; Battery* battery2 = nullptr;
@ -149,11 +145,6 @@ const battery_chemistry_enum battery_chemistry_default = battery_chemistry_enum:
battery_chemistry_enum user_selected_battery_chemistry = battery_chemistry_default; battery_chemistry_enum user_selected_battery_chemistry = battery_chemistry_default;
#ifdef COMMON_IMAGE
#ifdef SELECTED_BATTERY_CLASS
#error "Compile time SELECTED_BATTERY_CLASS should not be defined with COMMON_IMAGE"
#endif
BatteryType user_selected_battery_type = BatteryType::NissanLeaf; BatteryType user_selected_battery_type = BatteryType::NissanLeaf;
bool user_selected_second_battery = false; bool user_selected_second_battery = false;
@ -287,39 +278,6 @@ void setup_battery() {
} }
} }
} }
#else // Battery selection has been made at build-time
void setup_battery() {
// Instantiate the battery only once just in case this function gets called multiple times.
if (battery == nullptr) {
#ifdef TESLA_MODEL_3Y_BATTERY
battery = new SELECTED_BATTERY_CLASS(user_selected_battery_chemistry);
#else
battery = new SELECTED_BATTERY_CLASS();
#endif
}
battery->setup();
#ifdef DOUBLE_BATTERY
if (battery2 == nullptr) {
#if defined(BMW_I3_BATTERY)
battery2 =
new SELECTED_BATTERY_CLASS(&datalayer.battery2, &datalayer.system.status.battery2_allowed_contactor_closing,
can_config.battery_double, esp32hal->WUP_PIN2());
#elif defined(KIA_HYUNDAI_64_BATTERY)
battery2 = new SELECTED_BATTERY_CLASS(&datalayer.battery2, &datalayer_extended.KiaHyundai64_2,
&datalayer.system.status.battery2_allowed_contactor_closing,
can_config.battery_double);
#elif defined(SANTA_FE_PHEV_BATTERY) || defined(TEST_FAKE_BATTERY)
battery2 = new SELECTED_BATTERY_CLASS(&datalayer.battery2, can_config.battery_double);
#else
battery2 = new SELECTED_BATTERY_CLASS(&datalayer.battery2, nullptr, can_config.battery_double);
#endif
}
battery2->setup();
#endif
}
#endif
/* User-selected Tesla settings */ /* User-selected Tesla settings */
bool user_selected_tesla_digital_HVIL = false; bool user_selected_tesla_digital_HVIL = false;
@ -329,7 +287,7 @@ uint16_t user_selected_tesla_GTW_mapRegion = 2;
uint16_t user_selected_tesla_GTW_chassisType = 2; uint16_t user_selected_tesla_GTW_chassisType = 2;
uint16_t user_selected_tesla_GTW_packEnergy = 1; uint16_t user_selected_tesla_GTW_packEnergy = 1;
// Use 0V for user selected cell/pack voltage defaults (COMMON_IMAGE will replace with saved values from NVM) // Use 0V for user selected cell/pack voltage defaults (On boot will be replaced with saved values from NVM)
uint16_t user_selected_max_pack_voltage_dV = 0; uint16_t user_selected_max_pack_voltage_dV = 0;
uint16_t user_selected_min_pack_voltage_dV = 0; uint16_t user_selected_min_pack_voltage_dV = 0;
uint16_t user_selected_max_cell_voltage_mV = 0; uint16_t user_selected_max_cell_voltage_mV = 0;

View file

@ -6,10 +6,6 @@
#include "BMW-I3-HTML.h" #include "BMW-I3-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef BMW_I3_BATTERY
#define SELECTED_BATTERY_CLASS BmwI3Battery
#endif
class BmwI3Battery : public CanBattery { class BmwI3Battery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -4,10 +4,6 @@
#include "BMW-IX-HTML.h" #include "BMW-IX-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef BMW_IX_BATTERY
#define SELECTED_BATTERY_CLASS BmwIXBattery
#endif
class BmwIXBattery : public CanBattery { class BmwIXBattery : public CanBattery {
public: public:
BmwIXBattery() : renderer(*this) {} BmwIXBattery() : renderer(*this) {}

View file

@ -3,10 +3,6 @@
#include "BMW-PHEV-HTML.h" #include "BMW-PHEV-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef BMW_PHEV_BATTERY
#define SELECTED_BATTERY_CLASS BmwPhevBattery
#endif
class BmwPhevBattery : public CanBattery { class BmwPhevBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -3,10 +3,6 @@
#include "BOLT-AMPERA-HTML.h" #include "BOLT-AMPERA-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef BOLT_AMPERA_BATTERY
#define SELECTED_BATTERY_CLASS BoltAmperaBattery
#endif
class BoltAmperaBattery : public CanBattery { class BoltAmperaBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -24,9 +24,6 @@ static const int RAMPDOWN_POWER_ALLOWED =
10000; // Power to start ramp down from, set a lower value to limit the power even further as SOC decreases 10000; // Power to start ramp down from, set a lower value to limit the power even further as SOC decreases
/* Do not modify the rows below */ /* Do not modify the rows below */
#ifdef BYD_ATTO_3_BATTERY
#define SELECTED_BATTERY_CLASS BydAttoBattery
#endif
class BydAttoBattery : public CanBattery { class BydAttoBattery : public CanBattery {
public: public:

View file

@ -3,10 +3,6 @@
#include "CELLPOWER-HTML.h" #include "CELLPOWER-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef CELLPOWER_BMS
#define SELECTED_BATTERY_CLASS CellPowerBms
#endif
class CellPowerBms : public CanBattery { class CellPowerBms : public CanBattery {
public: public:
CellPowerBms() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {} CellPowerBms() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {}

View file

@ -7,10 +7,6 @@
#include "CHADEMO-BATTERY-HTML.h" #include "CHADEMO-BATTERY-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef CHADEMO_BATTERY
#define SELECTED_BATTERY_CLASS ChademoBattery
#endif
class ChademoBattery : public CanBattery { class ChademoBattery : public CanBattery {
public: public:
ChademoBattery() { ChademoBattery() {

View file

@ -4,10 +4,6 @@
#include "CMFA-EV-HTML.h" #include "CMFA-EV-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef CMFA_EV_BATTERY
#define SELECTED_BATTERY_CLASS CmfaEvBattery
#endif
class CmfaEvBattery : public CanBattery { class CmfaEvBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -3,10 +3,6 @@
#include "RS485Battery.h" #include "RS485Battery.h"
#ifdef DALY_BMS
#define SELECTED_BATTERY_CLASS DalyBms
#endif
class DalyBms : public RS485Battery { class DalyBms : public RS485Battery {
public: public:
void setup(); void setup();

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "ECMP-HTML.h" #include "ECMP-HTML.h"
#ifdef STELLANTIS_ECMP_BATTERY
#define SELECTED_BATTERY_CLASS EcmpBattery
#endif
class EcmpBattery : public CanBattery { class EcmpBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -2,10 +2,6 @@
#define FOXESS_BATTERY_H #define FOXESS_BATTERY_H
#include "CanBattery.h" #include "CanBattery.h"
#ifdef FOXESS_BATTERY
#define SELECTED_BATTERY_CLASS FoxessBattery
#endif
class FoxessBattery : public CanBattery { class FoxessBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -4,10 +4,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "GEELY-GEOMETRY-C-HTML.h" #include "GEELY-GEOMETRY-C-HTML.h"
#ifdef GEELY_GEOMETRY_C_BATTERY
#define SELECTED_BATTERY_CLASS GeelyGeometryCBattery
#endif
class GeelyGeometryCBattery : public CanBattery { class GeelyGeometryCBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -6,10 +6,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "HYUNDAI-IONIQ-28-BATTERY-HTML.h" #include "HYUNDAI-IONIQ-28-BATTERY-HTML.h"
#ifdef HYUNDAI_IONIQ_28_BATTERY
#define SELECTED_BATTERY_CLASS HyundaiIoniq28Battery
#endif
class HyundaiIoniq28Battery : public CanBattery { class HyundaiIoniq28Battery : public CanBattery {
public: public:
// Use the default constructor to create the first or single battery. // Use the default constructor to create the first or single battery.

View file

@ -2,10 +2,6 @@
#define IMIEV_CZERO_ION_BATTERY_H #define IMIEV_CZERO_ION_BATTERY_H
#include "CanBattery.h" #include "CanBattery.h"
#ifdef IMIEV_CZERO_ION_BATTERY
#define SELECTED_BATTERY_CLASS ImievCZeroIonBattery
#endif
class ImievCZeroIonBattery : public CanBattery { class ImievCZeroIonBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef JAGUAR_IPACE_BATTERY
#define SELECTED_BATTERY_CLASS JaguarIpaceBattery
#endif
class JaguarIpaceBattery : public CanBattery { class JaguarIpaceBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -5,10 +5,6 @@
#define ESTIMATE_SOC_FROM_CELLVOLTAGE #define ESTIMATE_SOC_FROM_CELLVOLTAGE
#ifdef KIA_HYUNDAI_64_FD_BATTERY
#define SELECTED_BATTERY_CLASS Kia64FDBattery
#endif
class Kia64FDBattery : public CanBattery { class Kia64FDBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -5,10 +5,6 @@
#define ESTIMATE_SOC_FROM_CELLVOLTAGE #define ESTIMATE_SOC_FROM_CELLVOLTAGE
#ifdef KIA_E_GMP_BATTERY
#define SELECTED_BATTERY_CLASS KiaEGmpBattery
#endif
class KiaEGmpBattery : public CanBattery { class KiaEGmpBattery : public CanBattery {
public: public:
KiaEGmpBattery() : renderer(*this) {} KiaEGmpBattery() : renderer(*this) {}

View file

@ -5,10 +5,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "KIA-HYUNDAI-64-HTML.h" #include "KIA-HYUNDAI-64-HTML.h"
#ifdef KIA_HYUNDAI_64_BATTERY
#define SELECTED_BATTERY_CLASS KiaHyundai64Battery
#endif
class KiaHyundai64Battery : public CanBattery { class KiaHyundai64Battery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -2,10 +2,6 @@
#define KIA_HYUNDAI_HYBRID_BATTERY_H #define KIA_HYUNDAI_HYBRID_BATTERY_H
#include "CanBattery.h" #include "CanBattery.h"
#ifdef KIA_HYUNDAI_HYBRID_BATTERY
#define SELECTED_BATTERY_CLASS KiaHyundaiHybridBattery
#endif
class KiaHyundaiHybridBattery : public CanBattery { class KiaHyundaiHybridBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "MEB-HTML.h" #include "MEB-HTML.h"
#ifdef MEB_BATTERY
#define SELECTED_BATTERY_CLASS MebBattery
#endif
class MebBattery : public CanBattery { class MebBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -2,10 +2,6 @@
#define MG_5_BATTERY_H #define MG_5_BATTERY_H
#include "CanBattery.h" #include "CanBattery.h"
#ifdef MG_5_BATTERY
#define SELECTED_BATTERY_CLASS Mg5Battery
#endif
class Mg5Battery : public CanBattery { class Mg5Battery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef MG_HS_PHEV_BATTERY
#define SELECTED_BATTERY_CLASS MgHsPHEVBattery
#endif
class MgHsPHEVBattery : public CanBattery { class MgHsPHEVBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -6,10 +6,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "NISSAN-LEAF-HTML.h" #include "NISSAN-LEAF-HTML.h"
#ifdef NISSAN_LEAF_BATTERY
#define SELECTED_BATTERY_CLASS NissanLeafBattery
#endif
class NissanLeafBattery : public CanBattery { class NissanLeafBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -4,10 +4,6 @@
#include "../system_settings.h" #include "../system_settings.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef ORION_BMS
#define SELECTED_BATTERY_CLASS OrionBms
#endif
class OrionBms : public CanBattery { class OrionBms : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -4,10 +4,6 @@
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef PYLON_BATTERY
#define SELECTED_BATTERY_CLASS PylonBattery
#endif
class PylonBattery : public CanBattery { class PylonBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef RANGE_ROVER_PHEV_BATTERY
#define SELECTED_BATTERY_CLASS RangeRoverPhevBattery
#endif
class RangeRoverPhevBattery : public CanBattery { class RangeRoverPhevBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -4,10 +4,6 @@
#include "../system_settings.h" #include "../system_settings.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef RELION_BATTERY
#define SELECTED_BATTERY_CLASS RelionBattery
#endif
class RelionBattery : public CanBattery { class RelionBattery : public CanBattery {
public: public:
RelionBattery() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {} RelionBattery() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {}

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef RENAULT_KANGOO_BATTERY
#define SELECTED_BATTERY_CLASS RenaultKangooBattery
#endif
class RenaultKangooBattery : public CanBattery { class RenaultKangooBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -2,10 +2,6 @@
#define RENAULT_TWIZY_BATTERY_H #define RENAULT_TWIZY_BATTERY_H
#include "CanBattery.h" #include "CanBattery.h"
#ifdef RENAULT_TWIZY_BATTERY
#define SELECTED_BATTERY_CLASS RenaultTwizyBattery
#endif
class RenaultTwizyBattery : public CanBattery { class RenaultTwizyBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -4,10 +4,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "RENAULT-ZOE-GEN1-HTML.h" #include "RENAULT-ZOE-GEN1-HTML.h"
#ifdef RENAULT_ZOE_GEN1_BATTERY
#define SELECTED_BATTERY_CLASS RenaultZoeGen1Battery
#endif
class RenaultZoeGen1Battery : public CanBattery { class RenaultZoeGen1Battery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -4,10 +4,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "RENAULT-ZOE-GEN2-HTML.h" #include "RENAULT-ZOE-GEN2-HTML.h"
#ifdef RENAULT_ZOE_GEN2_BATTERY
#define SELECTED_BATTERY_CLASS RenaultZoeGen2Battery
#endif
class RenaultZoeGen2Battery : public CanBattery { class RenaultZoeGen2Battery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -4,10 +4,6 @@
#include "../system_settings.h" #include "../system_settings.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef RJXZS_BMS
#define SELECTED_BATTERY_CLASS RjxzsBms
#endif
class RjxzsBms : public CanBattery { class RjxzsBms : public CanBattery {
public: public:
RjxzsBms() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {} RjxzsBms() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {}

View file

@ -4,10 +4,6 @@
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef SAMSUNG_SDI_LV_BATTERY
#define SELECTED_BATTERY_CLASS SamsungSdiLVBattery
#endif
class SamsungSdiLVBattery : public CanBattery { class SamsungSdiLVBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -3,10 +3,6 @@
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef SANTA_FE_PHEV_BATTERY
#define SELECTED_BATTERY_CLASS SantaFePhevBattery
#endif
class SantaFePhevBattery : public CanBattery { class SantaFePhevBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef SIMPBMS_BATTERY
#define SELECTED_BATTERY_CLASS SimpBmsBattery
#endif
class SimpBmsBattery : public CanBattery { class SimpBmsBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef SONO_BATTERY
#define SELECTED_BATTERY_CLASS SonoBattery
#endif
class SonoBattery : public CanBattery { class SonoBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -4,11 +4,6 @@
CanShunt* shunt = nullptr; CanShunt* shunt = nullptr;
ShuntType user_selected_shunt_type = ShuntType::None; ShuntType user_selected_shunt_type = ShuntType::None;
#ifdef COMMON_IMAGE
#ifdef SELECTED_SHUNT_CLASS
#error "Compile time SELECTED_SHUNT_CLASS should not be defined with COMMON_IMAGE"
#endif
void setup_can_shunt() { void setup_can_shunt() {
if (shunt) { if (shunt) {
return; return;
@ -30,21 +25,6 @@ void setup_can_shunt() {
} }
} }
#else
void setup_can_shunt() {
if (shunt) {
return;
}
#if defined(SELECTED_SHUNT_CLASS)
shunt = new SELECTED_SHUNT_CLASS();
if (shunt) {
shunt->setup();
}
#endif
}
#endif
extern std::vector<ShuntType> supported_shunt_types() { extern std::vector<ShuntType> supported_shunt_types() {
std::vector<ShuntType> types; std::vector<ShuntType> types;

View file

@ -4,13 +4,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "TESLA-HTML.h" #include "TESLA-HTML.h"
#ifdef TESLA_MODEL_3Y_BATTERY
#define SELECTED_BATTERY_CLASS TeslaModel3YBattery
#endif
#ifdef TESLA_MODEL_SX_BATTERY
#define SELECTED_BATTERY_CLASS TeslaModelSXBattery
#endif
// 0x7FF gateway config, "Gen3" vehicles only, not applicable to Gen2 "classic" Model S and Model X // 0x7FF gateway config, "Gen3" vehicles only, not applicable to Gen2 "classic" Model S and Model X
// These are user configurable from the Webserver UI // These are user configurable from the Webserver UI
extern bool user_selected_tesla_digital_HVIL; extern bool user_selected_tesla_digital_HVIL;

View file

@ -3,10 +3,6 @@
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef TEST_FAKE_BATTERY
#define SELECTED_BATTERY_CLASS TestFakeBattery
#endif
class TestFakeBattery : public CanBattery { class TestFakeBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -4,10 +4,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "VOLVO-SPA-HTML.h" #include "VOLVO-SPA-HTML.h"
#ifdef VOLVO_SPA_BATTERY
#define SELECTED_BATTERY_CLASS VolvoSpaBattery
#endif
class VolvoSpaBattery : public CanBattery { class VolvoSpaBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "VOLVO-SPA-HYBRID-HTML.h" #include "VOLVO-SPA-HYBRID-HTML.h"
#ifdef VOLVO_SPA_HYBRID_BATTERY
#define SELECTED_BATTERY_CLASS VolvoSpaHybridBattery
#endif
class VolvoSpaHybridBattery : public CanBattery { class VolvoSpaHybridBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -30,16 +30,11 @@ extern const char* name_for_charger_type(ChargerType type) {
} }
void setup_charger() { void setup_charger() {
#ifdef COMMON_IMAGE
switch (user_selected_charger_type) { switch (user_selected_charger_type) {
case ChargerType::ChevyVolt: case ChargerType::ChevyVolt:
charger = new ChevyVoltCharger(); charger = new ChevyVoltCharger();
case ChargerType::NissanLeaf: case ChargerType::NissanLeaf:
charger = new NissanLeafCharger(); charger = new NissanLeafCharger();
} }
#else
#ifdef SELECTED_CHARGER_CLASS
charger = new SELECTED_CHARGER_CLASS();
#endif
#endif
} }

View file

@ -87,7 +87,6 @@ void init_stored_settings() {
datalayer.battery.settings.user_set_bms_reset_duration_ms = temp; datalayer.battery.settings.user_set_bms_reset_duration_ms = temp;
} }
#ifdef COMMON_IMAGE
user_selected_battery_type = (BatteryType)settings.getUInt("BATTTYPE", (int)BatteryType::None); user_selected_battery_type = (BatteryType)settings.getUInt("BATTTYPE", (int)BatteryType::None);
user_selected_battery_chemistry = user_selected_battery_chemistry =
(battery_chemistry_enum)settings.getUInt("BATTCHEM", (int)battery_chemistry_enum::NCA); (battery_chemistry_enum)settings.getUInt("BATTCHEM", (int)battery_chemistry_enum::NCA);
@ -168,8 +167,6 @@ void init_stored_settings() {
mqtt_user = settings.getString("MQTTUSER").c_str(); mqtt_user = settings.getString("MQTTUSER").c_str();
mqtt_password = settings.getString("MQTTPASSWORD").c_str(); mqtt_password = settings.getString("MQTTPASSWORD").c_str();
#endif
settings.end(); settings.end();
} }

View file

@ -15,29 +15,11 @@
#include "mqtt.h" #include "mqtt.h"
#include "mqtt_client.h" #include "mqtt_client.h"
#ifdef MQTT bool mqtt_enabled = false;
const bool mqtt_enabled_default = true; bool ha_autodiscovery_enabled = false;
#else
const bool mqtt_enabled_default = false;
#endif
bool mqtt_enabled = mqtt_enabled_default;
#ifdef HA_AUTODISCOVERY
const bool ha_autodiscovery_enabled_default = true;
#else
const bool ha_autodiscovery_enabled_default = false;
#endif
bool ha_autodiscovery_enabled = ha_autodiscovery_enabled_default;
#ifdef COMMON_IMAGE
const int mqtt_port_default = 0; const int mqtt_port_default = 0;
const char* mqtt_server_default = ""; const char* mqtt_server_default = "";
#else
const int mqtt_port_default = MQTT_PORT;
const char* mqtt_server_default = MQTT_SERVER;
#endif
int mqtt_port = mqtt_port_default; int mqtt_port = mqtt_port_default;
std::string mqtt_server = mqtt_server_default; std::string mqtt_server = mqtt_server_default;
@ -626,7 +608,7 @@ bool init_mqtt(void) {
} }
if (mqtt_manual_topic_object_name) { if (mqtt_manual_topic_object_name) {
#ifdef COMMON_IMAGE
BatteryEmulatorSettingsStore settings; BatteryEmulatorSettingsStore settings;
topic_name = settings.getString("MQTTTOPIC", mqtt_topic_name); topic_name = settings.getString("MQTTTOPIC", mqtt_topic_name);
object_id_prefix = settings.getString("MQTTOBJIDPREFIX", mqtt_object_id_prefix); object_id_prefix = settings.getString("MQTTOBJIDPREFIX", mqtt_object_id_prefix);
@ -649,13 +631,6 @@ bool init_mqtt(void) {
device_id = ha_device_id; device_id = ha_device_id;
} }
#else
// Use custom topic name, object ID prefix, and device name from user settings
topic_name = mqtt_topic_name;
object_id_prefix = mqtt_object_id_prefix;
device_name = mqtt_device_name;
device_id = ha_device_id;
#endif
} else { } else {
// Use default naming based on WiFi hostname for topic, object ID prefix, and device name // Use default naming based on WiFi hostname for topic, object ID prefix, and device name
topic_name = "battery-emulator_" + String(WiFi.getHostname()); topic_name = "battery-emulator_" + String(WiFi.getHostname());

View file

@ -135,12 +135,6 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
return String(ssid.c_str()); return String(ssid.c_str());
} }
#ifndef COMMON_IMAGE
if (var == "COMMONIMAGEDIVCLASS") {
return "hidden";
}
#endif
if (var == "SAVEDCLASS") { if (var == "SAVEDCLASS") {
if (!settingsUpdated) { if (!settingsUpdated) {
return "hidden"; return "hidden";
@ -839,7 +833,7 @@ const char* getCANInterfaceName(CAN_Interface interface) {
<h4 style='color: white;'>SSID: <span id='SSID'>%SSID%</span><button onclick='editSSID()'>Edit</button></h4> <h4 style='color: white;'>SSID: <span id='SSID'>%SSID%</span><button onclick='editSSID()'>Edit</button></h4>
<h4 style='color: white;'>Password: ######## <span id='Password'></span> <button onclick='editPassword()'>Edit</button></h4> <h4 style='color: white;'>Password: ######## <span id='Password'></span> <button onclick='editPassword()'>Edit</button></h4>
<div style='background-color: #404E47; padding: 10px; margin-bottom: 10px;border-radius: 50px; class="%COMMONIMAGEDIVCLASS%"> <div style='background-color: #404E47; padding: 10px; margin-bottom: 10px;border-radius: 50px'>
<div style='max-width: 500px;'> <div style='max-width: 500px;'>
<form action='saveSettings' method='post' style='display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; align-items: center;'> <form action='saveSettings' method='post' style='display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; align-items: center;'>

View file

@ -23,21 +23,10 @@
extern std::string http_username; extern std::string http_username;
extern std::string http_password; extern std::string http_password;
#ifdef WEBSERVER bool webserver_enabled =
const bool webserver_enabled_default = true; true; // Global flag to enable or disable the webserver //Old method to disable was with #ifdef WEBSERVER
#else
const bool webserver_enabled_default = false;
#endif
bool webserver_enabled = webserver_enabled_default; // Global flag to enable or disable the webserver bool webserver_auth = false;
#ifndef COMMON_IMAGE
const bool webserver_auth_default = WEBSERVER_AUTH_REQUIRED;
#else
const bool webserver_auth_default = false;
#endif
bool webserver_auth = webserver_auth_default;
// Create AsyncWebServer object on port 80 // Create AsyncWebServer object on port 80
AsyncWebServer server(80); AsyncWebServer server(80);
@ -401,7 +390,6 @@ void init_webserver() {
request->send(200, "text/html", "OK"); request->send(200, "text/html", "OK");
}); });
#ifdef COMMON_IMAGE
struct BoolSetting { struct BoolSetting {
const char* name; const char* name;
bool existingValue; bool existingValue;
@ -557,7 +545,6 @@ void init_webserver() {
settingsUpdated = settings.were_settings_updated(); settingsUpdated = settings.were_settings_updated();
request->redirect("/settings"); request->redirect("/settings");
}); });
#endif
// Route for editing SSID // Route for editing SSID
def_route_with_auth("/updateSSID", server, HTTP_GET, [](AsyncWebServerRequest* request) { def_route_with_auth("/updateSSID", server, HTTP_GET, [](AsyncWebServerRequest* request) {
@ -908,9 +895,6 @@ String processor(const String& var) {
content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px; border-radius: 50px'>"; content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px; border-radius: 50px'>";
content += "<h4>Software: " + String(version_number); content += "<h4>Software: " + String(version_number);
#ifdef COMMON_IMAGE
content += " (Common image) ";
#endif
// Show hardware used: // Show hardware used:
#ifdef HW_LILYGO #ifdef HW_LILYGO
content += " Hardware: LilyGo T-CAN485"; content += " Hardware: LilyGo T-CAN485";

View file

@ -12,17 +12,7 @@ const bool wifi_enabled_default = false;
bool wifi_enabled = wifi_enabled_default; bool wifi_enabled = wifi_enabled_default;
#ifdef COMMON_IMAGE bool wifiap_enabled = true; //Old method was with ifdef
const bool wifiap_enabled_default = true;
#else
#ifdef WIFIAP
const bool wifiap_enabled_default = true;
#else
const bool wifiap_enabled_default = false;
#endif
#endif
bool wifiap_enabled = wifiap_enabled_default;
#ifdef MDNSRESPONDER #ifdef MDNSRESPONDER
const bool mdns_enabled_default = true; const bool mdns_enabled_default = true;

View file

@ -96,11 +96,6 @@ extern const char* name_for_inverter_type(InverterProtocolType type) {
return nullptr; return nullptr;
} }
#ifdef COMMON_IMAGE
#ifdef SELECTED_INVERTER_CLASS
#error "Compile time SELECTED_INVERTER_CLASS should not be defined with COMMON_IMAGE"
#endif
bool setup_inverter() { bool setup_inverter() {
if (inverter) { if (inverter) {
return true; return true;
@ -205,24 +200,3 @@ bool setup_inverter() {
return false; return false;
} }
#else
bool setup_inverter() {
if (inverter) {
// The inverter is setup only once.
return true;
}
#ifdef SELECTED_INVERTER_CLASS
inverter = new SELECTED_INVERTER_CLASS();
if (inverter) {
return inverter->setup();
}
return false;
#else
return true;
#endif
}
#endif

View file

@ -7,11 +7,6 @@ extern InverterProtocol* inverter;
#include "../../USER_SETTINGS.h" #include "../../USER_SETTINGS.h"
#include "AFORE-CAN.h" #include "AFORE-CAN.h"
#ifdef BYD_CAN_DEYE
#define BYD_CAN
#endif
#include "BYD-CAN.h" #include "BYD-CAN.h"
#include "BYD-MODBUS.h" #include "BYD-MODBUS.h"
#include "FERROAMP-CAN.h" #include "FERROAMP-CAN.h"

View file

@ -28,7 +28,7 @@ monitor_speed = 115200
monitor_filters = default, time, log2file monitor_filters = default, time, log2file
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
framework = arduino framework = arduino
build_flags = -I include -DHW_LILYGO -DCOMMON_IMAGE build_flags = -I include -DHW_LILYGO
lib_deps = lib_deps =
[env:stark_330] [env:stark_330]
@ -38,17 +38,7 @@ monitor_speed = 115200
monitor_filters = default, time, log2file, esp32_exception_decoder monitor_filters = default, time, log2file, esp32_exception_decoder
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
framework = arduino framework = arduino
build_flags = -I include -DHW_STARK -DCOMMON_IMAGE build_flags = -I include -DHW_STARK
lib_deps =
[env:stark_330_debuglog]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.30/platform-espressif32.zip
board = esp32dev
monitor_speed = 115200
monitor_filters = default, time, log2file, esp32_exception_decoder
board_build.partitions = min_spiffs.csv
framework = arduino
build_flags = -I include -DHW_STARK -DCOMMON_IMAGE -DDEBUG_VIA_USB
lib_deps = lib_deps =
[env:lilygo_2CAN_330] [env:lilygo_2CAN_330]
@ -62,7 +52,6 @@ framework = arduino
build_flags = build_flags =
-I include -I include
-D HW_LILYGO2CAN -D HW_LILYGO2CAN
-D COMMON_IMAGE
-D BOARD_HAS_PSRAM -D BOARD_HAS_PSRAM
-D ARDUINO_USB_MODE=1 -D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1 ;1 is to use the USB port as a serial port -D ARDUINO_USB_CDC_ON_BOOT=1 ;1 is to use the USB port as a serial port