From 5716802da4778c3c7507e401bba09686e23ceb60 Mon Sep 17 00:00:00 2001 From: cbdev Date: Fri, 14 Aug 2020 23:14:03 +0200 Subject: Initial VISCA backend implementation --- backends/visca.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 backends/visca.h (limited to 'backends/visca.h') diff --git a/backends/visca.h b/backends/visca.h new file mode 100644 index 0000000..54c80f7 --- /dev/null +++ b/backends/visca.h @@ -0,0 +1,57 @@ +#include "midimonster.h" + +MM_PLUGIN_API int init(); +static int ptz_configure(char* option, char* value); +static int ptz_configure_instance(instance* inst, char* option, char* value); +static int ptz_instance(instance* inst); +static channel* ptz_channel(instance* inst, char* spec, uint8_t flags); +static int ptz_set(instance* inst, size_t num, channel** c, channel_value* v); +static int ptz_handle(size_t num, managed_fd* fds); +static int ptz_start(size_t n, instance** inst); +static int ptz_shutdown(size_t n, instance** inst); + +#define VISCA_BUFFER_LENGTH 50 + +typedef struct /*_ptz_instance_data*/ { + int fd; + uint8_t cam_address; + uint32_t x; + uint32_t y; + uint8_t panspeed; + uint8_t tiltspeed; +} ptz_instance_data; + +enum /*ptz_channels*/ { + pan = 0, + tilt, + panspeed, + tiltspeed, + zoom, + focus, + call, + sentinel +}; + +typedef size_t (*ptz_channel_set)(instance*, channel*, channel_value*, uint8_t* msg); +static size_t ptz_set_pantilt(instance* inst, channel* c, channel_value* v, uint8_t* msg); +static size_t ptz_set_ptspeed(instance* inst, channel* c, channel_value* v, uint8_t* msg); +static size_t ptz_set_zoom(instance* inst, channel* c, channel_value* v, uint8_t* msg); +static size_t ptz_set_focus(instance* inst, channel* c, channel_value* v, uint8_t* msg); +static size_t ptz_set_memory(instance* inst, channel* c, channel_value* v, uint8_t* msg); + +static struct { + char* name; + size_t bytes; + uint8_t pattern[VISCA_BUFFER_LENGTH]; + size_t min; + size_t max; + ptz_channel_set set; +} ptz_channels[] = { + [pan] = {"pan", 14, {0x80, 0x01, 0x06, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF}, 0, 4000, ptz_set_pantilt}, + [tilt] = {"tilt", 14, {0x80, 0x01, 0x06, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF}, 0, 4000, ptz_set_pantilt}, + [panspeed] = {"panspeed", 0, {0}, 0x01, 0x18, ptz_set_ptspeed}, + [tiltspeed] = {"tiltspeed", 0, {0}, 0x01, 0x14, ptz_set_ptspeed}, + [zoom] = {"zoom", 9, {0x80, 0x01, 0x04, 0x47, 0, 0, 0, 0, 0xFF}, 0, 4000, ptz_set_zoom}, + [focus] = {"focus", 9, {0x80, 0x01, 0x04, 0x48, 0, 0, 0, 0, 0xFF}, 0, 4000, ptz_set_focus}, + [call] = {"memory", 7, {0x80, 0x01, 0x04, 0x3F, 0x02, 0, 0xFF}, 0, 254, ptz_set_memory} +}; -- cgit v1.2.3 From 9f2deded624e1a934b52ac0d4d33e3612a7fb469 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 12 Sep 2020 19:34:26 +0200 Subject: Fix VISCA dialect --- backends/visca.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'backends/visca.h') diff --git a/backends/visca.h b/backends/visca.h index 54c80f7..09c9057 100644 --- a/backends/visca.h +++ b/backends/visca.h @@ -15,8 +15,8 @@ static int ptz_shutdown(size_t n, instance** inst); typedef struct /*_ptz_instance_data*/ { int fd; uint8_t cam_address; - uint32_t x; - uint32_t y; + uint16_t x; + uint16_t y; uint8_t panspeed; uint8_t tiltspeed; } ptz_instance_data; @@ -29,6 +29,7 @@ enum /*ptz_channels*/ { zoom, focus, call, + store, sentinel }; @@ -38,20 +39,23 @@ static size_t ptz_set_ptspeed(instance* inst, channel* c, channel_value* v, uint static size_t ptz_set_zoom(instance* inst, channel* c, channel_value* v, uint8_t* msg); static size_t ptz_set_focus(instance* inst, channel* c, channel_value* v, uint8_t* msg); static size_t ptz_set_memory(instance* inst, channel* c, channel_value* v, uint8_t* msg); +static size_t ptz_set_memory_store(instance* inst, channel* c, channel_value* v, uint8_t* msg); static struct { char* name; size_t bytes; uint8_t pattern[VISCA_BUFFER_LENGTH]; - size_t min; + size_t min; //channel range = max - min size_t max; + size_t offset; //channel value = normalised * range - offset ptz_channel_set set; } ptz_channels[] = { - [pan] = {"pan", 14, {0x80, 0x01, 0x06, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF}, 0, 4000, ptz_set_pantilt}, - [tilt] = {"tilt", 14, {0x80, 0x01, 0x06, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF}, 0, 4000, ptz_set_pantilt}, - [panspeed] = {"panspeed", 0, {0}, 0x01, 0x18, ptz_set_ptspeed}, - [tiltspeed] = {"tiltspeed", 0, {0}, 0x01, 0x14, ptz_set_ptspeed}, - [zoom] = {"zoom", 9, {0x80, 0x01, 0x04, 0x47, 0, 0, 0, 0, 0xFF}, 0, 4000, ptz_set_zoom}, - [focus] = {"focus", 9, {0x80, 0x01, 0x04, 0x48, 0, 0, 0, 0, 0xFF}, 0, 4000, ptz_set_focus}, - [call] = {"memory", 7, {0x80, 0x01, 0x04, 0x3F, 0x02, 0, 0xFF}, 0, 254, ptz_set_memory} + [pan] = {"pan", 15, {0x80, 0x01, 0x06, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF}, 0, 0x990 * 2, 0x990, ptz_set_pantilt}, + [tilt] = {"tilt", 15, {0x80, 0x01, 0x06, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF}, 0, 0x510 * 2, 0x510, ptz_set_pantilt}, + [panspeed] = {"panspeed", 0, {0}, 0x01, 0x18, 0, ptz_set_ptspeed}, + [tiltspeed] = {"tiltspeed", 0, {0}, 0x01, 0x14, 0, ptz_set_ptspeed}, + [zoom] = {"zoom", 9, {0x80, 0x01, 0x04, 0x47, 0, 0, 0, 0, 0xFF}, 0, 0x4000, 0, ptz_set_zoom}, + [focus] = {"focus", 9, {0x80, 0x01, 0x04, 0x48, 0, 0, 0, 0, 0xFF}, 0, 0x4000, 0, ptz_set_focus}, + [call] = {"memory", 7, {0x80, 0x01, 0x04, 0x3F, 0x02, 0, 0xFF}, 0, 254, 0, ptz_set_memory}, + [store] = {"store", 7, {0x80, 0x01, 0x04, 0x3F, 0x01, 0, 0xFF}, 0, 254, 0, ptz_set_memory_store} }; -- cgit v1.2.3 From d45ca2422fd5bedf48d68a3a537bae924b0cbae7 Mon Sep 17 00:00:00 2001 From: cbdev Date: Fri, 18 Sep 2020 20:12:53 +0200 Subject: Implement additional VISCA channels --- backends/visca.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'backends/visca.h') diff --git a/backends/visca.h b/backends/visca.h index 09c9057..481f5c7 100644 --- a/backends/visca.h +++ b/backends/visca.h @@ -28,8 +28,14 @@ enum /*ptz_channels*/ { tiltspeed, zoom, focus, + focus_mode, + wb_red, + wb_blue, + wb_mode, call, store, + home, + stop, sentinel }; @@ -38,9 +44,15 @@ static size_t ptz_set_pantilt(instance* inst, channel* c, channel_value* v, uint static size_t ptz_set_ptspeed(instance* inst, channel* c, channel_value* v, uint8_t* msg); static size_t ptz_set_zoom(instance* inst, channel* c, channel_value* v, uint8_t* msg); static size_t ptz_set_focus(instance* inst, channel* c, channel_value* v, uint8_t* msg); +static size_t ptz_set_focus_mode(instance* inst, channel* c, channel_value* v, uint8_t* msg); +static size_t ptz_set_wb_mode(instance* inst, channel* c, channel_value* v, uint8_t* msg); +static size_t ptz_set_wb(instance* inst, channel* c, channel_value* v, uint8_t* msg); static size_t ptz_set_memory(instance* inst, channel* c, channel_value* v, uint8_t* msg); static size_t ptz_set_memory_store(instance* inst, channel* c, channel_value* v, uint8_t* msg); +//relative move test +static size_t ptz_set_stop(instance* inst, channel* c, channel_value* v, uint8_t* msg); + static struct { char* name; size_t bytes; @@ -56,6 +68,13 @@ static struct { [tiltspeed] = {"tiltspeed", 0, {0}, 0x01, 0x14, 0, ptz_set_ptspeed}, [zoom] = {"zoom", 9, {0x80, 0x01, 0x04, 0x47, 0, 0, 0, 0, 0xFF}, 0, 0x4000, 0, ptz_set_zoom}, [focus] = {"focus", 9, {0x80, 0x01, 0x04, 0x48, 0, 0, 0, 0, 0xFF}, 0, 0x4000, 0, ptz_set_focus}, + [focus_mode] = {"autofocus", 6, {0x80, 0x01, 0x04, 0x38, 0, 0xFF}, 0, 1, 0, ptz_set_focus_mode}, + [wb_mode] = {"wb.auto", 6, {0x80, 0x01, 0x04, 0x35, 0, 0xFF}, 0, 1, 0, ptz_set_wb_mode}, + [wb_red] = {"wb.red", 9, {0x80, 0x01, 0x04, 0x43, 0x00, 0x00, 0, 0, 0xFF}, 0, 255, 0, ptz_set_wb}, + [wb_blue] = {"wb.blue", 9, {0x80, 0x01, 0x04, 0x44, 0x00, 0x00, 0, 0, 0xFF}, 0, 255, 0, ptz_set_wb}, [call] = {"memory", 7, {0x80, 0x01, 0x04, 0x3F, 0x02, 0, 0xFF}, 0, 254, 0, ptz_set_memory}, - [store] = {"store", 7, {0x80, 0x01, 0x04, 0x3F, 0x01, 0, 0xFF}, 0, 254, 0, ptz_set_memory_store} + [store] = {"store", 7, {0x80, 0x01, 0x04, 0x3F, 0x01, 0, 0xFF}, 0, 254, 0, ptz_set_memory_store}, + [home] = {"home", 5, {0x80, 0x01, 0x06, 0x04, 0xFF}, 0, 0, 0, NULL}, + //relative move test + [stop] = {"stop", 9, {0x80, 0x01, 0x06, 0x01, 0, 0, 0x03, 0x03, 0xFF}, 0, 0, 0, ptz_set_stop} }; -- cgit v1.2.3 From 7d3bde27e412ebb6783c2c94f52a08f0e8d8ba49 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 19 Sep 2020 01:09:43 +0200 Subject: Fix VISCA channel parser --- backends/visca.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'backends/visca.h') diff --git a/backends/visca.h b/backends/visca.h index 481f5c7..160398d 100644 --- a/backends/visca.h +++ b/backends/visca.h @@ -22,10 +22,12 @@ typedef struct /*_ptz_instance_data*/ { } ptz_instance_data; enum /*ptz_channels*/ { - pan = 0, - tilt, - panspeed, + //channels with a name that includes another channels as prefix + //go first so the channel matching logic works + panspeed = 0, tiltspeed, + pan, + tilt, zoom, focus, focus_mode, @@ -62,10 +64,10 @@ static struct { size_t offset; //channel value = normalised * range - offset ptz_channel_set set; } ptz_channels[] = { - [pan] = {"pan", 15, {0x80, 0x01, 0x06, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF}, 0, 0x990 * 2, 0x990, ptz_set_pantilt}, - [tilt] = {"tilt", 15, {0x80, 0x01, 0x06, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF}, 0, 0x510 * 2, 0x510, ptz_set_pantilt}, [panspeed] = {"panspeed", 0, {0}, 0x01, 0x18, 0, ptz_set_ptspeed}, [tiltspeed] = {"tiltspeed", 0, {0}, 0x01, 0x14, 0, ptz_set_ptspeed}, + [pan] = {"pan", 15, {0x80, 0x01, 0x06, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF}, 0, 0x990 * 2, 0x990, ptz_set_pantilt}, + [tilt] = {"tilt", 15, {0x80, 0x01, 0x06, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF}, 0, 0x510 * 2, 0x510, ptz_set_pantilt}, [zoom] = {"zoom", 9, {0x80, 0x01, 0x04, 0x47, 0, 0, 0, 0, 0xFF}, 0, 0x4000, 0, ptz_set_zoom}, [focus] = {"focus", 9, {0x80, 0x01, 0x04, 0x48, 0, 0, 0, 0, 0xFF}, 0, 0x4000, 0, ptz_set_focus}, [focus_mode] = {"autofocus", 6, {0x80, 0x01, 0x04, 0x38, 0, 0xFF}, 0, 1, 0, ptz_set_focus_mode}, -- cgit v1.2.3 From 588503226ff61c2a440f19e050691af93cef0f5f Mon Sep 17 00:00:00 2001 From: cbdev Date: Fri, 9 Oct 2020 23:17:41 +0200 Subject: Implement VISCA relative movement --- backends/visca.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'backends/visca.h') diff --git a/backends/visca.h b/backends/visca.h index 160398d..47ada19 100644 --- a/backends/visca.h +++ b/backends/visca.h @@ -12,6 +12,15 @@ static int ptz_shutdown(size_t n, instance** inst); #define VISCA_BUFFER_LENGTH 50 +enum /*_ptz_relmove_channel */ { + rel_up = 1, + rel_down = 2, + rel_left = 4, + rel_right = 8, + rel_x = 3, + rel_y = 12 +}; + typedef struct /*_ptz_instance_data*/ { int fd; uint8_t cam_address; @@ -19,6 +28,8 @@ typedef struct /*_ptz_instance_data*/ { uint16_t y; uint8_t panspeed; uint8_t tiltspeed; + uint8_t relative_movement; + double deadzone; } ptz_instance_data; enum /*ptz_channels*/ { @@ -38,6 +49,7 @@ enum /*ptz_channels*/ { store, home, stop, + relmove, sentinel }; @@ -51,9 +63,7 @@ static size_t ptz_set_wb_mode(instance* inst, channel* c, channel_value* v, uint static size_t ptz_set_wb(instance* inst, channel* c, channel_value* v, uint8_t* msg); static size_t ptz_set_memory(instance* inst, channel* c, channel_value* v, uint8_t* msg); static size_t ptz_set_memory_store(instance* inst, channel* c, channel_value* v, uint8_t* msg); - -//relative move test -static size_t ptz_set_stop(instance* inst, channel* c, channel_value* v, uint8_t* msg); +static size_t ptz_set_relmove(instance* inst, channel* c, channel_value* v, uint8_t* msg); static struct { char* name; @@ -77,6 +87,6 @@ static struct { [call] = {"memory", 7, {0x80, 0x01, 0x04, 0x3F, 0x02, 0, 0xFF}, 0, 254, 0, ptz_set_memory}, [store] = {"store", 7, {0x80, 0x01, 0x04, 0x3F, 0x01, 0, 0xFF}, 0, 254, 0, ptz_set_memory_store}, [home] = {"home", 5, {0x80, 0x01, 0x06, 0x04, 0xFF}, 0, 0, 0, NULL}, - //relative move test - [stop] = {"stop", 9, {0x80, 0x01, 0x06, 0x01, 0, 0, 0x03, 0x03, 0xFF}, 0, 0, 0, ptz_set_stop} + [relmove] = {"move", 9, {0x80, 0x01, 0x06, 0x01, 0, 0, 0, 0, 0xFF}, 0, 1, 0, ptz_set_relmove}, + [stop] = {"stop", 9, {0x80, 0x01, 0x06, 0x01, 0, 0, 0x03, 0x03, 0xFF}, 0, 0, 0, ptz_set_relmove} }; -- cgit v1.2.3 From 71d86ec46259ce1b5488989ec30152c7cf810a8e Mon Sep 17 00:00:00 2001 From: cbdev Date: Fri, 15 Jan 2021 23:49:12 +0100 Subject: Fix static analysis failures --- backends/visca.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'backends/visca.h') diff --git a/backends/visca.h b/backends/visca.h index 47ada19..1004076 100644 --- a/backends/visca.h +++ b/backends/visca.h @@ -88,5 +88,6 @@ static struct { [store] = {"store", 7, {0x80, 0x01, 0x04, 0x3F, 0x01, 0, 0xFF}, 0, 254, 0, ptz_set_memory_store}, [home] = {"home", 5, {0x80, 0x01, 0x06, 0x04, 0xFF}, 0, 0, 0, NULL}, [relmove] = {"move", 9, {0x80, 0x01, 0x06, 0x01, 0, 0, 0, 0, 0xFF}, 0, 1, 0, ptz_set_relmove}, - [stop] = {"stop", 9, {0x80, 0x01, 0x06, 0x01, 0, 0, 0x03, 0x03, 0xFF}, 0, 0, 0, ptz_set_relmove} + [stop] = {"stop", 9, {0x80, 0x01, 0x06, 0x01, 0, 0, 0x03, 0x03, 0xFF}, 0, 0, 0, ptz_set_relmove}, + [sentinel] = {"SENTINEL"} }; -- cgit v1.2.3 From db76143dfff9aa69318273010fe2922c1e60ea4c Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 16 May 2021 17:09:23 +0200 Subject: Fix VISCA serial output (Fixes #91) --- backends/visca.h | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/visca.h') diff --git a/backends/visca.h b/backends/visca.h index 1004076..1b8c0e5 100644 --- a/backends/visca.h +++ b/backends/visca.h @@ -30,6 +30,7 @@ typedef struct /*_ptz_instance_data*/ { uint8_t tiltspeed; uint8_t relative_movement; double deadzone; + uint8_t direct_device; } ptz_instance_data; enum /*ptz_channels*/ { -- cgit v1.2.3 From 9be900acd86e03c73266c552db133562005f5607 Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 28 Jun 2021 21:46:55 +0200 Subject: Enhance visca relative movement --- backends/visca.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'backends/visca.h') diff --git a/backends/visca.h b/backends/visca.h index 1b8c0e5..37f21b1 100644 --- a/backends/visca.h +++ b/backends/visca.h @@ -17,8 +17,8 @@ enum /*_ptz_relmove_channel */ { rel_down = 2, rel_left = 4, rel_right = 8, - rel_x = 3, - rel_y = 12 + rel_x = rel_up | rel_down, + rel_y = rel_left | rel_right }; typedef struct /*_ptz_instance_data*/ { @@ -26,8 +26,8 @@ typedef struct /*_ptz_instance_data*/ { uint8_t cam_address; uint16_t x; uint16_t y; - uint8_t panspeed; - uint8_t tiltspeed; + uint8_t max_pan, max_tilt; + double factor_pan, factor_tilt; uint8_t relative_movement; double deadzone; uint8_t direct_device; -- cgit v1.2.3