I created a Flow for the basics of Visca control for PTZ cameras, but it soon became apparent that I really needed a joystick for a more human feel to the camera movements.
Having looked for a few hours, I came across a bit of C Code written by Jason White some years ago.
It took me less than 30 seconds to get the code up and running on an Odroid C4, running Diet-Pi and Node-RED, installed from the dietpi-software menu.
Starting the app from within Node-RED gave me all the events I needed.
When connected with a basic Thrustmaster joystick, this flow takes the event data from a slightly tweaked version of Jason's code and turns it into :-
-
Main Axis
- Raw X&Y data
- Compass position (8 point)
- Direction in degrees
- Pan and Tilt % (as in, Tilt = % of forward or back travel)
-
Throttle position
- Value between 0 and 65534
- % value
-
Thumb joystick (Binary)
- 4 compass points and Center
-
All other button events
- This thrustmaster has 4 buttons, but the app and flow will output whatever is available
-
Any other Axis data should be available for you to do something with, just by changing / copying the main function node (I've added notes in the function to help me remember what each section does, so that should help anyone expand the features)
The tweaked version of the C-Code is saved in the Comment node.
With instructions on how to compile
Just save it to your machine and compile it.
(I run it as root because I'm lazy and I know the machine is safe, you may have to grant permissions to the HID device path if using a different user to start Node-RED)
