Hello @zenofmud , I would like to add a functionality in my flow that every time I press the button up, down, left ,right the icon or UAV should move in that direction but currently if I press it only once the value or UAV goes in that direction only once, so how can I achieve this functionality? any ideas? I would be very thankful to you. This is my current flow:
[
{
"id": "594f4d4bfd9f7699",
"type": "tab",
"label": "Flight_Control_SIMULU",
"disabled": false,
"info": "",
"env": []
},
{
"id": "319ff3a15befbaa7",
"type": "ui_worldmap",
"z": "594f4d4bfd9f7699",
"group": "b4ebae93d455bbc5",
"order": 1,
"width": 9,
"height": 10,
"name": "",
"lat": "48.80",
"lon": "13.50",
"zoom": "",
"layer": "OSMC",
"cluster": "0",
"maxage": "",
"usermenu": "hide",
"layers": "hide",
"panit": "true",
"panlock": "false",
"zoomlock": "false",
"hiderightclick": "true",
"coords": "deg",
"showgrid": "false",
"showruler": "false",
"allowFileDrop": "false",
"path": "/worldmap",
"overlist": "DR,CO,RA,DN,AC,HM",
"maplist": "OSMG,OSMC,EsriC,EsriS,EsriT,EsriDG,UKOS",
"mapname": "",
"mapurl": "",
"mapopt": "",
"mapwms": false,
"x": 1100,
"y": 40,
"wires": []
},
{
"id": "01732bfeeaa6afce",
"type": "ui_text_input",
"z": "594f4d4bfd9f7699",
"name": "",
"label": "Initial Lat Position",
"tooltip": "",
"group": "b4ebae93d455bbc5",
"order": 2,
"width": 6,
"height": 1,
"passthru": true,
"mode": "number",
"delay": "100",
"topic": "lat",
"sendOnBlur": true,
"className": "",
"topicType": "str",
"x": 110,
"y": 120,
"wires": [
[
"bb2883299b8bc021"
]
]
},
{
"id": "2aeed1b10c6c1515",
"type": "ui_button",
"z": "594f4d4bfd9f7699",
"name": "",
"group": "b4ebae93d455bbc5",
"order": 3,
"width": 2,
"height": 1,
"passthru": false,
"label": "Set",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "set",
"topicType": "str",
"x": 90,
"y": 200,
"wires": [
[
"bb2883299b8bc021"
]
]
},
{
"id": "bb2883299b8bc021",
"type": "function",
"z": "594f4d4bfd9f7699",
"name": "function 1",
"func": "var data1 = global.get(\"data1\") || 0;\nvar data2 = global.get(\"data2\") || 0;\nvar data3 = flow.get(\"data3\") || 0;\nvar topic = msg.topic\n\nif(msg.topic == \"lat\"){\n data1 = msg.payload;\n global.set(\"data1\", data1);\n return\n}\n\nif(msg.topic == \"lon\"){\n data2 = msg.payload;\n global.set(\"data2\", data2);\n return\n}\n\nif(msg.topic == \"alt\"){\n var dist = data1;\n var a = dist * Math.tan(data1);\n var b = dist * Math.tan(data2);\n data3 = a + b;\n msg.payload = data3;\n flow.set(\"data3\", data3);\n return\n}\n\nif (msg.topic == \"up\") {\n data1 = data1 + 1;\n msg.payload = {\n \"name\": \"SIMULU\",\n \"lat\": data1,\n \"layer\": \"gps\"\n }\n}\n\n\nif(msg.topic == \"down\"){\n data1 = data1 - 1;\n msg.payload = {\n \"name\": \"SIMULU\",\n \"lat\": data1,\n \"layer\": \"gps\"\n }\n}\n\nif(msg.topic == \"left\"){\n data2 = data2 - 1;\n msg.payload = {\n \"name\": \"SIMULU\",\n \"lon\": data2,\n \"layer\": \"gps\"\n }\n}\n\nif(msg.topic == \"right\"){\n data2 = data2 + 1;\n msg.payload = {\n \"name\": \"SIMULU\",\n \"lon\": data2,\n \"layer\": \"gps\"\n }\n}\n\nif(msg.topic == \"set\"){\n msg.payload = {\n \"name\": \"SIMULU\",\n \"lat\": data1,\n \"lon\": data2,\n \"alt\": data3,\n \"icon\": \"fa-plane\",\n \"iconColor\": \"blue\",\n \"layer\": \"gps\",\n \"popped\": true\n }\n \n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 580,
"y": 140,
"wires": [
[
"2cb3acd121995f56",
"14927396080798d3",
"0b8c558142c13b6e"
]
]
},
{
"id": "0b8c558142c13b6e",
"type": "debug",
"z": "594f4d4bfd9f7699",
"name": "debug 3",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 740,
"y": 200,
"wires": []
},
{
"id": "2cb3acd121995f56",
"type": "worldmap-tracks",
"z": "594f4d4bfd9f7699",
"name": "",
"depth": 20,
"layer": "single",
"smooth": false,
"x": 870,
"y": 40,
"wires": [
[
"14927396080798d3"
]
]
},
{
"id": "14927396080798d3",
"type": "worldmap",
"z": "594f4d4bfd9f7699",
"name": "",
"lat": "48.80",
"lon": "13.50",
"zoom": "",
"layer": "OSMC",
"cluster": "",
"maxage": "20",
"usermenu": "show",
"layers": "show",
"panit": "true",
"panlock": "false",
"zoomlock": "false",
"hiderightclick": "false",
"coords": "deg",
"showgrid": "false",
"showruler": "false",
"allowFileDrop": "false",
"path": "/worldmap",
"overlist": "DR,CO,RA,DN,AC,HM",
"maplist": "OSMG,OSMC,EsriC,EsriS,EsriT,EsriDG,UKOS",
"mapname": "",
"mapurl": "",
"mapopt": "",
"mapwms": false,
"x": 1120,
"y": 140,
"wires": []
},
{
"id": "3f1eed7c26c68aa2",
"type": "ui_text_input",
"z": "594f4d4bfd9f7699",
"name": "",
"label": "Initial Lon Position",
"tooltip": "",
"group": "b4ebae93d455bbc5",
"order": 4,
"width": 6,
"height": 1,
"passthru": true,
"mode": "number",
"delay": "100",
"topic": "lon",
"sendOnBlur": true,
"className": "",
"topicType": "str",
"x": 110,
"y": 160,
"wires": [
[
"bb2883299b8bc021"
]
]
},
{
"id": "6c78defaf08106ad",
"type": "ui_slider",
"z": "594f4d4bfd9f7699",
"name": "",
"label": "Altitude",
"tooltip": "",
"group": "b4ebae93d455bbc5",
"order": 6,
"width": 6,
"height": 1,
"passthru": true,
"outs": "end",
"topic": "alt",
"topicType": "str",
"min": 0,
"max": "100",
"step": "0.1",
"className": "",
"x": 100,
"y": 240,
"wires": [
[
"bf273c3b70b21055",
"bb2883299b8bc021"
]
]
},
{
"id": "bf273c3b70b21055",
"type": "function",
"z": "594f4d4bfd9f7699",
"name": "function 2",
"func": "var data = flow.get(\"data\") || 0;\ndata = msg.payload;\nmsg.payload = msg.payload + global.data3;\nflow.set(\"data\", data);\n\nif(msg.topic == \"alt\"){\n msg.payload = {\n \"name\": \"SIMULU\",\n \"alt\": data,\n \"layer\": \"gps\"\n }\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 340,
"y": 300,
"wires": [
[
"14927396080798d3"
]
]
},
{
"id": "bd958146f73af5c1",
"type": "ui_button",
"z": "594f4d4bfd9f7699",
"name": "",
"group": "b4ebae93d455bbc5",
"order": 9,
"width": 6,
"height": 1,
"passthru": false,
"label": "up",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "up",
"topicType": "str",
"x": 370,
"y": 40,
"wires": [
[
"bb2883299b8bc021"
]
]
},
{
"id": "83cee2bda843d0d2",
"type": "ui_button",
"z": "594f4d4bfd9f7699",
"name": "",
"group": "b4ebae93d455bbc5",
"order": 11,
"width": 6,
"height": 1,
"passthru": false,
"label": "down",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "down",
"topicType": "str",
"x": 370,
"y": 100,
"wires": [
[
"bb2883299b8bc021"
]
]
},
{
"id": "03aa2f6ba41795a5",
"type": "ui_button",
"z": "594f4d4bfd9f7699",
"name": "",
"group": "b4ebae93d455bbc5",
"order": 13,
"width": 6,
"height": 1,
"passthru": false,
"label": "left",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "left",
"topicType": "str",
"x": 370,
"y": 220,
"wires": [
[
"bb2883299b8bc021"
]
]
},
{
"id": "7347a00f5de4aab0",
"type": "ui_button",
"z": "594f4d4bfd9f7699",
"name": "",
"group": "b4ebae93d455bbc5",
"order": 15,
"width": 6,
"height": 1,
"passthru": false,
"label": "right",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "right",
"topicType": "str",
"x": 450,
"y": 260,
"wires": [
[
"bb2883299b8bc021"
]
]
},
{
"id": "da5162007f53f84a",
"type": "ui_spacer",
"z": "594f4d4bfd9f7699",
"name": "spacer",
"group": "b4ebae93d455bbc5",
"order": 5,
"width": 2,
"height": 1
},
{
"id": "568ad55514974f76",
"type": "ui_spacer",
"z": "594f4d4bfd9f7699",
"name": "spacer",
"group": "b4ebae93d455bbc5",
"order": 7,
"width": 2,
"height": 1
},
{
"id": "9ee37cbae16930aa",
"type": "ui_spacer",
"z": "594f4d4bfd9f7699",
"name": "spacer",
"group": "b4ebae93d455bbc5",
"order": 8,
"width": 8,
"height": 1
},
{
"id": "40a1fbfb8a719908",
"type": "ui_spacer",
"z": "594f4d4bfd9f7699",
"name": "spacer",
"group": "b4ebae93d455bbc5",
"order": 10,
"width": 2,
"height": 1
},
{
"id": "a74ca6865dd325b5",
"type": "ui_spacer",
"z": "594f4d4bfd9f7699",
"name": "spacer",
"group": "b4ebae93d455bbc5",
"order": 12,
"width": 2,
"height": 1
},
{
"id": "5e21a558c6013ca5",
"type": "ui_spacer",
"z": "594f4d4bfd9f7699",
"name": "spacer",
"group": "b4ebae93d455bbc5",
"order": 14,
"width": 2,
"height": 1
},
{
"id": "e51b7d57e134cb2b",
"type": "ui_spacer",
"z": "594f4d4bfd9f7699",
"name": "spacer",
"group": "b4ebae93d455bbc5",
"order": 16,
"width": 2,
"height": 1
},
{
"id": "519946621d2895f0",
"type": "ui_spacer",
"z": "594f4d4bfd9f7699",
"name": "spacer",
"group": "b4ebae93d455bbc5",
"order": 17,
"width": 8,
"height": 1
},
{
"id": "921f688b0cf3e211",
"type": "ui_spacer",
"z": "594f4d4bfd9f7699",
"name": "spacer",
"group": "b4ebae93d455bbc5",
"order": 18,
"width": 8,
"height": 1
},
{
"id": "b4ebae93d455bbc5",
"type": "ui_group",
"name": "UAV Flight Control",
"tab": "37a720198b072daf",
"order": 1,
"disp": true,
"width": 17,
"collapse": false,
"className": ""
},
{
"id": "37a720198b072daf",
"type": "ui_tab",
"name": "Flight_Control",
"icon": "dashboard",
"order": 2,
"disabled": false,
"hidden": false
}
]