Working v1

This commit is contained in:
2026-03-21 00:37:30 -05:00
parent 062984275e
commit 43db9b97dd
4 changed files with 10 additions and 3 deletions

View File

@@ -57,7 +57,7 @@ void pm_init() {
}
extern "C" void app_main() {
// pm_init();
pm_init();
mainApp();
// servo_test();
}

View File

@@ -9,6 +9,7 @@
#include "socketIO.hpp"
#include "max17048.h"
#include "esp_sleep.h"
#include "defines.h"
// Give C linkage so max17048.c (a C translation unit) can link against these
extern "C" {
@@ -68,6 +69,8 @@ bool postServoPos(uint8_t currentAppPos) {
cJSON_Delete(response);
if (awaitCalib) {
gpio_set_level(debugLED, 1); // Start with LED off
gpio_hold_en(debugLED);
Calibration::clearCalibrated();
if (!calibrate()) {
if (!WiFi::attemptDHCPrenewal())
@@ -77,6 +80,8 @@ bool postServoPos(uint8_t currentAppPos) {
setupAndCalibrate();
}
}
gpio_hold_dis(debugLED);
gpio_set_level(debugLED, 0);
}
}
return success;
@@ -201,7 +206,7 @@ void mainEventLoop() {
postBatteryAlert(alertType, established_soc);
printf("CRITICAL BATTERY EVENT (%s, SOC=%d%%). Entering deep sleep.\n",
battAlertTypeStr(alertType), established_soc);
// esp_deep_sleep_start();
esp_deep_sleep_start();
} else if (received_event_type == EVENT_BATTERY_WARNING) {
postBatteryAlert((batt_alert_type_t)bms_pending_alert, established_soc);

View File

@@ -91,7 +91,7 @@ void bms_checker_task(void *pvParameters) {
main_event_type_t evt;
if ((status & VHbit) || (status & HDbit) || ((status & VLbit) && soc < SOC_CRITICAL_VL)) {
if ((status & HDbit) || ((status & VLbit) && soc < SOC_CRITICAL_VL)) {
// Critical: overvoltage (hardware fault) or battery truly empty
bms_pending_alert = (status & VHbit) ? BATT_ALERT_OVERVOLTAGE : BATT_ALERT_CRITICAL_LOW;
evt = EVENT_BATTERY_CRITICAL;

View File

@@ -23,6 +23,7 @@ void setupAndCalibrate() {
gpio_reset_pin(debugLED);
gpio_set_direction(debugLED, GPIO_MODE_OUTPUT);
gpio_set_level(debugLED, 1); // Start with LED off
gpio_hold_en(debugLED);
while (1) {
setupLoop();
if (awaitCalibration) {
@@ -30,6 +31,7 @@ void setupAndCalibrate() {
}
else break;
}
gpio_hold_dis(debugLED);
gpio_set_level(debugLED, 0); // Start with LED off
}