JoyStick mouseup send false

How do I make a boolean converter send false when I stop dragging the JoyStick?

My flow:

[
    {
        "id": "11ef2821d88603d2",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "63cfafe0c040a2fc",
        "type": "ui_joystick",
        "z": "11ef2821d88603d2",
        "name": "JoyStick Guindaste",
        "group": "e5316a08cde9d3cd",
        "order": 2,
        "width": "4",
        "height": "4",
        "trigger": "all",
        "timeInterval": "250",
        "useThemeColor": true,
        "color": "#7b73c9",
        "threshold": "0.1",
        "directions": "all",
        "shape": "circle",
        "centerAtRelease": true,
        "x": 90,
        "y": 440,
        "wires": [
            [
                "a23c6c5d9724fc2d"
            ]
        ]
    },
    {
        "id": "a23c6c5d9724fc2d",
        "type": "switch",
        "z": "11ef2821d88603d2",
        "name": "payload.direction.angle",
        "property": "payload.direction.angle",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "up",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "down",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "left",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "right",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 4,
        "x": 330,
        "y": 440,
        "wires": [
            [
                "5d7ff6244b22d18f"
            ],
            [
                "799a8c22a9b4ae43"
            ],
            [
                "272198d933e1974e"
            ],
            [
                "60a61d31a99a5f7f"
            ]
        ],
        "outputLabels": [
            "up",
            "down",
            "left",
            "right"
        ]
    },
    {
        "id": "60a61d31a99a5f7f",
        "type": "change",
        "z": "11ef2821d88603d2",
        "name": "Right",
        "rules": [
            {
                "t": "set",
                "p": "pan_speed",
                "pt": "msg",
                "to": "0.5",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "action",
                "pt": "msg",
                "to": "continuousMove",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 500,
        "wires": [
            [
                "fa66599e5c187151"
            ]
        ]
    },
    {
        "id": "272198d933e1974e",
        "type": "change",
        "z": "11ef2821d88603d2",
        "name": "Left",
        "rules": [
            {
                "t": "set",
                "p": "pan_speed",
                "pt": "msg",
                "to": "-0.5",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "action",
                "pt": "msg",
                "to": "continuousMove",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 440,
        "wires": [
            [
                "dbd90cde6b66283c"
            ]
        ]
    },
    {
        "id": "5d7ff6244b22d18f",
        "type": "change",
        "z": "11ef2821d88603d2",
        "name": "Up",
        "rules": [
            {
                "t": "set",
                "p": "tilt_speed",
                "pt": "msg",
                "to": "0.5",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "action",
                "pt": "msg",
                "to": "continuousMove",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 320,
        "wires": [
            [
                "77fddacc6df05fb6"
            ]
        ]
    },
    {
        "id": "799a8c22a9b4ae43",
        "type": "change",
        "z": "11ef2821d88603d2",
        "name": "Down",
        "rules": [
            {
                "t": "set",
                "p": "tilt_speed",
                "pt": "msg",
                "to": "-0.5",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "action",
                "pt": "msg",
                "to": "continuousMove",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 380,
        "wires": [
            [
                "cd87d231de89c4f5"
            ]
        ]
    },
    {
        "id": "77fddacc6df05fb6",
        "type": "convert",
        "z": "11ef2821d88603d2",
        "name": "",
        "convertTo": "boolean (0/1)",
        "x": 730,
        "y": 320,
        "wires": [
            [
                "8efc3bb0bb7930c9"
            ]
        ]
    },
    {
        "id": "cd87d231de89c4f5",
        "type": "convert",
        "z": "11ef2821d88603d2",
        "name": "",
        "convertTo": "boolean (0/1)",
        "x": 730,
        "y": 380,
        "wires": [
            []
        ]
    },
    {
        "id": "fa66599e5c187151",
        "type": "convert",
        "z": "11ef2821d88603d2",
        "name": "",
        "convertTo": "boolean (0/1)",
        "x": 730,
        "y": 500,
        "wires": [
            []
        ]
    },
    {
        "id": "dbd90cde6b66283c",
        "type": "convert",
        "z": "11ef2821d88603d2",
        "name": "",
        "convertTo": "boolean (0/1)",
        "x": 730,
        "y": 440,
        "wires": [
            []
        ]
    },
    {
        "id": "8efc3bb0bb7930c9",
        "type": "debug",
        "z": "11ef2821d88603d2",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1050,
        "y": 320,
        "wires": []
    },
    {
        "id": "e5316a08cde9d3cd",
        "type": "ui_group",
        "name": "Defaultwefe",
        "tab": "52005453115d197f",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "52005453115d197f",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

@Erissin_Industria4.0,

I cannot import your flow since the 'convert' node is unknown:

Which node is that?

And is this related to your other question?

it's node-red-contrib-convert which hasn't been updated in 3 years.

@BartButenaers This same.

Please don't post the same question twice. That makes it very hard for us to follow up discussions...

Not sure how you can do that by using only core nodes (e.g. Switch, Change, ...).
I have not much time currently, so I have quickly implemented some javascript code in a function node:

var outputMessages = [
    {payload:false},
    {payload:false},
    {payload:false},
    {payload:false}
]

switch(msg.payload.direction.angle) {
    case "up":
        outputMessages[0].payload = true;
        break;
    case "down":
        outputMessages[1].payload = true;
        break;        
    case "left":
        outputMessages[2].payload = true;
        break;               
    case "right":
        outputMessages[3].payload = true;
        break; 
}

return outputMessages

So this function node sets all four outputs to false, except the output corresponding to the current direction of the joystick (which will be set to true).

Here is the entire example flow:

[{"id":"5c323378554328d3","type":"ui_joystick","z":"9f5b31e2750b166b","name":"JoyStick Guindaste","group":"e5316a08cde9d3cd","order":2,"width":"4","height":"4","trigger":"all","timeInterval":"250","useThemeColor":true,"color":"#7b73c9","threshold":"0.1","directions":"all","shape":"circle","centerAtRelease":true,"x":230,"y":600,"wires":[["5aaf7468bf8995ca"]]},{"id":"5aaf7468bf8995ca","type":"function","z":"9f5b31e2750b166b","name":"function 1","func":"var outputMessages = [\n    {payload:false},\n    {payload:false},\n    {payload:false},\n    {payload:false}\n]\n\nswitch(msg.payload.direction.angle) {\n    case \"up\":\n        outputMessages[0].payload = true;\n        break;\n    case \"down\":\n        outputMessages[1].payload = true;\n        break;        \n    case \"left\":\n        outputMessages[2].payload = true;\n        break;               \n    case \"right\":\n        outputMessages[3].payload = true;\n        break; \n}\n\nreturn outputMessages;","outputs":4,"noerr":0,"initialize":"// Set all outputs to false at the startup\nnode.send([{payload:false},{payload:false},{payload:false},{payload:false}]);","finalize":"","libs":[],"x":420,"y":600,"wires":[["d97bc44d9d3fc7e6"],["bb73fd55e282de3d"],["e6f694ce8f38609e"],["64738a14d464586f"]],"outputLabels":["Up","Down","Left","Right"]},{"id":"d97bc44d9d3fc7e6","type":"debug","z":"9f5b31e2750b166b","name":"Up","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":590,"y":500,"wires":[]},{"id":"bb73fd55e282de3d","type":"debug","z":"9f5b31e2750b166b","name":"Down","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":590,"y":560,"wires":[]},{"id":"e6f694ce8f38609e","type":"debug","z":"9f5b31e2750b166b","name":"Left","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":590,"y":620,"wires":[]},{"id":"64738a14d464586f","type":"debug","z":"9f5b31e2750b166b","name":"Right","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":590,"y":680,"wires":[]},{"id":"e5316a08cde9d3cd","type":"ui_group","name":"Defaultwefe","tab":"52005453115d197f","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"52005453115d197f","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

And here the demo animation of this flow:
joystick

4 Likes

Ah sorry, thanks for the solution.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.