Hi, I am developing a dashboard UI for a toy car. I have it partially working. The problem that I am trying to solve is that as the forward icon is pressed the speed increases, which is fine, when I press the stop icon is pressed the motor stops, which is fine. However, when I press the forward button again the speed increments from the last value, it does not reset. I am not sure how to achieve this on the template or in the function nodes, can anyone assist?
Dev Screen
My Flow Construction
[{"id":"6fb68375.45d77c","type":"inject","z":"443ac335.bf30ec","name":"Steering Central Start","topic":"","payload":"35","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":"","x":207,"y":673,"wires":[["a0cfe519.0b33e8"]]},{"id":"90a853a5.35e9b","type":"ui_template","z":"443ac335.bf30ec","group":"e98d69cd.5b1848","name":"Button Mapping","order":3,"width":0,"height":0,"format":"<div layout=\"row\" layout-align=\"center center\">\n<i ng-click=\"count = count + 20; send({payload: 'fwd-'+count})\" ng-init=\"count=0\" class=\"fa fa-chevron-circle-up\" style=\"font-size:48px;color:red\"></i>\n</div>\n<div layout=\"row\" layout-align=\"space-between centre\">\n <i ng-click=\"count = count + 5; send({payload: 'lft-'+count})\" ng-init=\"count=60\" class=\"fa fa-chevron-circle-left\" style=\"font-size:48px;color:red\"></i>\n <i ng-click=\"send({payload: 'stp-'+0})\" class=\"fa fa-stop-circle\" style=\"font-size:48px;color:red\"></i>\n <i ng-click=\"count = count + 5; send({payload: 'rht'+count})\" ng-init=\"count=60\" class=\"fa fa-chevron-circle-right\" style=\"font-size:48px;color:red\"></i>\n</div>\n<div layout=\"row\" layout-align=\"center center\">\n<i ng-click=\"count = count + 20; send({payload: 'bwd-'+count})\" ng-init=\"count=0\" class=\"fa fa-chevron-circle-down\" style=\"font-size:48px;color:red\"></i>\n</div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":197,"y":490,"wires":[["dc90891f.854ed8"]]},{"id":"dc90891f.854ed8","type":"function","z":"443ac335.bf30ec","name":"","func":"msg1 = {};\nmsg2 = {};\nmsg3 = {};\nmsg4 = {};\nmsg5 = {};\nvar instruction = msg.payload.substring(0,3);\nvar value = msg.payload.substring(4);\n//msg1.payload = instruction;\nif (instruction == \"fwd\"){\nvalue = parseInt(value);\nif (value > 220){\n value = 220;\n}\nmsg1.payload = value;\n}\nif (instruction == \"bwd\"){\nvalue = parseInt(value);\nif (value > 150){\n value = 150;\n}\n\nmsg2.payload = value; \n}\nif (instruction == \"stp\"){\nmsg3.payload = \"Stop\"; \nmsg1.payload = parseInt(value);\n}\nif (instruction == \"lft\"){\nmsg4.payload = parseInt(value); \n}\nif (instruction == \"rht\"){\nmsg5.payload = parseInt(value); \n}\n\nreturn [msg1, msg2, msg3, msg4, msg5];","outputs":5,"noerr":0,"x":429,"y":513,"wires":[["26e57ba5.896854"],["a631a69e.f4c9e8"],["38aad2ac.45934e"],["32efacbd.1eed44"],["c264f9b.4a82f08"]]},{"id":"26e57ba5.896854","type":"debug","z":"443ac335.bf30ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":742,"y":432,"wires":[]},{"id":"a631a69e.f4c9e8","type":"debug","z":"443ac335.bf30ec","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":767,"y":495,"wires":[]},{"id":"38aad2ac.45934e","type":"debug","z":"443ac335.bf30ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":754,"y":547,"wires":[]},{"id":"32efacbd.1eed44","type":"debug","z":"443ac335.bf30ec","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":775,"y":606,"wires":[]},{"id":"c264f9b.4a82f08","type":"debug","z":"443ac335.bf30ec","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":768,"y":660,"wires":[]},{"id":"e98d69cd.5b1848","type":"ui_group","z":"","name":"thing2car","tab":"257a7994.928216","disp":true,"width":"6","collapse":false},{"id":"257a7994.928216","type":"ui_tab","z":0,"name":"Home","icon":"dashboard"}]