You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Add com.example.draw
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "CPU Tester",
|
||||
"publisher": "ACME Inc",
|
||||
"short_description": "Testing the CPU speed",
|
||||
"long_description": "Experimentally determines how many idle loops and sha256-hashing loops the CPU can perform per second.",
|
||||
"icon_url": "http://demo.lnpiggy.com:2121/apps/com.example.cputest_0.0.1.mpk_icon_64x64.png",
|
||||
"download_url": "http://demo.lnpiggy.com:2121/apps/com.example.cputest_0.0.1.mpk",
|
||||
"fullname": "com.example.cputest",
|
||||
"version": "0.0.1",
|
||||
"entrypoint": "assets/cputest.py",
|
||||
"category": "benchmarking"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
appscreen = lv.screen_active()
|
||||
|
||||
import lvgl as lv
|
||||
|
||||
class DrawApp:
|
||||
def __init__(self):
|
||||
self.canvas = None
|
||||
self.init_gui()
|
||||
def init_gui(self):
|
||||
self.canvas = lv.canvas(lv.screen_active())
|
||||
disp = lv.display_get_default()
|
||||
self.canvas.set_size(disp.get_hor_res(), disp.get_ver_res())
|
||||
self.canvas.set_style_bg_color(lv.color_white(), 0)
|
||||
buffer = bytearray(disp.get_hor_res() * disp.get_ver_res() * 4)
|
||||
self.canvas.set_buffer(buffer, disp.get_hor_res(), disp.get_ver_res(), lv.COLOR_FORMAT.NATIVE)
|
||||
self.canvas.fill_bg(lv.color_white(), lv.OPA.COVER)
|
||||
self.canvas.add_event_cb(self.touch_cb, lv.EVENT.PRESSING, None)
|
||||
def touch_cb(self, obj, event, user_data):
|
||||
if event == lv.EVENT.PRESSING:
|
||||
indev = lv.indev_active()
|
||||
if indev:
|
||||
point = indev.get_point()
|
||||
x, y = point.x, point.y
|
||||
self.canvas.draw_arc(x, y, 5, 0, 360, lv.color_black())
|
||||
|
||||
draw_app = DrawApp()
|
||||
|
||||
# Wait until the user closes the app
|
||||
while appscreen == lv.screen_active():
|
||||
time.sleep_ms(1000)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.0 KiB |
Reference in New Issue
Block a user