We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f792e45 commit 0bb7a02Copy full SHA for 0bb7a02
1 file changed
internal_filesystem/lib/mpos/battery_voltage.py
@@ -1,3 +1,4 @@
1
+from machine import ADC, Pin
2
import time
3
4
MIN_VOLTAGE = 3.15
@@ -7,14 +8,15 @@
7
8
scale_factor = 0
9
10
# This gets called by (the device-specific) boot*.py
-def init_adc(pinnr, scale_factor):
11
- global adc
+def init_adc(pinnr, sf):
12
+ global adc, scale_factor
13
try:
14
from machine import ADC, Pin
- print("Initializing ADC pin {pinnr} with scale_factor {scale_factor}")
15
+ print(f"Initializing ADC pin {pinnr} with scale_factor {scale_factor}")
16
adc = ADC(Pin(pinnr))
17
# Set ADC to 11dB attenuation for 0–3.3V range (common for ESP32)
18
adc.atten(ADC.ATTN_11DB)
19
+ scale_factor = sf
20
except Exception as e:
21
print("Info: this platform has no ADC for measuring battery voltage")
22
0 commit comments