forked from blechdom/node-red-flows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Robot_Arm_preset_logic_working.json
1 lines (1 loc) · 4.21 KB
/
Robot_Arm_preset_logic_working.json
1
[{"id":"b0bb0f84.48852","type":"function","z":"ece5114f.f98d3","name":"Just get preset","func":"var servos = msg.payload;\n\nvar last_servos = global.get(\"last_sent_servos\");\nvar m = [];\nvar sameness_flag = 0;\n\nif (servos!=last_servos){\n sameness_flag = 1;\n}\n\nif(sameness_flag==1){\n \n global.set(\"last_sent_servos\", servos);\n global.set(\"servos_preset\", servos);\n m[0] = {payload: \"sending the preset\"};\n m[1] = {payload: servos};\n return m;\n\n}\n","outputs":2,"noerr":0,"x":780,"y":440,"wires":[["6bc3b338.a84bec"],["7824333.8394dcc"]]},{"id":"7910b4eb.d7b53c","type":"function","z":"ece5114f.f98d3","name":"save servo #s","func":"global.set(\"last_sent_servos\", 0);\nglobal.set(\"servos_preset\", 0); \nreturn msg;","outputs":1,"noerr":0,"x":780,"y":160,"wires":[[]]},{"id":"35fb5db6.a3bca2","type":"inject","z":"ece5114f.f98d3","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":570,"y":160,"wires":[["7910b4eb.d7b53c"]]},{"id":"934141cf.30855","type":"inject","z":"ece5114f.f98d3","name":"preset #","topic":"","payload":"5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":580,"y":440,"wires":[["b0bb0f84.48852"]]},{"id":"5ab8f87e.5de808","type":"function","z":"ece5114f.f98d3","name":"get last sent","func":"msg.payload = \"last sent: \" + global.get(\"last_sent_servos\");\n\nreturn msg;","outputs":1,"noerr":0,"x":730,"y":220,"wires":[["d765ca02.1c0618"]]},{"id":"81ae1d3f.d477a","type":"inject","z":"ece5114f.f98d3","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":560,"y":220,"wires":[["5ab8f87e.5de808"]]},{"id":"1915341c.94df8c","type":"function","z":"ece5114f.f98d3","name":"get current","func":"msg.payload = \"current value: \" + global.get(\"servos_preset\");\nreturn msg;","outputs":1,"noerr":0,"x":730,"y":280,"wires":[["91c42a8e.84fee8"]]},{"id":"d765ca02.1c0618","type":"debug","z":"ece5114f.f98d3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":990,"y":220,"wires":[]},{"id":"ecba78f0.ac8c78","type":"inject","z":"ece5114f.f98d3","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":560,"y":280,"wires":[["1915341c.94df8c"]]},{"id":"91c42a8e.84fee8","type":"debug","z":"ece5114f.f98d3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":990,"y":280,"wires":[]},{"id":"6bc3b338.a84bec","type":"debug","z":"ece5114f.f98d3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1030,"y":420,"wires":[]},{"id":"718b38fb.209948","type":"function","z":"ece5114f.f98d3","name":"send servo data","func":"var servos = global.get(\"servos_preset\");\nvar last_servos = global.get(\"last_sent_servos\");\nvar sameness_flag = false;\n\nif (servos!=last_servos){\n sameness_flag = 1;\n}\n\nif(sameness_flag==1){\n \n global.set(\"last_sent_servos\", servos);\n msg.payload = \"sending single servo\";\n return msg;\n\n}\n\n\n\n","outputs":1,"noerr":0,"x":800,"y":600,"wires":[["a2621b11.5dd9c8"]]},{"id":"b5cadb92.4c4238","type":"inject","z":"ece5114f.f98d3","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":600,"y":600,"wires":[["718b38fb.209948"]]},{"id":"a2621b11.5dd9c8","type":"debug","z":"ece5114f.f98d3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1010,"y":600,"wires":[]},{"id":"7824333.8394dcc","type":"ui_slider","z":"ece5114f.f98d3","name":"","label":"slider","group":"7684373e.2d7528","order":0,"width":0,"height":0,"passthru":true,"topic":"","min":0,"max":10,"step":1,"x":1190,"y":500,"wires":[["6d8e25a8.48d6ec"]]},{"id":"6d8e25a8.48d6ec","type":"function","z":"ece5114f.f98d3","name":"","func":"global.set(\"servos_preset\", msg.payload);\n","outputs":1,"noerr":0,"x":1350,"y":500,"wires":[[]]},{"id":"7684373e.2d7528","type":"ui_group","z":"ece5114f.f98d3","name":"SERVO LOG","tab":"a232f4ae.722488","order":4,"disp":true,"width":"6","collapse":true},{"id":"a232f4ae.722488","type":"ui_tab","z":"","name":"ROBOT ARM DASHBOARD","icon":"home","order":2}]