added cpu_f
This commit is contained in:
@@ -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
|
- `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)
|
- `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.
|
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
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
REAL_HW = False
|
REAL_HW = False
|
||||||
try:
|
try:
|
||||||
import board, analogio
|
import board, analogio, microcontroller
|
||||||
vbat_analog = analogio.AnalogIn(board.BAT_ADC)
|
vbat_analog = analogio.AnalogIn(board.BAT_ADC)
|
||||||
REAL_HW = True
|
REAL_HW = True
|
||||||
except:
|
except:
|
||||||
@@ -19,5 +19,12 @@ def board_id():
|
|||||||
def battery_v():
|
def battery_v():
|
||||||
if REAL_HW:
|
if REAL_HW:
|
||||||
return (vbat_analog.value * 3.3) / 65535 * 2
|
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:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
+1
-1
@@ -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.input import input, input_multi
|
||||||
from deck.pager import print_paged, term_size
|
from deck.pager import print_paged, term_size
|
||||||
from deck.time import *
|
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 deck.http import wget, http_fetch, http_set_ua
|
||||||
from app.ed import edit, view
|
from app.ed import edit, view
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user