Thanks for posting up the C code - hopefully that'll really help some others as well.
Robin's got a good point with the 'setWatch' link - by using the data pin argument you could use a single setWatch with JS. It'll only have half the accuracy but it should be capable of going much faster than the plain JS version (not your C version).
As far as I can tell the QDEC hardware seems pretty easy to use - I'd just use the http://www.espruino.com/modules/NRF52LL.js file as a basis and fill in the registers from the datasheet.
As far as I can tell for the simplest setup you need to:
The gotcha here is you'll have to poll the reader (unless you're willing to waste 2 external pins so you can setWatch one and then use NRF52LL to toggle the pin state when an 'event' is generated from the QDEC).
Also your current solution looks like it's actually the most power efficient. I could be wrong here but it looks like QDEC doesn't use edge detection - it repeatedly polls to check the values. That means that it'll require the high speed oscillator to be left on when it runs, which will cause at least 1mA (IIRC) power drain. Your method will draw basically nothing when idle.
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.
Thanks for posting up the C code - hopefully that'll really help some others as well.
Robin's got a good point with the 'setWatch' link - by using the
data
pin argument you could use a single setWatch with JS. It'll only have half the accuracy but it should be capable of going much faster than the plain JS version (not your C version).Totally untested but:
As far as I can tell the QDEC hardware seems pretty easy to use - I'd just use the http://www.espruino.com/modules/NRF52LL.js file as a basis and fill in the registers from the datasheet.
As far as I can tell for the simplest setup you need to:
Then when you want to read:
You could also be fancy and use a new feature I added in 2v04 to access the registers as if they were variables: http://www.espruino.com/Reference#l_E_memoryMap
The gotcha here is you'll have to poll the reader (unless you're willing to waste 2 external pins so you can setWatch one and then use NRF52LL to toggle the pin state when an 'event' is generated from the QDEC).
Also your current solution looks like it's actually the most power efficient. I could be wrong here but it looks like QDEC doesn't use edge detection - it repeatedly polls to check the values. That means that it'll require the high speed oscillator to be left on when it runs, which will cause at least 1mA (IIRC) power drain. Your method will draw basically nothing when idle.