> require("Encoder").connect(A1,A5,function (direction) {
step += direction;
if (step >=4)
{
pos += 1;
if (pos>96) {
pos=96;
}
step=0;
print_pos();
}
if (step <=-4)
{
pos += -1;
if (pos<20) {
pos=20;
}
step=0;
print_pos();
}
});
this is my workaround for getting one count per click (probably there is a more elegant way - I am new to javascript..)
the encoders I have are the cheapest kind, but used in this way it does not seem to be any difference if I have RC filters to handle debounce or not. good to know that debouncing will be introduced in the code later on.
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.
this is my workaround for getting one count per click (probably there is a more elegant way - I am new to javascript..)
the encoders I have are the cheapest kind, but used in this way it does not seem to be any difference if I have RC filters to handle debounce or not. good to know that debouncing will be introduced in the code later on.