Example Node-RED that adds a sidebar panel in the editor
-
git clone this gist somewhere
-
In
~/.node-red
run:npm install <path to where the gist is>
-
Restart Node-RED
-
Reload the editor and marvel at the new sidebar tab
{ | |
"swagger": "2.0", | |
"info": { | |
"title": "FlowForge Platform API", | |
"description": "API documentation for interacting with the FlowForge platform", | |
"version": "1.8.0-git" | |
}, | |
"definitions": { | |
"def-0": { | |
"type": "object", |
Example Node-RED that adds a sidebar panel in the editor
git clone this gist somewhere
In ~/.node-red
run: npm install <path to where the gist is>
Restart Node-RED
Reload the editor and marvel at the new sidebar tab
[{"id":"479b30f5.0d2bb","type":"function","z":"7756eff1.08d0a","name":"Marble Maze","func":"// A Function to generate a new goal position\nfunction updateGoal() {\n do {\n goalX = Math.floor(Math.random()*7)+1;\n goalY = Math.floor(Math.random()*7)+1;\n } while(checkWall(goalX,goalY));\n \n flow.set('goalX',goalX);\n flow.set('goalY',goalY); \n}\n\n// Generate 'walls' - 10 randomly placed blocks\nfunction generateWalls() {\n walls = [];\n for (var i=0;i<10;i++) {\n var wx = 0;\n var wy = 0;\n do {\n wx = Math.floor(Math.random()*8);\n wy = Math.floor(Math.random()*8);\n } while(wx === x && wy === y);\n walls.push({x:wx,y:wy});\n }\n flow.set('walls',walls);\n}\n\n// Check whether a given position collides with any of the walls\nfunction checkWall(x,y) {\n for (var i=0;i<walls.length;i++) {\n if (walls[i].x === x && walls[i].y === y) {\n return true;\n }\n }\n return false;\n}\n\n// Retrieve the current player positions from local context\nvar x = context.get('x');\nvar y = context.get('y');\n\n// Retrieve the |
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<head> | |
<style> | |
body { | |
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | |
position: relative; | |
text-align: center; | |
} | |
.chart { |
/* | |
CurrentCost MQTT Bridge | |
Example sketch for the CurrentCost Bridge device that causes | |
readings to be published over MQTT. | |
Requires: | |
- Arduino 0022 | |
- PubSubClient v1.6+ | |
http://knolleary.net/arduino-client-for-mqtt/ |