added cpu_f

This commit is contained in:
Luxferre
2025-12-23 22:02:44 +02:00
parent c95c1dd702
commit 67e906bb19
3 changed files with 10 additions and 2 deletions
+1
View File
@@ -106,6 +106,7 @@ Exports the following functions:
- `board_id()`: get the board ID (e.g. `lilygo_tdeck` for T-Deck/T-Deck Plus), or `emulated` if it's not run on a CircuitPython device
- `battery_v()`: (T-Deck-specific) get the current battery voltage (or 0 if running in an emulated environment)
- `cpu_f()`: CPU frequency in Hertz
Also, this module exposes the `REAL_HW` variable to detect whether the code is running on a real hardware in the CircuitPython environment.
+8 -1
View File
@@ -2,7 +2,7 @@
REAL_HW = False
try:
import board, analogio
import board, analogio, microcontroller
vbat_analog = analogio.AnalogIn(board.BAT_ADC)
REAL_HW = True
except:
@@ -19,5 +19,12 @@ def board_id():
def battery_v():
if REAL_HW:
return (vbat_analog.value * 3.3) / 65535 * 2
else:
return 0.0
# get CPU frequency
def cpu_f():
if REAL_HW:
return microcontroller.cpu.frequency
else:
return 0
+1 -1
View File
@@ -8,7 +8,7 @@ from deck.fs import du, df, sep, pwd, ls, md, cd, rd, rm, mv, cp, sync
from deck.input import input, input_multi
from deck.pager import print_paged, term_size
from deck.time import *
from deck.hwinfo import board_id, battery_v, REAL_HW
from deck.hwinfo import board_id, battery_v, cpu_f, REAL_HW
from deck.http import wget, http_fetch, http_set_ua
from app.ed import edit, view
try: