FIx battery quirks
This commit is contained in:
@@ -36,14 +36,15 @@ void updateBattery() {
|
||||
ChargeStatus status = chg ? (pct >= 99 ? CHGSTAT_FULL : CHGSTAT_CHARGING) : CHGSTAT_DISCHARGING;
|
||||
// Only write BLE Battery Service when connected - blebas.write() blocks on the
|
||||
// SoftDevice ATT layer and causes 30-40ms loop stalls when called during advertising.
|
||||
if (Bluefruit.connected()) blebas.write(pct);
|
||||
if (Bluefruit.connected()) blebas.notify(pct);
|
||||
lastChargeStatus = status;
|
||||
#ifdef FEATURE_TELEMETRY
|
||||
telem.chargeStatus = (uint8_t)status;
|
||||
#endif
|
||||
const char* st[] = {"discharging","charging","full"};
|
||||
Serial.print("[BATT] "); Serial.print(v,2); Serial.print("V ");
|
||||
Serial.print(pct); Serial.print("% "); Serial.println(st[status]);
|
||||
Serial.print(pct); Serial.print("% "); Serial.print(st[status]);
|
||||
Serial.print(" (PIN_CHG="); Serial.print(digitalRead(PIN_CHG)); Serial.println(")");
|
||||
// Critical battery alert - only blink when not connected to avoid blocking BLE scheduler.
|
||||
// 6 × 160ms = 960ms hard block; skip during active connection.
|
||||
if (status == CHGSTAT_DISCHARGING && v < BATT_CRITICAL && !Bluefruit.connected())
|
||||
|
||||
Reference in New Issue
Block a user