Turn your Puck.js into a PowerPoint presenter!

Posted on
  • You can find the code on my gitHub.

    You can also read about my reason for building this in the Medium article I posted.

  • I had some ideas for improving the robustness of your code, and forked your gist.

    • Ensure BLE is turned on when Puck is powered on or battery is replaced.
    • Ensure mag turning off doesn’t happen in the middle of presenting.
    • Puck.magOn() doesn’t return a Boolean to check if on/off; added code to
      fix this.
    • Simplified character sending code to remove duplicate code.
    • Added catchy keyboard Bluetooth device name. :-)

    Feel free to incorporate the changes into your code.


    1 Attachment

    • Screen Shot 2017-03-16 at 5.40.55 PM.png
  • Nice, thanks for posting up! Nice article.

    @oesterle's tweaks look really good.

    Just to add though:

    • Web IDE - where did you actually hit that bug? Was it on https://www.espruino.com/ide/ or had you tried to get it running directly from GitHub? Also, the way the IDE's designed that shouldn't have actually stopped it from working - it just disabled the one plugin.
    • Your issue with setWatch is you're getting a callback when the button is pressed, and you're then checking against the time it was previously released. You're actually looking at the amount of time the button has been released for, rather than how long it was pressed. If you change rising to falling it'll work great.
    • With the magnetometer I'd check against mag.x>100 or something. In a lot of cases, just rotating the Puck could cause the earth's magnetic field to change the measurement so x flipped sign - last thing you want is to randomly go one slide back :)
  • @oesterle, this is awesome! Happy folks are getting inspired by my "first ever code for hardware", and will certainly include the changes (after I am back from my holiday) in my gist, crediting you. The beauty of collaborative code: we all get a slice of a really good Pi(e)! :)

    @Gordon those suggestions are worth billions! I wish both you and @oesterle could share the resources you used for finding some of the information you mentioned or implemented. I find the docs very "all over the place" and uninviting or maybe I am used to more verbose docs like jQuery, Angular, Ionic or Node's documentation. That bit about the magnetic field changing, that's interesting. I was somewhat worried that might actually happen at some point, but since it never did so far, I assumed I was seeing trouble where there wasn't any.

    I will have to try the falling bit out, it would save me the need to rely on the magnetometer altogether which while a cool effect, is a less desirable solution.

    The IDE issue I faced both online and the GitHub version (I have it installed locally as well). In hindsight it may have not been what prevented my puck working - as eventually I did restart the machine at some point, but not knowing how the IDE code works and what's needed for things to run, that syntax error was staring me too much in the face. Probably a coincidence that after it got fixed my IDE started working too. On that note however, connecting to the Puck is still a hit and miss, and if I want to be certain it starts and connects to the IDE, I need to restart my Mac. Removing and adding it again, does not help. I believe this has been documented before.

  • I find the docs very "all over the place" and uninviting

    The search bar on espruino.com is definitely your friend. I wish we could do better but there's a lot of information to get across for a lot of different boards, and not all of it is directly related to functions (like jQuery/etc).

    If you do find things that could be improved it'd be great if you could issue a PR or at least give a prod. Especially on http://www.espruino.com/Reference if you want to update docs for a function, click the character after the function's title - it'll bring you to the area of code where the documentation for the function is, and it's easy enough to tweak it there :)

    and if I want to be certain to starts and connects to the IDE, I need to restart my Mac.

    aha - have you seen this: http://www.espruino.com/Puck.js#i-can-t-­reconnect-to-my-puck-js-on-mac-os

    The issue seems to be that Puck.js can't handle multiple connections, so doesn't advertise when it's connected. If you've set it up as a BLE HID device then the Mac automatically connects, and so stops the Web IDE from connecting too :) I think Google might be fixing it in a Chrome update (so chrome shows you devices you're already connected to) but I doubt it's hit mainstream yet.

    Also, if you haven't updated your firmware yet then the firmware Puck.js ships with can be a bit hit and miss to connect to on some devices as well.

  • @Gordon, @oesterle, both of you, thanks again for your suggestions. Truly invaluable!

    I've updated the article to reflect the code changes and added a second implementation that uses the short/long button press approach I initially thought was wrong.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Turn your Puck.js into a PowerPoint presenter!

Posted by Avatar for attilavago @attilavago

Actions