Close

"Wish" style API

A project log for Mayak

Handheld E-ink pocket PC on Arduino

sergeySergey 12/30/2017 at 13:040 Comments

Due to "Low power" project priority, I start to change all code of subsystems to "Wish" style. This style need me to write application in certain style. 

Any API request can be executed momentarily, delayed or even never. So any application must check all and work in "state" patterns style.

Let's see in example on VectorMaps application. 

1.We look have we fresh coords or not. For me, I decide that coords with 2-3 min - still pretty fresh and we dont need to power on GPS for getting more actual coords. And if its not so fresh - we call "updateCoords" fucntion and set wish to work again for "task switcher" for 20 secs. Then we return execution from application to "task switcher".

2. After 20 secs (or more if we sleep due to low voltage) application start again check for fresh coords. This cycle can repeat forever until application got fresh coords or we can add return to main menu after 2-3 tries for battery save. 

This "wish" style api help to create a very similar to "tickless" work mode for Mayak. When we wait for GPS coords - MCU sleep, when we updated it, GPS sleep :).

Discussions