mirror of
https://gitee.com/quecpython/helios-service.git
synced 2025-05-19 06:08:22 +08:00
30 lines
748 B
Python
30 lines
748 B
Python
from machine import Pin, ExtInt
|
|
from usr.bin.third_party.ql_interrupter import ExIntProcess, BusExIntInterrupter
|
|
import sys_bus
|
|
|
|
"======================第一种======================="
|
|
"""
|
|
可以自定义 topic
|
|
"""
|
|
extint = BusExIntInterrupter("TOPIC1", Pin.GPIO17, trige_mode=ExtInt.IRQ_RISING_FALLING, pull_mode=ExtInt.PULL_DISABLE)
|
|
|
|
|
|
def sub_cb(topic, msg):
|
|
print(topic, msg)
|
|
|
|
|
|
sys_bus.subscribe("TOPIC1", sub_cb)
|
|
|
|
"=======================第二种====================="
|
|
"""
|
|
我们固定死 topic, 按默认规则订阅即可
|
|
"""
|
|
# extint = ExIntProcess(Pin.GPIO17, trige_mode=ExtInt.IRQ_RISING_FALLING, pull_mode=ExtInt.PULL_DISABLE)
|
|
|
|
|
|
# def sub_cb(topic, msg):
|
|
# print(topic, msg)
|
|
|
|
|
|
# sys_bus.subscribe("GPIO17_EXINT", sub_cb)
|