5956 views|18 replies

1w

Posts

25

Resources
The OP
 

MicroPython simple task scheduler [Copy link]

 
 

MicroPython simple task scheduler is mainly used in some tasks that need to be executed periodically. You can define multiple different tasks, each with a different period.

MicroPython simple task scheduler currently has two versions, one using timer and one using asyncio. The two versions have the same basic usage, but the asynchronous version has fewer functions.

Basic usage:

  1. Defining tasks
  2. Adding tasks to the scheduler
  3. Run Scheduler

Routine:

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()

website:

游客,如果您要查看本帖隐藏内容请回复

Latest reply

This is very good, I collected it   Details Published on 2021-12-2 15:07
 
 

685

Posts

0

Resources
2
 

Multithreading would be better.

Comments

The current multithreading is not perfect, has not been updated for a long time, and takes up a lot of memory.  Details Published on 2020-12-10 16:41
 
 
 

1w

Posts

25

Resources
3
 
Extreme Zero published on 2020-12-10 13:07 It would be better if it was multi-threaded

The current multithreading is not perfect, has not been updated for a long time, and takes up a lot of memory.

 
 
 

62

Posts

0

Resources
4
 

Just started to contact this

 
 
 

128

Posts

0

Resources
5
 

You must learn this well.

 
 
 

7422

Posts

2

Resources
6
 

Does this mean that mpy can only do large loops now?

Comments

Can be used in loops, timers, asynchronous, etc.  Details Published on 2020-12-15 23:56
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

1w

Posts

25

Resources
7
 
freebsder posted on 2020-12-15 18:33 Does this mean that mpy can only do large loops now?

Can be used in loops, timers, asynchronous, etc.

Comments

The model is too abstract and not suitable for embedding.  Details Published on 2020-12-16 21:10
 
 
 

7422

Posts

2

Resources
8
 
dcexpert posted on 2020-12-15 23:56 You can use loops, timers, asynchronous methods, etc.

The model is too abstract and not suitable for embedding.

Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

375

Posts

0

Resources
9
 

Study

 
 
 

4

Posts

0

Resources
10
 
Follow
 
 
 

1

Posts

0

Resources
11
 
ddddddd
 
 
 

19

Posts

0

Resources
12
 

Passing by, learning

 
 
 

1

Posts

0

Resources
13
 

Hello! Come and learn

 
 
 

4

Posts

2

Resources
14
 

Thank you for sharing

 
 
 

5

Posts

0

Resources
15
 

Loud nbnb

 
 
 

2

Posts

0

Resources
16
 

Thank you, the host is a good person

 
 
 

64

Posts

0

Resources
17
 

Learn

 
 
 

1

Posts

0

Resources
18
 

Learn about task scheduling

 
 
 

53

Posts

0

Resources
19
 

This is very good, I collected it

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list