• Just posted a video to YouTube of a work in progress:

    Hello, Puck! – Puck.js in 30 seconds.
    https://youtu.be/EZPnjGKtMAk

    Added this description:

    Hello, Puck! demonstrates many of the built-in features of Puck.js.
    Like Arduino, you can use Puck.js to build IoT devices. While you code
    Arduino in C++, Puck.js runs JavaScript. Like the Amazon Dash, you can
    program behaviors accessible with a single button click.

    • Web Bluetooth IDE and console • Button • RGB LEDs • Temperature
    sensor • Battery sensor • Magnetometer: movement, orientation,
    magnetism • Nearby BLE devices • Light sensor • NFC URL broadcasting
    and field detection

    Visit http://puck-js.com to learn more.

    I'm cleaning up the code and will share it here.

  • Looks great!

    Are you thinking of something like this for your idea of the pre-loaded program? I guess maybe we could think of some fun things to do with the LEDs so it can show interaction with the magnetometer even before it had a bluetooth connection.

    I wonder how hard it is to send out an IR on/off command for most common types of television set? :)

  • Yes! Maybe map Puck.mag() to HSB colors. Thanks for the motion detection code the other day. Didn't realize the magnetometer was so versatile. Sorta overlooked it at first, having only played with accelerometers and gyros.

    Will have to fork something like https://learn.adafruit.com/tv-b-gone-kit­.

  • @Gordon, I've cleaned up the code quite a bit, and created a Hello, Puck! repo on Github.

    Download and try it out. I welcome y'all's ideas!

    It has quite a few convenience functions to make it easier to use the sensors, button, and LEDs.

    The idea is, how can we make Puck.js more interesting out-of-the-box, i.e., before it's connected to the IDE.

  • Looks Great, And yes, like @Gordon said IR would be nice to have it :)

  • I just got a chance to try this - looks nice!

    I guess for something pre-installed, people won't actually see any of the text that appears (initially) - and when they get to that point they could easily have loaded up your code themselves.

    (just an aside, but if I added https://www.espruino.com/ide/#code_url_h­ere it could be really helpful for posting up code?)

    So I'm wondering what we could do 'out of the box' - when you first insert the battery and do nothing else - that would be fun, and that didn't drain the battery for those that turn the Puck on and then just leave it (including if they put it in a bag and the button kept being pressed).

    The rainbow is nice, and maybe it could detect rotation using the magnetometer.

    Perhaps it could flash out rainbow colours in 4 groups of pulses, where the number of pulses corresponded with the Puck's MAC address that was displayed when advertising?

    It'd be nice to it to be able to connect to Pucks that are very close (high signal strength) and make them flash or something - but I think in a classroom environment that would just be more annoying than anything else :)

    I guess after an hour of not being used it could just completely clear itself so it went back to not using much power?

  • I just got a chance to try this - looks nice!

    Thanks for taking a look, @Gordon!

    I guess for something pre-installed, people won't actually see any of the text that appears (initially) - and when they get to that point they could easily have loaded up your code themselves.

    True that. Still, it's nice to see something more than that red flash on battery insertion.

    (just an aside, but if I added https://www.espruino.com/ide/#code_url_h­ere it could be really helpful for posting up code?)

    I'm not sure what you mean.

    So I'm wondering what we could do 'out of the box' - when you first insert the battery and do nothing else - that would be fun, and that didn't drain the battery for those that turn the Puck on and then just leave it (including if they put it in a bag and the button kept being pressed).

    I do put a lot of stuff to sleep after 20 seconds right now, until the next button press. Maybe I could be smarter about detecting unintentional button presses. Hmm.

    The rainbow is nice, and maybe it could detect rotation using the magnetometer.

    YES. I'm totally thinking along the lines of making it more playful before connecting to an IDE. I'm going to fork this, and make something more of a game.

    Perhaps it could flash out rainbow colours in 4 groups of pulses, where the number of pulses corresponded with the Puck's MAC address that was displayed when advertising?

    Or maybe it just maps each hex digit to a hue, and does a 4-color sequence unique to that Puck. More quickly recognizable.

    It'd be nice to it to be able to connect to Pucks that are very close (high signal strength) and make them flash or something - but I think in a classroom environment that would just be more annoying than anything else :)

    I'm thinking of a separate program that enables you to select a nearby puck, and say "hi".

    I guess after an hour of not being used it could just completely clear itself so it went back to not using much power?

    Perhaps a long press of the button does a reset(). Or a long press followed by a short confirmation press. Maybe a super long press ("Help, I'm trapped under books in a backpack!") is detected and basically ignored.

  • It sounds like a few different examples could be good...

    I'm not sure what you mean.

    Click this link :) https://www.espruino.com/ide/#https://ra­w.githubusercontent.com/oesterle/hellopu­ck/master/hellopuck.js

    And it'll load your code from GitHub into the IDE. You can do it with files you upload to the forum too - I'll have to start using it more.

    I like the 4 color sequence idea - I wonder if realistically you could tell 16 shades apart, but I guess it'd be enough to tell between different Pucks.

    I'd like to ship with something that:

    • Has the 4 colors on startup (or wake up)
    • Does something fun for a few seconds while awake - maybe when it's been rotated 360 degrees (so it's calibrated) it lets you cycle through colors.
    • Goes totally to sleep unless pressed. Perhaps after half an hour it should stop advertising too - I've had a some complaints from people who've left them and then had coworkers reprogram them!

    I'm not sure if there's anything else, but it'd be nice to keep the one it comes with fun and simple. Perhaps we could even program it with that 'single button reaction tester'.

    I'm happy to implement it, but if you want to do it that'd be awesome :)

  • I'd love to contribute! Here's a test version of blinking out the address, mapping hex to hue, running on 3 Pucks:


    1 Attachment

  • Nice, thanks! How does the hue work? Blue->red rainbow colors?

    It's annoying that I don't have control of the Web Bluetooth device listing, because then I could put the 4 colors next to each Puck in the list!

  • Nice, thanks! How does the hue work? Blue->red rainbow colors?

    Yep.

    t.hexToColor = (hexChar)=> {
        var hue = parseInt(hexChar,16) / 16;
        var rgb = hueToRGB(hue);
        return rgb;
      };
    

    The colors are a nice "visual hash" of the Puck address.

    It's annoying that I don't have control of the Web Bluetooth device listing, because then I could put the 4 colors next to each Puck in the list!

    It would still be useful to find a way to put the address of the currently connected Puck in the IDE. Puck address colors would be very cool. When working with multiple Pucks (I got your 5-pack on Kickstarter), I lose track of which one is connected in the IDE.

  • Ahh, good point. I added a 'connection type' in the bottom right recently, so with a bit of hacking it could hopefully display the device name there.

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

Hello, Puck! – Puck.js in 30 seconds (video, github repo)

Posted by Avatar for oesterle @oesterle

Actions