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.


  • @velox Hi there! I'm looking for a way to display a chromium window in a Tingbot app like in your demo video. Is it possible to see the code used in the video, or at least get a barebone code example of how to get a web view up on the Tingbot?



  • @khromov Hi, I'm not using a "real" tingbot app – instead I set up a "normal" raspbian on my tingbot made to work with the Tingbot display.
    It seems the instructions on how to set that up (first link in the original post) got merged with instructions on how to set up retropie, but if I remember correctly, it's mostly the "Tingbot Overlay" stuff still mentioned there.
    Maybe (untested! please only use on an installation you consider replaceable!) my ancient script on the tingbot slack still works: https://tingbot.slack.com/files/U1E85V4Q6/F2LE7Q0RX/prepare_lcd_raspbian_sh.sh

    Once that is set up, you can try the nodejs and tingbot-node installation as described on https://github.com/jgibbon/tingbot-node to get the button controls and brightness running. Test it with some of the examples on the same page and let me know if it still works.

    In the code from the video, I run chromium from node js as follows:

        this.browserProcess = childProcess.exec((isRaspbian ? 'sudo -u pi ' : '') + 'DISPLAY=:0.0 chromium-browser --kiosk --remote-debugging-port=9223 --disable-infobars --disable-session-crashed-bubble --disable-tab-switcher --disable-translate --enable-low-res-tiling ' + config.url);
    

    This translates to something like

    DISPLAY=:0.0 chromium-browser --kiosk --remote-debugging-port=9223 --disable-infobars --disable-session-crashed-bubble --disable-tab-switcher --disable-translate --enable-low-res-tiling http://www.tingbot.com
    

    when you just want to open a full screen chromium without buttons/backlight from a shell script.

    Let me know if this is actually what you want to achieve and if so, if you got this far.
    I should be able to guide you through some basic set up of the node js server next week.

    cheers!


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.