Minimize usage of build-time DOUBLE_BATTERY

This commit is contained in:
Jaakko Haakana 2025-06-01 18:54:09 +03:00
parent 17a22dc59d
commit 8cb4884af7
7 changed files with 9 additions and 28 deletions

View file

@ -255,10 +255,11 @@ void core_loop(void*) {
#endif #endif
update_pause_state(); // Check if we are OK to send CAN or need to pause update_pause_state(); // Check if we are OK to send CAN or need to pause
update_values_battery(); // Fetch battery values update_values_battery(); // Fetch battery values
#ifdef DOUBLE_BATTERY
update_values_battery2(); if (battery2) {
check_interconnect_available(); update_values_battery2();
#endif // DOUBLE_BATTERY check_interconnect_available();
}
update_calculated_values(); update_calculated_values();
update_machineryprotection(); // Check safeties update_machineryprotection(); // Check safeties
update_values_inverter(); // Update values heading towards inverter update_values_inverter(); // Update values heading towards inverter

View file

@ -50,16 +50,15 @@ void update_values_battery() {
void transmit_can_battery(unsigned long currentMillis) { void transmit_can_battery(unsigned long currentMillis) {
((CanBattery*)battery)->transmit_can(currentMillis); ((CanBattery*)battery)->transmit_can(currentMillis);
#ifdef DOUBLE_BATTERY if (battery2) {
((CanBattery*)battery2)->transmit_can(currentMillis); ((CanBattery*)battery2)->transmit_can(currentMillis);
#endif }
} }
void handle_incoming_can_frame_battery(CAN_frame rx_frame) { void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
((CanBattery*)battery)->handle_incoming_can_frame(rx_frame); ((CanBattery*)battery)->handle_incoming_can_frame(rx_frame);
} }
#ifdef DOUBLE_BATTERY
void update_values_battery2() { void update_values_battery2() {
battery2->update_values(); battery2->update_values();
} }
@ -67,7 +66,6 @@ void update_values_battery2() {
void handle_incoming_can_frame_battery2(CAN_frame rx_frame) { void handle_incoming_can_frame_battery2(CAN_frame rx_frame) {
((CanBattery*)battery2)->handle_incoming_can_frame(rx_frame); ((CanBattery*)battery2)->handle_incoming_can_frame(rx_frame);
} }
#endif
#ifdef RS485_BATTERY_SELECTED #ifdef RS485_BATTERY_SELECTED
void transmit_rs485() { void transmit_rs485() {

View file

@ -325,10 +325,8 @@ void map_can_frame_to_variable(CAN_frame* rx_frame, int interface) {
map_can_frame_to_variable_inverter(*rx_frame); map_can_frame_to_variable_inverter(*rx_frame);
#endif #endif
} }
if (interface == can_config.battery_double) { if (interface == can_config.battery_double && battery2) {
#ifdef DOUBLE_BATTERY
handle_incoming_can_frame_battery2(*rx_frame); handle_incoming_can_frame_battery2(*rx_frame);
#endif
} }
if (interface == can_config.charger && charger) { if (interface == can_config.charger && charger) {
charger->map_can_frame_to_variable(*rx_frame); charger->map_can_frame_to_variable(*rx_frame);

View file

@ -79,12 +79,8 @@
#define EQUIPMENT_STOP_PIN 35 #define EQUIPMENT_STOP_PIN 35
// BMW_I3_BATTERY wake up pin // BMW_I3_BATTERY wake up pin
#ifdef BMW_I3_BATTERY
#define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1 #define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1
#ifdef DOUBLE_BATTERY
#define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2 #define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2
#endif // DOUBLE_BATTERY
#endif // BMW_I3_BATTERY
/* ----- Error checks below, don't change (can't be moved to separate file) ----- */ /* ----- Error checks below, don't change (can't be moved to separate file) ----- */
#ifndef HW_CONFIGURED #ifndef HW_CONFIGURED

View file

@ -67,12 +67,8 @@ The pin layout below supports the following:
#define INVERTER_DISCONNECT_CONTACTOR_PIN GPIO_NUM_5 #define INVERTER_DISCONNECT_CONTACTOR_PIN GPIO_NUM_5
// BMW_I3_BATTERY wake up pin // BMW_I3_BATTERY wake up pin
#ifdef BMW_I3_BATTERY
#define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1 #define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1
#ifdef DOUBLE_BATTERY
#define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2 #define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2
#endif // DOUBLE_BATTERY
#endif // BMW_I3_BATTERY
/* ----- Error checks below, don't change (can't be moved to separate file) ----- */ /* ----- Error checks below, don't change (can't be moved to separate file) ----- */
#ifndef HW_CONFIGURED #ifndef HW_CONFIGURED

View file

@ -74,12 +74,8 @@
#define EQUIPMENT_STOP_PIN 35 #define EQUIPMENT_STOP_PIN 35
// BMW_I3_BATTERY wake up pin // BMW_I3_BATTERY wake up pin
#ifdef BMW_I3_BATTERY
#define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1 #define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1
#ifdef DOUBLE_BATTERY
#define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2 #define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2
#endif // DOUBLE_BATTERY
#endif // BMW_I3_BATTERY
/* ----- Error checks below, don't change (can't be moved to separate file) ----- */ /* ----- Error checks below, don't change (can't be moved to separate file) ----- */
#ifndef HW_CONFIGURED #ifndef HW_CONFIGURED

View file

@ -66,12 +66,8 @@ GPIOs on extra header
#define EQUIPMENT_STOP_PIN 2 #define EQUIPMENT_STOP_PIN 2
// BMW_I3_BATTERY wake up pin // BMW_I3_BATTERY wake up pin
#ifdef BMW_I3_BATTERY
#define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1 #define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1
#ifdef DOUBLE_BATTERY
#define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2 #define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2
#endif // DOUBLE_BATTERY
#endif // BMW_I3_BATTERY
/* ----- Error checks below, don't change (can't be moved to separate file) ----- */ /* ----- Error checks below, don't change (can't be moved to separate file) ----- */
#ifndef HW_CONFIGURED #ifndef HW_CONFIGURED