You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Wow, that looks great!

    have you met this issue before with the ILI9431 and XPT2046?

    I don't think so, no. Whenever I used it they were on separate busses.

    rotary controller does two increments every click

    Have you seen setWatch has a data argument? I guess it might work just to use that with a debounce. I guess a falling edge when data=0 is one way, falling with data=1 is another?

  • Yes, some of those options might help, however, the code below proved the simplest most reliable driver.

    
    function createEncoder(pinA,pinB){
      pinMode(pinA,"input_pullup");
      pinMode(pinB,"input_pullup"); 
      var a0=pinA.read(), c0=pinB.read(), incr0 =0, second=false;
      var OBJ = {};
    
     function handler () {
       var a = pinA.read();
       var b = pinB.read();
       if (a != a0) {              // A changed
         a0 = a;
         if (b != c0) {
           c0 = b;
           var incr = (a == b)?-1:1;
           if (incr!=incr0 || !second) OBJ.emit("change",incr);
           incr0=incr; second = !second;
         }
       }
     }
     setWatch(handler,pinA,{repeat:true,edge:­"both"});
     return OBJ;
    }
    
    
About

Avatar for Gordon @Gordon started