-
Notifications
You must be signed in to change notification settings - Fork 0
/
flows_pi-top.json
1 lines (1 loc) · 2.74 KB
/
flows_pi-top.json
1
[{"id":"88faf6ac.0458b8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"bf5a5835.fa9c28","type":"rpi-sensehat out","z":"88faf6ac.0458b8","name":"","x":790,"y":260,"wires":[]},{"id":"f8eb4e21.cc1b7","type":"function","z":"88faf6ac.0458b8","name":"Simple graphical clock","func":"\n// array to hold \"random\" pixels\nvar ranNums = [];\n\n// create a non-overlapping array of random numbers 0-8\nfunction rerand() {\n var nums = [0,1,2,3,4,5,6,7,8];\n var i = nums.length;\n var j;\n ranNums = [];\n while (i--) {\n j = Math.floor(Math.random() * (i+1));\n ranNums.push(nums[j]);\n nums.splice(j,1);\n }\n}\n\n// Get the hours and minutes and split into tens and units\nvar d = new Date();\nvar s = d.getSeconds();\nvar su = s%4;\nif (su === 0) {\n var h = d.getHours();\n var m = d.getMinutes();\n var hu = h%10;\n h = parseInt(h/10);\n var mu = m%10;\n m = parseInt(m/10);\n \n // Do the tens of hours (red)\n rerand();\n node.send({payload:\"1-3,1-3,0,0,0\"});\n for (var i=0; i<h; i++) {\n node.send({payload:(1+ranNums[i]%3)+\",\"+(1+parseInt(ranNums[i]/3))+\",255,0,0\"});\n }\n \n // Do the units of hours (green)\n rerand();\n node.send({payload:\"4-6,1-3,0,0,0\"});\n for (var i=0; i<hu; i++) {\n node.send({payload:(4+ranNums[i]%3)+\",\"+(1+parseInt(ranNums[i]/3))+\",0,255,0\"});\n }\n \n // Do the tens of minutes (yellow)\n rerand();\n node.send({payload:\"1-3,4-6,0,0,0\"});\n for (var i=0; i<m; i++) {\n node.send({payload:(1+ranNums[i]%3)+\",\"+(4+parseInt(ranNums[i]/3))+\",255,255,0\"});\n }\n \n // Do the unit of minutes (blue)\n rerand();\n node.send({payload:\"4-6,4-6,0,0,0\"});\n for (var i=0; i<mu; i++) {\n node.send({payload:(4+ranNums[i]%3)+\",\"+(4+parseInt(ranNums[i]/3))+\",0,0,255\"});\n }\n \n}\nnode.send({payload:\"0,0,\"+(su===0?\"purple\":\"off\")+\",7,0,\"+(su===1?\"purple\":\"off\")+\",7,7,\"+(su===2?\"purple\":\"off\")+\",0,7,\"+(su===3?\"purple\":\"off\")})\n\n\n// nothing left to do\nreturn null;","outputs":1,"noerr":0,"x":580,"y":260,"wires":[["bf5a5835.fa9c28"]]},{"id":"b3046b0d.95ee78","type":"comment","z":"88faf6ac.0458b8","name":"Simple graphical clock for Sense Hat","info":"Generates a graphical clock, showing hours and minutes. \n\nHours are shown by the red and green pixels, minutes\nare the yellow and blue pixels.\n\nUses the local time of the Pi - you may need to set your local\ntimezone using\n\n sudo dpkg-reconfigure tzdata\n","x":470,"y":220,"wires":[]},{"id":"8f267b70.adab88","type":"inject","z":"88faf6ac.0458b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"x":380,"y":260,"wires":[["f8eb4e21.cc1b7"]]}]