Avatar for HarryCaper

HarryCaper

Member since Aug 2019 • Last active Aug 2019
  • 0 conversations
  • 1 comments

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for HarryCaper

    Hi,
    I have a floor stand for a phone/tablet set up next to a recliner, so that I can read ebooks hands free (I have both neck and wrist joint issues from too many years of holding books in my lap to read). The problem is that the phone/tablet wobbles whenever I swipe the screen to change page. So I went looking for a simple control I could hold in my hand to turn the pages. Cue puck.js.

    It arrived this morning, and after a little hiccup I got it working. I needed to turn on location services (bluetooth was already on) on my android phone to detect the DfuTarg in order to flash the firmware.

    Then with the help of the "DIY Hands-free music control with Puck.js" YouTube video, I was able to put together the code snippet below, which on a short button press sends the right arrow key (Play Books = next page) and on a longer press sends the left arrow key (Play Books = previous page)

    And I'm in business :-)

    It seems a shame to use such a versatile device for such a simple thing, but it is going to make reading so much easier on my neck and wrists. Perhaps there are others out there who also need something to help them read hands free.

    var kb = require("ble_hid_keyboard");
    NRF.setServices(undefined, { hid : kb.report });
    
    setWatch(function(e) {
      var len = e.time - e.lastTime;
      if(len < 0.3) {
         kb.tap(kb.KEY.RIGHT, 0);
         } else {
         kb.tap(kb.KEY.LEFT,0);
    }
    }, BTN, {edge:"falling",repeat:true,debounce:50}­);
    
    
Actions