mirror of
https://github.com/okalachev/flix.git
synced 2026-08-16 00:38:56 +00:00
Fix power subsystem
This commit is contained in:
+6
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user