You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Update showbattery app
This commit is contained in:
@@ -3,15 +3,15 @@
|
||||
"publisher": "MicroPythonOS",
|
||||
"short_description": "Minimal app",
|
||||
"long_description": "Demonstrates the simplest app.",
|
||||
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.helloworld/icons/com.micropythonos.helloworld_0.0.3_64x64.png",
|
||||
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.helloworld/mpks/com.micropythonos.helloworld_0.0.3.mpk",
|
||||
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.helloworld/icons/com.micropythonos.helloworld_0.1.0_64x64.png",
|
||||
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.helloworld/mpks/com.micropythonos.helloworld_0.1.0.mpk",
|
||||
"fullname": "com.micropythonos.showbattery",
|
||||
"version": "0.0.3",
|
||||
"version": "0.1.0",
|
||||
"category": "development",
|
||||
"activities": [
|
||||
{
|
||||
"entrypoint": "assets/hello.py",
|
||||
"classname": "Hello",
|
||||
"entrypoint": "assets/show_battery.py",
|
||||
"classname": "ShowBattery",
|
||||
"intent_filters": [
|
||||
{
|
||||
"action": "main",
|
||||
|
||||
+3
-5
@@ -40,9 +40,9 @@ battery power:
|
||||
import lvgl as lv
|
||||
import time
|
||||
|
||||
from mpos import BatteryManager, Activity
|
||||
from mpos import Activity, BatteryManager
|
||||
|
||||
class Hello(Activity):
|
||||
class ShowBattery(Activity):
|
||||
|
||||
refresh_timer = None
|
||||
|
||||
@@ -60,14 +60,12 @@ class Hello(Activity):
|
||||
super().onResume(screen)
|
||||
|
||||
def update_bat(timer):
|
||||
#global l
|
||||
r = BatteryManager.read_raw_adc()
|
||||
v = BatteryManager.read_battery_voltage()
|
||||
percent = BatteryManager.get_battery_percentage()
|
||||
text = f"{time.localtime()}\n{r}\n{v}V\n{percent}%"
|
||||
#text = f"{time.localtime()}: {r}"
|
||||
print(text)
|
||||
self.update_ui_threadsafe_if_foreground(self.raw_label.set_text, text)
|
||||
self.raw_label.set_text(text)
|
||||
|
||||
self.refresh_timer = lv.timer_create(update_bat,1000,None) #.set_repeat_count(10)
|
||||
|
||||
Reference in New Issue
Block a user