Skip to content

Commit 0bb7a02

Browse files
Fix battery_voltage readout scale_factor handling
1 parent f792e45 commit 0bb7a02

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal_filesystem/lib/mpos/battery_voltage.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from machine import ADC, Pin
12
import time
23

34
MIN_VOLTAGE = 3.15
@@ -7,14 +8,15 @@
78
scale_factor = 0
89

910
# This gets called by (the device-specific) boot*.py
10-
def init_adc(pinnr, scale_factor):
11-
global adc
11+
def init_adc(pinnr, sf):
12+
global adc, scale_factor
1213
try:
1314
from machine import ADC, Pin
14-
print("Initializing ADC pin {pinnr} with scale_factor {scale_factor}")
15+
print(f"Initializing ADC pin {pinnr} with scale_factor {scale_factor}")
1516
adc = ADC(Pin(pinnr))
1617
# Set ADC to 11dB attenuation for 0–3.3V range (common for ESP32)
1718
adc.atten(ADC.ATTN_11DB)
19+
scale_factor = sf
1820
except Exception as e:
1921
print("Info: this platform has no ADC for measuring battery voltage")
2022

0 commit comments

Comments
 (0)