Merge and fix conflicts

This commit is contained in:
Jaakko Haakana 2025-06-21 08:33:39 +03:00
commit d6cbd1bcdd
6 changed files with 33 additions and 58 deletions

View file

@ -102,7 +102,7 @@ void init_contactors() {
// Set all pins OFF (0% PWM)
ledcWrite(POSITIVE_CONTACTOR_PIN, PWM_OFF_DUTY);
ledcWrite(NEGATIVE_CONTACTOR_PIN, PWM_OFF_DUTY);
} else {
} else { //Normal CONTACTOR_CONTROL
pinMode(POSITIVE_CONTACTOR_PIN, OUTPUT);
set(POSITIVE_CONTACTOR_PIN, OFF);
pinMode(NEGATIVE_CONTACTOR_PIN, OUTPUT);
@ -111,33 +111,20 @@ void init_contactors() {
pinMode(PRECHARGE_PIN, OUTPUT);
set(PRECHARGE_PIN, OFF);
}
#if defined(SECOND_POSITIVE_CONTACTOR_PIN) && defined(SECOND_NEGATIVE_CONTACTOR_PIN)
if (contactor_control_enabled_double_battery) {
pinMode(SECOND_POSITIVE_CONTACTOR_PIN, OUTPUT);
set(SECOND_POSITIVE_CONTACTOR_PIN, OFF);
pinMode(SECOND_NEGATIVE_CONTACTOR_PIN, OUTPUT);
set(SECOND_NEGATIVE_CONTACTOR_PIN, OFF);
pinMode(SECOND_BATTERY_CONTACTORS_PIN, OUTPUT);
set(SECOND_BATTERY_CONTACTORS_PIN, OFF);
}
#endif
// Init BMS contactor
#if defined HW_STARK || defined HW_3LB // This hardware has dedicated pin, always enable on start
pinMode(BMS_POWER, OUTPUT); //LilyGo is omitted from this, only enabled if user selects PERIODIC_BMS_RESET
digitalWrite(BMS_POWER, HIGH);
#ifdef BMS_2_POWER //Hardware supports 2x BMS
pinMode(BMS_2_POWER, OUTPUT);
digitalWrite(BMS_2_POWER, HIGH);
#endif //BMS_2_POWER
#endif // HW with dedicated BMS pins
#ifdef BMS_POWER
if (periodic_bms_reset || remote_bms_reset) {
pinMode(BMS_POWER, OUTPUT);
digitalWrite(BMS_POWER, HIGH);
#ifdef BMS_2_POWER //Hardware supports 2x BMS
pinMode(BMS_2_POWER, OUTPUT);
digitalWrite(BMS_2_POWER, HIGH);
#endif //BMS_2_POWER
}
#endif
}
@ -266,12 +253,10 @@ void handle_contactors() {
#ifdef CONTACTOR_CONTROL_DOUBLE_BATTERY
void handle_contactors_battery2() {
if ((contactorStatus == COMPLETED) && datalayer.system.status.battery2_allowed_contactor_closing) {
set(SECOND_NEGATIVE_CONTACTOR_PIN, ON);
set(SECOND_POSITIVE_CONTACTOR_PIN, ON);
set(SECOND_BATTERY_CONTACTORS_PIN, ON);
datalayer.system.status.contactors_battery2_engaged = true;
} else { // Closing contactors on secondary battery not allowed
set(SECOND_NEGATIVE_CONTACTOR_PIN, OFF);
set(SECOND_POSITIVE_CONTACTOR_PIN, OFF);
set(SECOND_BATTERY_CONTACTORS_PIN, OFF);
datalayer.system.status.contactors_battery2_engaged = false;
}
}

View file

@ -52,11 +52,7 @@
#define NEGATIVE_CONTACTOR_PIN 33
#define PRECHARGE_PIN 25
#define BMS_POWER 2
#define SECOND_POSITIVE_CONTACTOR_PIN 13
#define SECOND_NEGATIVE_CONTACTOR_PIN 16
#define SECOND_PRECHARGE_PIN 18
#define BMS_2_POWER 12
#define SECOND_BATTERY_CONTACTORS_PIN 13
// SMA CAN contactor pins
#define INVERTER_CONTACTOR_ENABLE_PIN 36

View file

@ -50,7 +50,7 @@ The pin layout below supports the following:
#define POSITIVE_CONTACTOR_PIN GPIO_NUM_5
#define NEGATIVE_CONTACTOR_PIN GPIO_NUM_16
#define PRECHARGE_PIN GPIO_NUM_17
#define SECOND_BATTERY_CONTACTORS_PIN GPIO_NUM_32
// SMA CAN contactor pins
#define INVERTER_CONTACTOR_ENABLE_PIN GPIO_NUM_14

View file

@ -51,7 +51,8 @@
#define POSITIVE_CONTACTOR_PIN 32
#define NEGATIVE_CONTACTOR_PIN 33
#define PRECHARGE_PIN 25
#define BMS_POWER 18 // Note, this pin collides with CAN add-ons and Chademo
#define BMS_POWER 18 // Note, this pin collides with CAN add-ons and Chademo
#define SECOND_BATTERY_CONTACTORS_PIN 15 //Note, this pin collides with SD card pins
// Automatic precharging
#define HIA4V1_PIN 25

View file

@ -50,6 +50,7 @@ GPIOs on extra header
#define NEGATIVE_CONTACTOR_PIN 33
#define PRECHARGE_PIN 25
#define BMS_POWER 23
#define SECOND_BATTERY_CONTACTORS_PIN 19 //Available as extra GPIO via pin header
// Automatic precharging
#define HIA4V1_PIN 19 //Available as extra GPIO via pin header

View file

@ -1258,42 +1258,34 @@ String processor(const String& var) {
if (contactor_control_enabled) {
content += "<h4>Contactors controlled by emulator, state: ";
if (datalayer.system.status.contactors_engaged) {
if (datalayer.system.status.contactors_battery2_engaged) {
content += "<span style='color: green;'>ON</span>";
} else {
content += "<span style='color: red;'>OFF</span>";
}
content += "</h4>";
content += "<h4>Precharge: (";
content += PRECHARGE_TIME_MS;
content += " ms) Cont. Neg.: ";
if (pwm_contactor_control) {
if (datalayer.system.status.contactors_engaged) {
content += "<span style='color: green;'>Economized</span>";
content += " Cont. Pos.: ";
content += "<span style='color: green;'>Economized</span>";
} else {
content += "<span style='color: red;'>&#10005;</span>";
content += " Cont. Pos.: ";
content += "<span style='color: red;'>&#10005;</span>";
}
} else { // No PWM_CONTACTOR_CONTROL , we can read the pin and see feedback. Helpful if channel overloaded
if (digitalRead(NEGATIVE_CONTACTOR_PIN) == HIGH) {
content += "<span style='color: green;'>&#10003;</span>";
} else {
content += "<span style='color: red;'>&#10005;</span>";
}
content += " Cont. Pos.: ";
if (digitalRead(POSITIVE_CONTACTOR_PIN) == HIGH) {
content += "<span style='color: green;'>&#10003;</span>";
} else {
content += "<span style='color: red;'>&#10005;</span>";
}
if (contactor_control_enabled_double_battery) {
if (pwm_contactor_control) {
content += "<h4>Cont. Neg.: ";
if (datalayer.system.status.contactors_battery2_engaged) {
content += "<span style='color: green;'>Economized</span>";
content += " Cont. Pos.: ";
content += "<span style='color: green;'>Economized</span>";
} else {
content += "<span style='color: red;'>&#10005;</span>";
content += " Cont. Pos.: ";
content += "<span style='color: red;'>&#10005;</span>";
}
} else { // No PWM_CONTACTOR_CONTROL , we can read the pin and see feedback. Helpful if channel overloaded
content += "<h4>Cont. Neg.: ";
if (digitalRead(SECOND_BATTERY_CONTACTORS_PIN) == HIGH) {
content += "<span style='color: green;'>&#10003;</span>";
} else {
content += "<span style='color: red;'>&#10005;</span>";
}
} //no PWM_CONTACTOR_CONTROL
content += "</h4>";
}
content += "</h4>";
}
// Close the block