Skip to content

Commit 658b999

Browse files
TaskManager: comments
1 parent 61ae548 commit 658b999

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal_filesystem/lib/mpos/task_manager.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ class TaskManager:
99
disabled = False
1010

1111
@classmethod
12-
async def _asyncio_thread(cls, ms_to_sleep):
12+
async def _asyncio_thread(cls, sleep_ms):
1313
print("asyncio_thread started")
1414
while cls.keep_running is True:
15-
#print(f"asyncio_thread tick because {cls.keep_running}")
16-
await asyncio.sleep_ms(ms_to_sleep) # This delay determines how quickly new tasks can be started, so keep it below human reaction speed
15+
#print(f"asyncio_thread tick because cls.keep_running:{cls.keep_running}")
16+
# According to the docs, lv.timer_handler should be called periodically, but everything seems to work fine without it.
17+
# Perhaps lvgl_micropython is doing this somehow, although I can't find it... I guess the task_handler...?
18+
# sleep_ms can't handle too big values, so limit it to 30 ms, which equals 33 fps
19+
# sleep_ms = min(lv.timer_handler(), 30) # lv.timer_handler() will return LV_NO_TIMER_READY (UINT32_MAX) if there are no running timers
20+
await asyncio.sleep_ms(sleep_ms)
1721
print("WARNING: asyncio_thread exited, now asyncio.create_task() won't work anymore")
1822

1923
@classmethod

0 commit comments

Comments
 (0)