You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • Nice inline-C solution.... and it is portable between Espruino bards. Doing it with counters may not be much faster but much more complicated and keeps the processor still busy. Using the built-in QDEC spares the processor - depending how you setup the interrupts and interface with JS layer.

    To use the QDEC in poling mode - almost what you do in current solution - you can achieve with poking and and peeking. poke32() -http://www.espruino.com/Reference#l__global_poke32 - and peek32() -http://www.espruino.com/Reference#l__global_peek32 - in JavaScript give you the access to the registers... so go for it! Since it is a dedicated piece of hardware, you will not interfere with Espruiono's use of timers and interrupts.

    Looking at the power use, it is for sure much much lower than get thru the interrupt FIFO the JavaScript execution space going. It also does not / much much less compete with the interrupts other IO generate.

    Interesting to the QDEC implementation is that it already does great error detection and counting and has built in 'debounce' filtering (which btw uses timers when using debounce in setWatch().

About

Avatar for allObjects @allObjects started