Skip to content

Commit 72223b6

Browse files
Fix battery_voltage on desktop builds
1 parent 498eb5b commit 72223b6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

internal_filesystem/lib/mpos/battery_voltage.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from machine import ADC, Pin
21
import time
32

43
MIN_VOLTAGE = 3.15
@@ -11,8 +10,8 @@
1110
def init_adc(pinnr, sf):
1211
global adc, scale_factor
1312
try:
14-
from machine import ADC, Pin
1513
print(f"Initializing ADC pin {pinnr} with scale_factor {scale_factor}")
14+
from machine import ADC, Pin # do this inside the try because it will fail on desktop
1615
adc = ADC(Pin(pinnr))
1716
# Set ADC to 11dB attenuation for 0–3.3V range (common for ESP32)
1817
adc.atten(ADC.ATTN_11DB)

0 commit comments

Comments
 (0)