You've already forked uiflow-micropython
mirror of
https://github.com/m5stack/uiflow-micropython.git
synced 2026-05-20 10:39:27 -07:00
4b8dbf65b9
Signed-off-by: lbuque <1102390310@qq.com>
38 lines
633 B
Python
38 lines
633 B
Python
# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
from hardware import *
|
|
import time
|
|
|
|
|
|
def click_event():
|
|
print("click")
|
|
|
|
|
|
def double_click_event():
|
|
print("double_click")
|
|
|
|
|
|
def pressed_event():
|
|
print("pressed")
|
|
|
|
|
|
def released_event():
|
|
print("released")
|
|
|
|
|
|
def hold_event():
|
|
print("hold")
|
|
|
|
|
|
b = Button(1, pullup_active=False)
|
|
b.attach_click_event(click_event)
|
|
b.attach_double_click(double_click_event)
|
|
b.attach_long_press_start(pressed_event)
|
|
b.attach_long_press_stop(released_event)
|
|
b.attach_during_long_press(hold_event)
|
|
|
|
while True:
|
|
b.tick(None)
|
|
time.sleep_ms(10)
|