Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicroPython Cooperative Scheduler

A simple, lightweight, cooperative scheduler module designed for MicroPython.

License

Installation

Via mip

You can install this package directly onto your MicroPython device using mip:

import mip
mip.install("github:simonl65/scheduler")

Or using mpremote:

mpremote mip install github:simonl65/scheduler

Via uv / pip (For development/simulation)

For local simulation or development, you can install the package via:

uv pip install .
# or
pip install .

Usage

Define your task functions and task list, and run the scheduler loop:

from machine import Pin
from scheduler import Task, run

led = Pin("LED", Pin.OUT)

def task_led():
    led.toggle()
    print("LED toggled")

def task_sensor():
    print("Reading sensor data")

# Set up tasks with their intervals (in milliseconds)
tasks = [
    Task(task_led, interval_ms=1000),
    Task(task_sensor, interval_ms=500),
]

# Run the scheduler
# Setting light_sleep=True will sleep between task rounds to save power
scheduler = run(tasks, light_sleep=True)

while True:
    next(scheduler)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages