Callback functions


To use the timer’s callback function, in the example it says you can not use functions that allocate memory in these callbacks.
So this means it is not possible to use the TF person detection code inside a callback function? I have tried this and it has worked. But not always, it can also shut down the camera and disconnect.
Is there anyway to use a timer to trigger other events then the callback function?

You can just set a flag and check in the main loop if that flag is set, run the person detection and clear the flag.

Yhea did that now. Can you explain why you can’t do anything memory allocating in the timer callback?

Thanks for the answer

It had something to do with MicroPython’s garbage collector being locked in IRQs I think, maybe it’s not thread-safe, can’t really remember the exact issue but it’s not allowed.