• The below code (as published on espruino.com) yields:

    ERROR: INTERNAL: Timeout on SPI RX
    

    whenever the touchscreen is drawn upon.
    Have tried different setIntervals ranging from 10 to 100 touchFinc but with no change -any ideas?

    this is observed with Espruino 1v39

    var onInit = function () {
    	  SPI1.setup({sck:A5,miso:A6,mosi:A7})
    	  SPI1.send([0x90,0],A4); // just wake the controller up
    	};
    
    var touchFunc = function () {
    	  if (!digitalRead(B6)) { // touch down
    	    var d = SPI1.send([0x90,0,0xD0,0],A4);   
    	    var pos = {x:(d[1]*256+d[2])*LCD.WIDTH/0x8000, 
    	               y:(d[3]*256+d[4])*LCD.HEIGHT/0x8000};
    	    touchCallback(pos.x, pos.y);
    	    lastPos = pos;
    	  } else lastPos = null;
    	};
    
    var touchCallback = function (x,y) {
    	  if (lastPos!=null) { 
    	    LCD.drawLine(x,y,lastPos.x,lastPos.y,0xFFFF);
    	  }
    	};
    
    onInit();setInterval(touchFunc, 50);
    
About

Avatar for neil @neil started