Using the Tingbot in NodeJS with tingbot-node (on Raspbian)



  • This thread is meant to discuss (and hopefully enhance) tingbot-node, my small inofficial module to listen for tingbot button presses and to set the LCD backlight brightness via NodeJS, which is currently targeted at Tingbots running Raspbian instead of it's TingbotOS flavour. I may edit/update this post when it seems like it's a good idea.

    Check out information on how to configure Raspbian on your Tingbot.

    You can find tingbot-node on github if you'd like to take a look: https://github.com/jgibbon/tingbot-node
    There's loads of Information on how to install it (along with a recent version of NodeJS) and how to use it on github as well, also there's the generated API documentation if you're into that.

    An early (a bit buggy at that point) example of what can be done with it inside a NodeJS webserver and a full screen chromium browser is here:

    I'm afraid, I'm not going to be able to release this one for licensing reasons, but may do something similar from scratch if people really like it. Sorry.

    Tell me more before I visit github!
    Sure, my pleasure. It is a small convenience library to include in your NodeJS projects. As such you can use it to control your JS application by pressing the Tingbot buttons, but it does not include any kind of GUI.

    After installing with npm install tingbot-node in your project, you can include it like this:

    var tb = require('tingbot-node');
    var tingbot = new tb();
    

    Buttons

    It emits quite a few events for button presses, for example:

    tingbot.on('button:down', function (data) { //add :down or :up to get only events you want
            console.log(data.name + ' was pressed down:', data);
    });
    

    or

    tingbot.on('button-center-left', function (data) { //single buttons have easy-to-remember names
        if (data.direction === 'up') { 
            console.log(data.name + ' released:', data);
        }
    });
    

    Backlight

    The backlight module is quite simple to use:

    //backlight off:
    tingbot.set_backlight(tingbot.backlight.min_backlight);
    //really bright:
    tingbot.set_backlight(tingbot.backlight.max_backlight);
    

    At the moment, the actual number values used are not in line with the tingbot-python api (values up to 100), but this may change in the near future.

    How to contribute

    If you want to help (really? thanks, that's awesome!) you could:

    • Tell me about bugs (raise a github issue or reply here).
    • If you're able to, even fix them (pull requests welcome).
    • Tell me if it works on TingbotOS as well… or what's missing for it to work. I have both limited time and a limited number of sd cards at my disposal, so I'm going to stick with raspbian for a while myself.
    • Just tell me if you've actually tried it, if it worked for you, what you think could be better, …
    • Show us what you've built with it.

Log in to reply

Looks like your connection to Using the Tingbot in NodeJS with tingbot-node (on Raspbian) was lost, please wait while we try to reconnect.