-
Tue 2019.08.20
Thank you @Jofo for the additional detail, we now may follow along more easily.
Surprised, and glad you were able to get the inline 'C' working quickly. My first attempts took me longer. Nothing appears out of the ordinary for the Javascript snippet. Proper use of setWatch() and not embedded with the setInterval() function.
This is most likely understood, so forgive me if this is too obvious. I use a technique to allow a function call in the WebIDE Left-Hand console window to stop processing as at times Ctrl+C isn't always as responsive when updating at 100msec. L9 could be modified to:
var intervalID = {}; function ci() { clearInterval( intervalID ); } L9: intervalID = setInterval(function() {
' it works if I rotate slowly (~4s per turn), but skips counts if i turn faster'
Your post reminded me of another with an encoder issue, several days ago, and a link there shows a solution Gordon proposed that should be fast enough with Javascript and setWatch() data: options attribute.
See the link 'Proper technique needed to nest a setWatch()' in #27 there
post #22 and #27 and with encoder image #30
http://forum.espruino.com/comments/14857261/'I am still interested in hardware support, maybe more power-efficient'
I'll continue to read up from your links, in the mean time I'll defer to others. . . .
To follow up, here is the inlineC version, which actually is fast enough for my purpose! I am still interested in hardware support, maybe more power-efficient or leaving cpu for other tasks, but this could be good enough anyway. Super-cool that we can combine js and c this way, so thanks for that.