mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
40 lines
481 B
Python
40 lines
481 B
Python
import machine
|
|
|
|
import PikaStdLib
|
|
|
|
pin = machine.GPIO()
|
|
rgb = machine.RGB()
|
|
mem = PikaStdLib.MemChecker()
|
|
|
|
pin.setPin('PA8')
|
|
pin.setMode('out')
|
|
pin.enable()
|
|
|
|
rgb.init()
|
|
rgb.enable()
|
|
|
|
print('task demo')
|
|
print('mem used max:')
|
|
mem.max()
|
|
|
|
|
|
def rgb_task():
|
|
rgb.flow()
|
|
mem.now()
|
|
|
|
|
|
def led_task():
|
|
if pin.read():
|
|
pin.low()
|
|
else:
|
|
pin.high()
|
|
|
|
|
|
task = machine.Task()
|
|
|
|
task.call_period_ms(rgb_task, 50)
|
|
task.call_period_ms(led_task, 500)
|
|
|
|
task.run_forever()
|
|
|