Fix battery_voltage on desktop builds

This commit is contained in:
Thomas Farstrike
2025-10-09 19:19:08 +02:00
parent 498eb5b420
commit 72223b6c0b
@@ -1,4 +1,3 @@
from machine import ADC, Pin
import time
MIN_VOLTAGE = 3.15
@@ -11,8 +10,8 @@ scale_factor = 0
def init_adc(pinnr, sf):
global adc, scale_factor
try:
from machine import ADC, Pin
print(f"Initializing ADC pin {pinnr} with scale_factor {scale_factor}")
from machine import ADC, Pin # do this inside the try because it will fail on desktop
adc = ADC(Pin(pinnr))
# Set ADC to 11dB attenuation for 03.3V range (common for ESP32)
adc.atten(ADC.ATTN_11DB)