Hi. I new in mongoose normally I develop on Particle.io it’s 100% Arduino compatible. And am not C expert I afraid to make clash on our production firmware.
This is my question..
How can I loop like Arduino Loop() I should used SW timer or HW timer ?
if I have many sensor to read I should used many timer or single timer ?
Do I have to free ram or anything I should concern about memory management ?
If anyone open for consultancy service please leave an email.
There is no “loop” like arduino - mOS is event driven.
What you can do is look at the timer callback feature.
If you wanted as tight a loop as possible you could call your “loop” function once it was complete, otherwise if you wanted a time based loop you can use the “MGOS_TIMER_REPEAT” flag.
mgos_set_timer(0, 0, loop, NULL); // call 'loop' immediately
mgos_set_timer(1000, MGOS_TIMER_REPEAT, loop, NULL); // call 'loop' every 1000 ms
I agree, my biggest hurdle coming from Arduino was trying to change my though process of how my program should execute.
Best to think about what actions/events that would cause your project to do different things. Then you can start to think about what sensor readings might trigger those events etc.