index.js
function(remoteID, keycode) {
    if (!config.opened && config.pinNumber !== null) this.open(config.pinNumber);
    if (!config.opened) throw new Error('Trying to write with no pins opened');

    debugMsg("sendButton: remoteID: " + remoteID + " keycode: " + keycode);

    // how many times to transmit a command
    for (pulse= 0; pulse <= config.repeats; pulse++) {

      sendPulse(1); // Start
      config.high = true; // first pulse is always high

      // transmit remoteID
      for (i = 15; i >= 0; i--) {
        var txPulse = remoteID & (1 << i); // read bits from remote ID
        if (txPulse > 0) {
          selectPulse(1);
        } else {
          selectPulse(0);
        }
      }

      // transmit keycode
      for (i = 6; i >= 0; i--)
      {
        var txPulse = keycode & (1 << i); // read bits from keycode
        if (txPulse > 0) {
          selectPulse(1);
        } else {
          selectPulse(0);
        }
      }
    }

    rpio.write(config.pinNumber, rpio.LOW);
  }
function(remoteID, keycode) {
    if (!config.opened && config.pinNumber !== null) this.open(config.pinNumber);
    if (!config.opened) throw new Error('Trying to write with no pins opened');

    debugMsg("sendButton: remoteID: " + remoteID + " keycode: " + keycode);

    // how many times to transmit a command
    for (pulse= 0; pulse <= config.repeats; pulse++) {

      sendPulse(1); // Start
      config.high = true; // first pulse is always high

      // transmit remoteID
      for (i = 15; i >= 0; i--) {
        var txPulse = remoteID & (1 << i); // read bits from remote ID
        if (txPulse > 0) {
          selectPulse(1);
        } else {
          selectPulse(0);
        }
      }

      // transmit keycode
      for (i = 6; i >= 0; i--)
      {
        var txPulse = keycode & (1 << i); // read bits from keycode
        if (txPulse > 0) {
          selectPulse(1);
        } else {
          selectPulse(0);
        }
      }
    }

    rpio.write(config.pinNumber, rpio.LOW);
  }
function ( remoteID , keycode ) { if ( ! config . opened && config . pinNumber !== null ) this . open ( config . pinNumber ) ; if ( ! config . opened ) throw new Error ( 'Trying to write with no pins opened' ) ; debugMsg ( "sendButton: remoteID: " + remoteID + " keycode: " + keycode ) ; // how many times to transmit a command for ( pulse = 0 ; pulse <= config . repeats ; pulse ++ ) { sendPulse ( 1 ) ; // Start config . high = true ; // first pulse is always high // transmit remoteID for ( i = 15 ; i >= 0 ; i -- ) { var txPulse = remoteID & ( 1 << i ) ; // read bits from remote ID if ( txPulse > 0 ) { selectPulse ( 1 ) ; } else { selectPulse ( 0 ) ; } } // transmit keycode for ( i = 6 ; i >= 0 ; i -- ) { var txPulse = keycode & ( 1 << i ) ; // read bits from keycode if ( txPulse > 0 ) { selectPulse ( 1 ) ; } else { selectPulse ( 0 ) ; } } } rpio . write ( config . pinNumber , rpio . LOW ) ; }
emulate key signal
emulate key signal