Created
February 10, 2015 20:24
-
-
Save kevinmarx/f7b68abeacc9406239fb to your computer and use it in GitHub Desktop.
Node-Red Workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"1a6950c5.e596af","type":"bean","name":"Next Bus","uuid":"","connectiontype":"constant","connectiontimeout":"0"},{"id":"5ae1cb18.a51e34","type":"sentiment","name":"","x":504,"y":333,"z":"24232079.dbdce","wires":[["df520a61.20adf8","672c16c9.98d3e8"]]},{"id":"9c9fdf29.63602","type":"bean led","name":"","bean":"1a6950c5.e596af","x":933,"y":338,"z":"24232079.dbdce","wires":[]},{"id":"df520a61.20adf8","type":"debug","name":"","active":true,"console":"false","complete":"false","x":694,"y":423,"z":"24232079.dbdce","wires":[]},{"id":"8c524fac.73adb","type":"inject","name":"","topic":"","payload":"I am so happy!","payloadType":"string","repeat":"","crontab":"","once":false,"x":320,"y":307,"z":"24232079.dbdce","wires":[["5ae1cb18.a51e34"]]},{"id":"f4ac7367.0b539","type":"inject","name":"","topic":"","payload":"I am so angry!","payloadType":"string","repeat":"","crontab":"","once":false,"x":324,"y":372,"z":"24232079.dbdce","wires":[["5ae1cb18.a51e34"]]},{"id":"50827230.af7d8c","type":"inject","name":"","topic":"","payload":"ok","payloadType":"string","repeat":"","crontab":"","once":false,"x":345,"y":420,"z":"24232079.dbdce","wires":[["5ae1cb18.a51e34"]]},{"id":"672c16c9.98d3e8","type":"function","name":"","func":"context.RGBArray = context.RGBArray || []; \nvar red = 0;\nvar green = 0;\nvar blue = 0;\nif(context.RGBArray.length==0){\n for (var i = 0; i<3; i++){\n\tcontext.RGBArray.push([0,0,0]);\t\n }\n}\nvar intensity = Math.round(255*msg.sentiment.score/5);\nvar RGB = [0,0,0];\n\nif(msg.sentiment.score<0){\n\tRGB[0] = Math.abs(intensity);\n} else if(msg.sentiment.score==0) {\n\tRGB[2] = 50;\n} else {\n\tRGB[1] = intensity;\n}\n\ncontext.RGBArray.unshift(RGB);\ncontext.RGBArray.pop();\n\nconsole.log(context.RGBArray);\nfor (var i = 0; i<3; i++){\n\tred += context.RGBArray[i][0];\n\tgreen += context.RGBArray[i][1];\n\tblue += context.RGBArray[i][2];\n}\nred = Math.round(red/3);\ngreen = Math.round(green/3);\nblue = Math.round(blue/3);\nmsg.payload = String(red) + \",\" + String(green) +\",\"+ String(blue);\n\nreturn msg;","outputs":1,"x":701,"y":334,"z":"24232079.dbdce","wires":[["9c9fdf29.63602","df520a61.20adf8"]]},{"id":"730ea8db.8cf158","type":"inject","name":"","topic":"","payload":"0,0,0","payloadType":"string","repeat":"","crontab":"","once":false,"x":657,"y":560,"z":"24232079.dbdce","wires":[["9c9fdf29.63602"]]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment