What is the flip1 function? Everything else looks pretty straightforward and should take a pretty normal amount of time.
When drawCompass is running slow, does it run slow every time from then on?
There is one other possibility - What is your memory usage?
When the memory gets quite full and it is fragmented, it becomes impossible to allocate a large contiguous area of memory. In this case Espruino still soldiers on and allocates arrays (eg the buffer for your offscreen graphics) split across memory - however that means that from then on every operation on that data ends up substantially slower.
So what you could do to fix this is ensure that you deallocate your old watch face before loading a new one. You could check process.memory().usage to ensure it's gone.
You could also call E.defrag() before loading the new watch face in the hope that it'd rearrange things enough that big memory areas could be allocated.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
What is the
flip1
function? Everything else looks pretty straightforward and should take a pretty normal amount of time.When
drawCompass
is running slow, does it run slow every time from then on?There is one other possibility - What is your memory usage?
When the memory gets quite full and it is fragmented, it becomes impossible to allocate a large contiguous area of memory. In this case Espruino still soldiers on and allocates arrays (eg the buffer for your offscreen graphics) split across memory - however that means that from then on every operation on that data ends up substantially slower.
So what you could do to fix this is ensure that you deallocate your old watch face before loading a new one. You could check
process.memory().usage
to ensure it's gone.You could also call
E.defrag()
before loading the new watch face in the hope that it'd rearrange things enough that big memory areas could be allocated.