Fix power subsystem

This commit is contained in:
Oleg Kalachev
2026-08-15 23:14:45 +03:00
parent 6df52f1534
commit 88cdebd4ac
+6 -1
View File
@@ -18,8 +18,8 @@ float voltageScale = 2;
void setupPower() {
#ifdef ESP32
REG_CLR_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ENA); // disable reset on low voltage
#endif
if (digitalPinToAnalogChannel(voltagePin) == -1) voltagePin = -1; // test ADC pin
#endif
}
void readVoltage() {
@@ -28,6 +28,11 @@ void readVoltage() {
static Rate rate(10);
if (!rate) return;
#if defined(ESP32)
float v = analogReadMilliVolts(voltagePin) * voltageScale / 1000.0f;
#elif defined(ARDUINO_ARCH_STM32)
float v = analogRead(voltagePin) * voltageScale * 3.3f / 4095.0f;
#endif
voltage = voltageFilter.update(v);
}