https://github.com/micropython-chinese-community/micropython-simple-scheduler
micropython simple scheduler
https://github.com/micropython-chinese-community/micropython-simple-scheduler
Last synced: 10 months ago
JSON representation
micropython simple scheduler
- Host: GitHub
- URL: https://github.com/micropython-chinese-community/micropython-simple-scheduler
- Owner: micropython-Chinese-Community
- License: mit
- Created: 2020-12-09T01:24:18.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-23T13:31:16.000Z (over 5 years ago)
- Last Synced: 2025-03-16T23:42:42.377Z (over 1 year ago)
- Language: Python
- Size: 4.88 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# micropython-simple-scheduler
Simple task scheduler for micropython.
- [time base version scheduler](tmScheduler)
- [asyncio version scheduler](asScheduler)
## uasge
1. define user function.
2. define task.
3. add tasks to scheduler.
4. run scheduler.
```
from scheduler import Scheduler, Task
import machine
def LED():
pyb.LED(1).toggle()
def pn(n):
print(n)
task1 = Task(LED, None, 1000)
task2 = Task(pn, 1, 1000)
task3 = Task(pn, 2, 1500)
sc = Scheduler(machine.Timer(-1))
sc.add(task1)
sc.add(task2)
sc.add(task3)
sc.scheduler()
```