Advertisement
Guest User

Node-RED Tutorial and Example

a guest
Jul 9th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 26.12 KB | None | 0 0
  1. [{"id":"7a5f99cc.a7f8b8","type":"tab","label":"Tutorial Website","disabled":false,"info":""},{"id":"4e9db622.1152a8","type":"tab","label":"Chatroom Demo","disabled":false,"info":""},{"id":"b06baa9b.a99ea8","type":"tab","label":"Testing","disabled":true,"info":""},{"id":"d146301b.a5a96","type":"websocket-listener","z":"","path":"/chatroomws","wholemsg":"false"},{"id":"fc8ae346.214ce","type":"websocket-listener","z":"","path":"demo_gpio_ws","wholemsg":"false"},{"id":"d768110b.70459","type":"websocket-listener","z":"","path":"demochatws","wholemsg":"false"},{"id":"14c76729.b10589","type":"websocket in","z":"4e9db622.1152a8","name":"/chatroomws","server":"d768110b.70459","client":"","x":150,"y":640,"wires":[["f8789ed2.f09b3"]]},{"id":"5e2c262a.701168","type":"websocket out","z":"4e9db622.1152a8","name":"/ws out","server":"d146301b.a5a96","client":"","x":840,"y":640,"wires":[]},{"id":"c46f70fd.f618b","type":"http in","z":"4e9db622.1152a8","name":"/demo/chat","url":"/demo/chat","method":"get","upload":false,"swaggerDoc":"","x":140,"y":300,"wires":[["4d738bf.bb4fe74"]]},{"id":"4d738bf.bb4fe74","type":"template","z":"4e9db622.1152a8","name":"Browser HTML & Javascript","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<script>\n    var socket;\n    var chatroom;\n    var message;\n    \n    window.onload = function() {\n        chatroom = document.getElementById(\"chatroom\");\n        message = document.getElementById(\"message\");\n        \n        socket = new WebSocket(\"ws://\"+window.location.host+\"/demochatws\");\n        socket.onopen = function(){\n        \tsocket.send(\"Someone has joined the room!\");\n        }\n        socket.onmessage = function(msg){\n        \tchatroom.innerHTML += msg.data+\"&nbsp;<span class='timestamp'>(\"+new Date().toLocaleString()+\")</span><br />\";\n        }\n    };\n    function send(){\n        if(socket){\n            socket.send(message.value);    \n        }\n    }\n</script>\n<input id=\"message\" placeholder=\"Your message here\" size=\"60\" maxlength=\"300\" />\n<button onclick=\"send();\">Send Message</button>\n<div id=\"chatroom\"></div>","x":500,"y":300,"wires":[["a6268276.c24be"]]},{"id":"f8789ed2.f09b3","type":"function","z":"4e9db622.1152a8","name":"Broadcast","func":"delete msg._session;\nreturn msg;","outputs":1,"noerr":0,"x":480,"y":640,"wires":[["5e2c262a.701168"]]},{"id":"b7d0c17c.5a6cb","type":"comment","z":"4e9db622.1152a8","name":"This flow demonstrates using websockets to create a chat room!","info":"","x":250,"y":20,"wires":[]},{"id":"fad41d30.f8371","type":"http response","z":"7a5f99cc.a7f8b8","name":"http response","statusCode":"","headers":{},"x":780,"y":120,"wires":[]},{"id":"2a037dc.18dc882","type":"template","z":"7a5f99cc.a7f8b8","name":"Page Template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n    <head>\n        <title>Aviat Networks - Node Red Tutorial</title>\n        <style>\n            h1{\n                font-family: arial;\n                font-size: 2em;\n                font-weight: bold;\n            }\n            h2{\n                font-family: arial;\n                font-size: 1.6em;\n                font-weight: bold;\n            }\n            body{\n                font-family: arial;\n                font-size: 1.2em;\n                text-align:center;\n            }\n            #content{\n                text-align:left;\n                margin: 0 auto;\n                width: 80%;\n            }\n            li{\n                margin-bottom: 15px;\n            }\n            .code{\n                color: #533;\n                display: block;\n                padding: 10px;\n                margin: 15px;\n                border: solid 1px black;\n                background-color: #BE9A9A;\n            }\n            @media print {\n                #content{\n                    width: 100%;\n                }\n            }\n        </style>\n    </head>\n    <body>\n        <img src=\"/resources/aviatlogo.png\" />\n        <img src=\"/resources/IYM-banner.jpg\" />\n        <br />\n        <div id=\"content\">{{{payload}}}</div>\n    </body>\n</html>","x":520,"y":60,"wires":[["fad41d30.f8371"]]},{"id":"f03169ce.555268","type":"rpi-sensehat out","z":"b06baa9b.a99ea8","name":"","x":930,"y":160,"wires":[]},{"id":"a031f7a0.06f6e8","type":"inject","z":"b06baa9b.a99ea8","name":"Pulse","topic":"","payload":"","payloadType":"date","repeat":"0.1","crontab":"","once":false,"x":107,"y":226,"wires":[["44e1b48c.5de8cc"]]},{"id":"98988f3c.4fec9","type":"function","z":"b06baa9b.a99ea8","name":"PixelPositionIncrement","func":"//global.circlepos = ((global.circlepos+0.25)%360) || 1;\n\nif(global.pixelmap===undefined){\n    \n    if(global.skipmap===undefined){\n       global.skipmap = {}; \n    }\n    \n    global.pixelmap = [];\n    var output = [];\n    for(var i=0;i<=360;i+=0.1){\n        var x = Math.floor(4 + 4 * Math.cos(i));\n        var y = Math.floor(4 + 4 * Math.sin(i));\n        if(x<0){x=0;}\n        if(x>7){x=7;}\n        if(y<0){y=0;}\n        if(y>7){y=7;}\n        \n        if(global.skipmap[x+\"_\"+y]!==undefined){continue;}\n        global.skipmap[x+\"_\"+y] = {};\n        \n        global.pixelmap.push({x:x,y:y});\n        output.push(x+\",\"+y+\",white\");\n    }\n    msg.payload = output.join(\",\");\n}\nelse{\n    global.circlepos = ((global.circlepos+1)%global.pixelmap.length) || 0;\n    var x = global.pixelmap[global.circlepos].x;\n    var y = global.pixelmap[global.circlepos].y;\n    msg.payload = x+\",\"+y+\",\"+msg.colour.red+\",\"+msg.colour.green+\",\"+msg.colour.blue;\n}\nreturn msg;","outputs":1,"noerr":0,"x":557,"y":223,"wires":[["f03169ce.555268"]]},{"id":"44e1b48c.5de8cc","type":"function","z":"b06baa9b.a99ea8","name":"ColourCycleIncrement","func":"var increment = 20;\nglobal.red = global.red!==undefined?global.red:255;\nglobal.green = global.green!==undefined?global.green:0;\nglobal.blue = global.blue!==undefined?global.blue:0;\n\nif (global.red === 255 && global.green < 255 && global.blue === 0){global.green += increment;}\nif (global.green === 255 && global.red > 0 && global.blue === 0){global.red -= increment;}\nif (global.green === 255 && global.blue < 255 && global.red === 0){global.blue += increment;}\nif (global.blue === 255 && global.green > 0 && global.red === 0){global.green -= increment;}\nif (global.blue === 255 && global.red < 255 && global.green === 0){global.red += increment;}\nif (global.red === 255 && global.blue > 0 && global.green === 0){global.blue -= increment;}\n\nif(global.red>255){global.red = 255;}\nif(global.green>255){global.green = 255;}\nif(global.blue>255){global.blue = 255;}\n\nif(global.red<0){global.red = 0;}\nif(global.green<0){global.green = 0;}\nif(global.blue<0){global.blue = 0;}\n\nmsg.colour = {red:global.red, green:global.green, blue: global.blue};\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":224,"wires":[["98988f3c.4fec9"]]},{"id":"eaf7796f.c66988","type":"inject","z":"b06baa9b.a99ea8","name":"","topic":"","payload":"*,*,off","payloadType":"str","repeat":"","crontab":"","once":false,"x":613,"y":141,"wires":[["f03169ce.555268"]]},{"id":"ac9f89ad.6e69b8","type":"http in","z":"7a5f99cc.a7f8b8","name":"/resources/:file","url":"/resources/:file","method":"get","upload":false,"swaggerDoc":"","x":140,"y":180,"wires":[["f078683e.27e4b8"]]},{"id":"596fc4e3.a3101c","type":"file in","z":"7a5f99cc.a7f8b8","name":"File In","filename":"","format":"","chunk":false,"x":550,"y":180,"wires":[["fad41d30.f8371"]]},{"id":"f078683e.27e4b8","type":"function","z":"7a5f99cc.a7f8b8","name":"/home/pi/resources/:file","func":"msg.filename = \"/home/pi/resources/\"+msg.req.params.file;\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":180,"wires":[["596fc4e3.a3101c"]]},{"id":"342fafb0.443ae","type":"comment","z":"7a5f99cc.a7f8b8","name":"This part allows any file in /home/pi/resources to be requested.","info":"","x":280,"y":140,"wires":[]},{"id":"28705660.9b2b8a","type":"http in","z":"7a5f99cc.a7f8b8","name":"/tutorial","url":"/tutorial","method":"get","upload":false,"swaggerDoc":"","x":110,"y":60,"wires":[["a37d9f2e.ade78"]]},{"id":"a37d9f2e.ade78","type":"template","z":"7a5f99cc.a7f8b8","name":"Printable Version","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<h1>Node-RED Tutorial</h1>\n<ol id=\"toc\">\n    <li><a href=\"#whatisnodered\">What is Node-RED?</a></li>\n    <li>\n        <a href=\"#installation\">Setting Up Node-RED at Home</a>\n        <ol>\n            <li><a href=\"#installwin\">Windows</a></li>\n            <li><a href=\"#installrpi\">Raspberry Pi</a></li>\n        </ol>\n    </li>\n    <li><a href=\"#basics\">Node-RED Basics</a></li>\n    <li><a href=\"#project\">Example Project</a></li>\n</ol>\n\n<a id=\"whatisnodered\"></a><h2>What is Node-RED?</h2>\n<p>\n    Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.<br />\n    It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.\n</p>\n<a id=\"installation\"></a><h2>Setting Up Node-RED at Home</h2>\n<a id=\"installwin\"></a><h3>Windows</h3>\n<ol>\n    <li>Download and install NodeJS <a href=\"https://nodejs.org/dist/latest-v6.x/node-v6.11.0-x64.msi\">https://nodejs.org/dist/latest-v6.x/node-v6.11.0-x64.msi</a></li>\n    <li>Open a CMD window by clicking start and typing cmd, then choosing cmd.exe</li>\n    <li>Once the command window opens type in the following line<span class=\"code\">npm install -g --unsafe-perm node-red</span></li>\n    <li>Any time you want to run Node-RED you just need to enter the following line into the CMD window.<span class=\"code\">node-red</span></li>\n    <li>Now that its running you can access the configurator by going into a web browser and entering the following address in the URL bar <a href=\"http://localhost:1880\">http://localhost:1880</a><br /><br /><img src=\"/resources/browser.png\" /><br /><br /></li>\n    <li>See the official Node-Red documentation for more information. <a href=\"https://nodered.org/docs/getting-started/installation.html\">https://nodered.org/docs/getting-started/installation.html</a></li>\n</ol>\n<a id=\"installrpi\"></a><h3>Raspberry Pi</h3>\n<ol>\n    <li>\n        You can get your own Raspberry Pi from many different retailers. One such place is Element 14. See this page for more info. <a href=\"http://nz.element14.com/buy-raspberry-pi\">http://nz.element14.com/buy-raspberry-pi</a><br />\n        You will need a Micro SD card with at least 4GB of space.<br />\n        You will also need a laptop with an SD card slot, or a USB sd card reader/writer.<br />\n    </li>\n    <li>\n        Download the latest Rasbian Operating System. From the following link. <a href=\"https://www.raspberrypi.org/downloads/raspbian/\">https://www.raspberrypi.org/downloads/raspbian/</a><br />\n        Find RASPBIAN JESSIE WITH DESKTOP and click the Download Zip link below it.\n    </li>\n    <li>\n        Download a program called Etcher from <a href=\"https://etcher.io/\">https://etcher.io/</a>\n    </li>\n    <li>\n        Put your Micro SD card into the computer or USB reader/writer and use Etcher to write the rasbian ZIP file you just downloaded.\n    </li>\n    <li>\n        Put the SD card into the Raspberry Pi, plug in a mouse screen and keyboard and finally the power plug. The Raspberry Pi should start immediately.\n    </li>\n    <li>\n        More information can be found here <a href=\"https://www.raspberrypi.org/documentation/installation/installing-images/\">https://www.raspberrypi.org/documentation/installation/installing-images/</a>\n    </li>\n    <li>\n        In the top right corner of the screen is the WIFI status. If you click this icon, you can connect to your home WIFI and get internet access. <img src=\"/resources/networkicon.png\" />\n    </li>\n    <li>\n        Now the Raspberry Pi is up and running with internet access we just need to configure Node-RED. Find the terminal icon in the top left corner of the screen and click it. It looks like <img src=\"/resources/cmdicon.png\" />\n    </li>\n    <li>\n        In new terminal window run the following command.\n        <span class=\"code\">update-nodejs-and-nodered</span>\n        This could take 10-20 minutes.\n    </li>\n    <li>\n        Now run the following command which will make Node-RED start automatically when the Pi starts up.\n        <span class=\"code\">sudo systemctl enable nodered.service</span><br />\n        If you are asked for a username or password you can use<br />username: pi<br />password: raspberry<br />\n    </li>\n    <li>\n        Now you can open the web browser at any time and enter the url http://localhost:1880. The web browser icon is in the top left and looks like. <img src=\"/resources/browsericon.png\" />\n    </li>\n</ol>\n<a id=\"basics\"></a><h2>Node-RED Basics</h2>\n<ol>\n    <li>\n        First open a browser and navigate to <a href=\"http://localhost:1880\" target=\"_blank\">http://localhost:1880</a> to open the flow configuration tool. You should see something like this.<br />\n        <br /><img src=\"/resources/screenshot.png\" />\n    </li>\n    <li>Across the top, you will see a list of tabs. These are called flows and represent seperate programs. On the right side of this bar, you will find a + button. Click it to create a new flow.</li>\n    <li>\n        On the left side of the screen you will find a library of nodes that you can use in your project.\n        Find the inject node and drag it into the workspace in the middle.\n    </li>\n    <li>\n        Find the debug node and drag it into the workspace.\n    </li>    \n    <li>Using the little handles on the left and right side of the two nodes, click and drag a line between them.<br /><img src=\"/resources/connector.png\" /></li>\n    <li>Now lets test our program!<br />Click the red deploy button in the top right corner of the screen.<br /><img src=\"/resources/deploy.png\" /><br />The program is now running</li>\n    <li>Click the little tag on the left side of the inject node. You will notice that a message appears in the debug log on the right.</li>\n</ol>\n<br />\nThis form of programming is about sending messages down a pipeline. When we click the injector node a message is created and sent down the line, into a debug node that prints it out. These nodes can be very useful for debugging your programs.\n\n<a id=\"project\"></a><h2>Example Project</h2>\n<p>\n    Now we are going to create a simple website, that has a few pages of content and also a live chat room. This will demonstrate how to make both a simple website and a more complicated web application. If there is time, we will also see how we can control and use hardware like the joystick and LED matrix.\n</p>","x":310,"y":60,"wires":[["2a037dc.18dc882"]]},{"id":"acf8bb79.6dd958","type":"http in","z":"4e9db622.1152a8","name":"/demo","url":"/demo","method":"get","upload":false,"swaggerDoc":"","x":130,"y":140,"wires":[["ee5b9627.265478"]]},{"id":"ee5b9627.265478","type":"template","z":"4e9db622.1152a8","name":"Home Page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<h1>Welcome to Super Chat!</h1>\nThis is some information about this web app!!!","x":550,"y":140,"wires":[["a6268276.c24be"]]},{"id":"a477f735.f47628","type":"http in","z":"4e9db622.1152a8","name":"/demo/info","url":"/demo/info","method":"get","upload":false,"swaggerDoc":"","x":140,"y":220,"wires":[["88a863e1.b043e"]]},{"id":"88a863e1.b043e","type":"template","z":"4e9db622.1152a8","name":"Basics Tutorial","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<h1>Info</h1>\nThis is some different information!!!","x":540,"y":220,"wires":[["a6268276.c24be"]]},{"id":"a6268276.c24be","type":"template","z":"4e9db622.1152a8","name":"Page Template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n    <head>\n        <title>My First Node-RED Web App</title>\n        <style>\n            #chatroom{\n                margin-top: 10px;\n                padding: 15px;\n                height: 500px;\n                border: solid 1px black;\n            }\n            .timestamp{\n                font-size: 10pt;\n                font-family: arial;\n            }\n        </style>\n    </head>\n    <body>\n        <div id=\"menu\"><a href=\"/demo\">Home</a>&nbsp;|&nbsp;<a href=\"/demo/info\">Info</a>&nbsp;|&nbsp;<a href=\"/demo/chat\">Chat</a>&nbsp;|&nbsp;<a href=\"/demo/hardwarecontrol\">Hardware Control</a></div>\n        <br />\n        {{{payload}}}\n    </body>\n</html>","x":820,"y":300,"wires":[["7e89b2b5.9458dc"]]},{"id":"7e89b2b5.9458dc","type":"http response","z":"4e9db622.1152a8","name":"HTTP Response","statusCode":"","headers":{},"x":1040,"y":300,"wires":[]},{"id":"f0f7c691.ff4398","type":"template","z":"4e9db622.1152a8","name":"Browser HTML & Javascript (ADVANCED)","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n    <head>\n        <title>Example 1 - Websockets</title>\n        <script>\n            \n            function getCookieValue(a) {\n                var b = document.cookie.match('(^|;)\\\\s*' + a + '\\\\s*=\\\\s*([^;]+)');\n                return b ? b.pop() : '';\n            }\n\n            var socket;\n            var chatroom;\n            var message;\n            var nameInput;\n            \n            window.onload = function() {\n                nameInput = document.getElementById(\"name\");\n                chatroom = document.getElementById(\"chatroom\");\n                message = document.getElementById(\"message\");\n                if(document.cookie){\n                    \n                    nameInput.value = getCookieValue(\"name\");\n                }\n                message.onkeypress = function(e){\n                    if(e.key===\"Enter\"){\n                        send();\n                    }\n                };\n                message.focus();\n                \n                socket = new WebSocket(\"ws://jayspi:1880/demochatws\");\n                socket.onopen = function(){\n                \tconsole.log(\"Socket has been opened!\");\n                \tsocket.send(nameInput.value+\": Has joined the room!\");\n                }\n                socket.onmessage = function(msg){\n                \tchatroom.innerHTML += msg.data+\"&nbsp;<span class='timestamp'>(\"+new Date().toLocaleString()+\")</span><br />\";\n                }\n            };\n            function send(){\n                if(socket){\n                    if(message.value.charAt(0)===\"/\"){\n                        socket.send(message.value);    \n                    }\n                    else{\n                        socket.send(nameInput.value+\": \"+message.value);\n                    }\n                    message.value = \"\";\n                    message.focus();\n                    document.cookie = \"name=\"+nameInput.value;\n                }\n            }\n        </script>\n        <style>\n            #chatroom{\n                margin-top: 10px;\n                padding: 15px;\n                height: 500px;\n                border: solid 1px black;\n            }\n            .timestamp{\n                font-size: 10pt;\n                font-family: arial;\n            }\n        </style>\n    </head>\n    <body>\n        <input id=\"name\" placeholder=\"Your name here\" size=\"20\" maxlength=\"20\" value=\"anonymous\" /><br />\n        <input id=\"message\" placeholder=\"Your message here\" size=\"60\" maxlength=\"300\" />\n        <button onclick=\"send();\">Send Message</button>\n        <div id=\"chatroom\"></div>\n    </body>\n</html>","x":460,"y":380,"wires":[["a6268276.c24be"]]},{"id":"1c6e57ba.5eb198","type":"http in","z":"4e9db622.1152a8","name":"/demo/chat2","url":"/demo/chat2","method":"get","upload":false,"swaggerDoc":"","x":150,"y":380,"wires":[["f0f7c691.ff4398"]]},{"id":"8a618149.a1c8c","type":"comment","z":"4e9db622.1152a8","name":"This part catches incomming messages and sends them out to all people in the chat room.","info":"","x":390,"y":600,"wires":[]},{"id":"d0af61da.d0163","type":"comment","z":"4e9db622.1152a8","name":"This part sets up the different pages on the website.","info":"","x":271,"y":98,"wires":[]},{"id":"385f5c59.4d87b4","type":"http in","z":"4e9db622.1152a8","name":"/demo/hardwarecontrol","url":"/demo/hardwarecontrol","method":"get","upload":false,"swaggerDoc":"","x":180,"y":460,"wires":[["aa0b8b7d.cfe0a8"]]},{"id":"aa0b8b7d.cfe0a8","type":"template","z":"4e9db622.1152a8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<script>\n    var socket;\n    window.onload = function(){\n        socket = new WebSocket(\"ws://\"+window.location.host+\"/demo_gpio_ws\");\n        socket.onopen = function(){\n        \tconsole.log(\"Socket has been opened!\");\n        }\n        socket.onmessage = function(msg){\n        \tvar data = JSON.parse(msg.data);\n        \tif(data && data.key){\n        \t    document.getElementById('arrow').src=\"/images/arrow_\"+data.key+\".png\";\n        \t}\n        }\n    };\n    function send(){\n        if(socket){\n            socket.send(document.getElementById('message').value);\n        }\n    }\n</script>\n<div style=\"float: right; width: 50%;\">\n    <div class=\"node-help\"><span class=\"bidiAware\" dir=\"\">\n    <p>Raspberry Pi Sense HAT output node.</p>\n    <p>This node sends commands to the 8x8 LED display on the Sense HAT.</p>\n    <p>Commands are sent to the node in <code>msg.payload</code>. Multiple commands can\n    be sent in a single message by separating them with newline (\\n) characters.</p><p>\n    \n    </p><p><b>Set the colour of individual pixels</b></p>\n    <p>Format: <code>&lt;x&gt;,&lt;y&gt;,&lt;colour&gt;</code>\n    </p><p><code>x</code> and <code>y</code> must either be a value from 0 to 7, a\n    <code>*</code> to indicate the entire row or column, or a range such as <code>3-6</code>.</p>\n    <p><code>colour</code> must be one of:\n    </p><ul>\n        <li>the well-known <a href=\"https://en.wikipedia.org/wiki/Web_colors\" target=\"_blank\">HTML colour names</a>\n         - eg <code>red</code> or <code>aquamarine</code>,</li>\n        <li>the <a href=\"http://cheerlights.com/cheerlights-api/\" target=\"_blank\">CheerLights colour names</a>,</li>\n        <li>a HEX colour value - eg <code>#aa9900</code></li>\n        <li>an RGB triple - <code>190,255,0</code></li>\n        <li>or simply <code>off</code></li>\n    </ul>\n    \n    <p><i>Examples</i></p>\n    <p>To set the entire screen to red:</p>\n    <p><code>*,*,red</code></p>\n    <p>To set the four corners of the display to red, green (#00ff00), yellow and blue (0,0,255):</p>\n    <p><code>0,0,red,0,7,#00ff00,7,7,yellow,7,0,0,0,255</code></p>\n    <p>To set a 3-pixel wide column to purple:</p>\n    <p><code>4-6,*,purple</code></p>\n    \n    <p><b>Rotate the screen</b></p>\n    <p>Format: <code>R&lt;angle&gt;</code></p>\n    <p><code>angle</code> must be 0, 90, 180 or 270.</p>\n    \n    <p><b>Flip the screen</b></p>\n    <p>Format: <code>F&lt;axis&gt;</code></p>\n    <p><code>axis</code> must be either <code>H</code> or <code>V</code> to flip on\n    the horizontal or vertical axis respectively.</p>\n    \n    <p><b>Scroll a message</b></p>\n    <p>If <code>msg.payload</code> is not recognised as any of the above commands,\n    it is treated as a text message to be scrolled across the screen.</p>\n    <p>If the text is a single character, it will be displayed without scrolling.\n    To scroll a single character, append a blank space after it - <code>\"A \"</code>.</p>\n    <p>The following message properties can be used to customise the appearance:</p>\n    <ul>\n        <li><code>msg.color</code> - the colour of the text, default: <code>white</code></li>\n        <li><code>msg.background</code> - the colour of the background, default: <code>off</code></li>\n        <li><code>msg.speed</code> - the scroll speed. A value in the range 1 (slower) to 5 (faster), default: <code>3</code></li>\n    </ul>\n    \n    <p><b>Set the screen brightness</b></p>\n    <p>Format: <code>D&lt;level&gt;</code></p>\n    <p><code>level</code> must be 0 (low) or 1 (high).</p>\n    </span></div>\n</div>\n<textarea id=\"message\" placeholder=\"Your message here\" rows=\"10\" cols=\"50\"></textarea>\n<button onclick=\"send()\">Send Message</button><br /><br />\n<img id=\"arrow\" />","x":570,"y":460,"wires":[["a6268276.c24be"]]},{"id":"240a99b3.2efbb6","type":"websocket in","z":"4e9db622.1152a8","name":"demo_gpio_ws","server":"fc8ae346.214ce","client":"","x":160,"y":780,"wires":[["40155017.0b333"]]},{"id":"cb0396ba.54fc08","type":"websocket out","z":"4e9db622.1152a8","name":"/ws out","server":"fc8ae346.214ce","client":"","x":860,"y":780,"wires":[]},{"id":"252ed307.0ce5ec","type":"rpi-sensehat in","z":"4e9db622.1152a8","name":"","motion":false,"env":false,"stick":true,"x":642,"y":781,"wires":[["cb0396ba.54fc08"]]},{"id":"40155017.0b333","type":"rpi-sensehat out","z":"4e9db622.1152a8","name":"","x":350,"y":780,"wires":[]},{"id":"6b91beba.3211d","type":"comment","z":"4e9db622.1152a8","name":"This part exchanges messages in both directions between the websocket and the Sense-Hat","info":"","x":400,"y":740,"wires":[]},{"id":"acc21df1.d6774","type":"http in","z":"4e9db622.1152a8","name":"/images/:file","url":"/images/:file","method":"get","upload":false,"swaggerDoc":"","x":150,"y":920,"wires":[["344c83d0.2cfb0c"]]},{"id":"bd474cc3.04d94","type":"file in","z":"4e9db622.1152a8","name":"File In","filename":"","format":"","chunk":false,"x":670,"y":920,"wires":[["debcaf12.083d"]]},{"id":"344c83d0.2cfb0c","type":"function","z":"4e9db622.1152a8","name":"/home/pi/resources/:file","func":"msg.filename = \"/home/pi/resources/\"+msg.req.params.file;\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":920,"wires":[["bd474cc3.04d94"]]},{"id":"e630092a.4c0578","type":"comment","z":"4e9db622.1152a8","name":"This part allows any file in /home/pi/resources to be requested.","info":"","x":300,"y":880,"wires":[]},{"id":"debcaf12.083d","type":"http response","z":"4e9db622.1152a8","name":"","statusCode":"","headers":{},"x":850,"y":920,"wires":[]},{"id":"9c12304f.be841","type":"comment","z":"b06baa9b.a99ea8","name":"This flow will draw a circle on the LED screen and will cycle through various colours.","info":"","x":330,"y":60,"wires":[]}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement