Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb44720c

Browse files
Make battery voltage pin handling generic
1 parent9f4e201 commitb44720c

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

‎internal_filesystem/boot.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,8 @@
8282
lv.init()
8383
display.set_rotation(lv.DISPLAY_ROTATION._90)# must be done after initializing display and creating the touch drivers, to ensure proper handling
8484

85+
# Battery voltage ADC measuring
86+
importmpos.battery_voltage
87+
mpos.battery_voltage.init_adc(5)
88+
8589
print("boot.py finished")

‎internal_filesystem/boot_fri3d-2024.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,8 @@ def keypad_read_cb(indev, data):
214214
indev.set_display(disp)# different from display
215215
indev.enable(True)# NOQA
216216

217+
# Battery voltage ADC measuring
218+
importmpos.battery_voltage
219+
mpos.battery_voltage.init_adc(13)
220+
217221
print("boot.py finished")

‎internal_filesystem/lib/mpos/battery_voltage.py‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1+
adc=None
12
have_adc=True
2-
try:
3-
frommachineimportADC,Pin
4-
# Configure ADC on pin 5 (IO5 / BAT_ADC)
5-
#adc = ADC(Pin(5)) # TouchColorPiggy
6-
adc=ADC(Pin(13))# fri3d-2024
7-
# Set ADC to 11dB attenuation for 0–3.3V range (common for ESP32)
8-
adc.atten(ADC.ATTN_11DB)
9-
exceptExceptionase:
10-
print("Info: this platform has no ADC for measuring battery voltage")
11-
have_adc=False
3+
4+
# This gets called by (the device-specific) boot*.py
5+
definit_adc(pinnr):
6+
globaladc
7+
try:
8+
frommachineimportADC,Pin
9+
print("setting adc")
10+
adc=ADC(Pin(pinnr))
11+
print("adc set")
12+
# Set ADC to 11dB attenuation for 0–3.3V range (common for ESP32)
13+
adc.atten(ADC.ATTN_11DB)
14+
exceptExceptionase:
15+
print("Info: this platform has no ADC for measuring battery voltage")
16+
have_adc=False
1217

1318
importtime
1419

‎internal_filesystem/lib/mpos/ui/__init__.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
importlvglaslv
22
importmpos.apps
3-
importmpos.battery_voltage
43
importmpos.time
54
importmpos.wifi
65
frommpos.ui.animimportWidgetAnimator

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp