• The modifications to the above to get it to work with MPR121 - put the following into onInit()

    SCL=D15;
    SDA=D14;
    IRQ=D16;
    
    I2C1.setup({scl:SCL,sda:SDA});
    
    sensor = require("MPR121").connect(I2C1, function() {});
    
    // Function to be called when MPR121 notifies us of change
    setWatch(function(e) {
        var value = sensor.touched() & 0x0f; // Filter out other inputs
        if (value==0) { // All buttons up: Emit the key
          emitkey(state);
          state='_';
        }
    // Buttons map to MP121 inputs 0,1,2,3 -> bits 1,2,4,8
        if (value==1) keydown(0);
        if (value==2) keydown(1);
        if (value==4) keydown(2);
        if (value==8) keydown(3);
    
    }, IRQ, {edge: 'falling', repeat: true});
    
About

Avatar for ColinP @ColinP started