Avatar for Jean-Philippe_Rey

Jean-Philippe_Rey

Member since Apr 2015 • Last active Sep 2020
  • 35 conversations
  • 268 comments

Developping IoT @ http://www.novaccess.ch , Switzerland

80% Hardware
15% Firmware
5%Software

Linkedin: linkedin.com/in/jprey
Twitter: https://twitter.com/yerpj

Most recent activity

  • in News
    Avatar for Jean-Philippe_Rey

    Welcome Christine! Good for us that you join the party!

  • in Projects
    Avatar for Jean-Philippe_Rey

    I suspect that the gamepad running the script above suffers from some delay between button press and actual action by the emulator running on my Android phone. The delay is in the order of hundreds of milliseconds....
    Could it be possible that it comes from the BLE connection interval? If so, is there any chance of decreasing this delay?

  • in Projects
    Avatar for Jean-Philippe_Rey

    BTW, here is a first picture showing my naked gamepad. The enclosure which will be 3d printed will come in the next few days

  • in Projects
    Avatar for Jean-Philippe_Rey

    OK I managed to solve my problem by calling NRF.sendHIDReportmanually.
    Now I have a first working gamepad implementation. Here is my script:

    var kb=require("ble_hid_keyboard");
    
    BTN_UP=D3;
    BTN_DN=D24;
    BTN_LEFT=D2;
    BTN_RIGHT=D22;
    BTN_B=D28;
    BTN_A=D25;
    var keys=[0,0,0,0,0,0,0,0];
    
    digitalWrite(D7,0);
    
    function onInit(){
      NRF.setServices(undefined, { hid : kb.report });
    
      setWatch("keys[2]=kb.KEY.UP;NRF.sendHIDR­eport(keys);", BTN_UP, {edge:"falling",repeat:true,debounce:50}­);
      setWatch("keys[2]=0;NRF.sendHIDReport(ke­ys);", BTN_UP, {edge:"rising",repeat:true,debounce:50})­;
    
      setWatch("keys[3]=kb.KEY.DOWN;NRF.sendHI­DReport(keys);", BTN_DN, {edge:"falling",repeat:true,debounce:50}­);
      setWatch("keys[3]=0;NRF.sendHIDReport(ke­ys);", BTN_DN, {edge:"rising",repeat:true,debounce:50})­;
    
      setWatch("keys[4]=kb.KEY.LEFT;NRF.sendHI­DReport(keys);", BTN_LEFT, {edge:"falling",repeat:true,debounce:50}­);
      setWatch("keys[4]=0;NRF.sendHIDReport(ke­ys);", BTN_LEFT, {edge:"rising",repeat:true,debounce:50})­;
    
      setWatch("keys[5]=kb.KEY.RIGHT;NRF.sendH­IDReport(keys);", BTN_RIGHT, {edge:"falling",repeat:true,debounce:50}­);
      setWatch("keys[5]=0;NRF.sendHIDReport(ke­ys);", BTN_RIGHT, {edge:"rising",repeat:true,debounce:50})­;
    
      setWatch("keys[6]=kb.KEY.BACKSPACE;NRF.s­endHIDReport(keys);", BTN_B, {edge:"falling",repeat:true,debounce:50}­);
      setWatch("keys[6]=0;NRF.sendHIDReport(ke­ys);", BTN_B, {edge:"rising",repeat:true,debounce:50})­;
    
      setWatch("keys[7]=kb.KEY.ENTER;NRF.sendH­IDReport(keys);", BTN_A, {edge:"falling",repeat:true,debounce:50}­);
      setWatch("keys[7]=0;NRF.sendHIDReport(ke­ys);", BTN_A, {edge:"rising",repeat:true,debounce:50})­;
    
      setTimeout("digitalWrite(D7,1)",200);
    }
    

    Currently I only deal with 6 buttons. This is because the HID report can handle up to 6 buttons at a time.
    I will continue to work on it for some improvements and hopefully I will come back soon with some pictures and/or videos just for your curiosity and for my pleasure ;-)

  • in Projects
    Avatar for Jean-Philippe_Rey

    OK I get it... Well this is far to much elaborated for such a basic app like mine. However it may be something useful for the metronome app . Moreover, Bangle.js and its display would be more adapted to indicate the time signature, compared to the few LEDs on the Thingy:52 :-)

  • in Projects
    Avatar for Jean-Philippe_Rey

    Well it seems the limitation comes from the module itself, in particular the method tap() which sends press and release successively...

    exports.tap = function(keyCode, modifiers, callback) {
      NRF.sendHIDReport([modifiers,0,keyCode,0­,0,0,0,0], function() {
        NRF.sendHIDReport([0,0,0,0,0,0,0,0], function() {
          if (callback) callback();
        });    
      });
    };
    
  • in Projects
    Avatar for Jean-Philippe_Rey

    It seems that I can do anything I want with the ble_hid_keyboard profile. But now I am facing another problem:
    When I press button "A", Until now I sent the character "A":
    function btnA(){kb.tap(kb.KEY.A,0);}
    What I should rather do is sending a command saying "A is pressed" or "A is released". Any idea on how to do that over HID?

  • in Porting to new Devices
    Avatar for Jean-Philippe_Rey

    I am trying to build a Gameboy-like gamepad. Ultimately I was hoping to be able to control a Gameboy emulator running on my smartphone :-) BTW there is also some discussion in this thread.

Actions