From 40ee102fd9814e9504b71f69e4d64246f9b96998 Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:29:35 -0800 Subject: [PATCH 01/16] Update viscalib.cpp Added zoom functions. --- viscalib.cpp | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/viscalib.cpp b/viscalib.cpp index 5ccfd35..1946a61 100644 --- a/viscalib.cpp +++ b/viscalib.cpp @@ -139,4 +139,102 @@ void ViscaLib::PAN_TILT_RELATIVE_POSITION(byte speed, int panPosition, int tiltP list[12] = signedtiltPosition_byte2 & 0x0F; sendList(list, sizeof(list) / sizeof(list[0])); -} \ No newline at end of file +} + +void ViscaLib::ZOOM_TELE_STANDARD(){ + byte list[4] = {0x01, 0x04, 0x07, 0x02}; + sendList(list, sizeof(list) / sizeof(list[0])); +} + +void ViscaLib::ZOOM_WIDE_STANDARD(){ + byte list[4] = {0x01, 0x04, 0x07, 0x03}; + sendList(list, sizeof(list) / sizeof(list[0])); +} + +void ViscaLib::ZOOM_TELE_VARIABLE(byte speed){ + speed = constrain(speed, 0, 7); + byte list[4] = {0x01, 0x04, 0x07, 0x00}; + list[3] = 0x20 + speed; + sendList(list, sizeof(list) / sizeof(list[0])); +} + +void ViscaLib::ZOOM_WIDE_VARIABLE(byte speed){ + speed = constrain(speed, 0, 7); + byte list[4] = {0x01, 0x04, 0x07, 0x00}; + list[3] = 0x30 + speed; + sendList(list, sizeof(list) / sizeof(list[0])); +} + +void ViscaLib::ZOOM_STOP(){ + byte list[4] = {0x01, 0x04, 0x07, 0x00}; + sendList(list, sizeof(list) / sizeof(list[0])); +} + +void ViscaLib::ZOOM_DIRECT(unsigned int zoomPosition){ + zoomPosition = constrain(zoomPosition, 0, 0x4000); + byte list[7] = {0x01, 0x04, 0x47, 0x00, 0x00, 0x00, 0x00}; + list[3] = (zoomPosition & 0xF000) >> 12; + list[4] = (zoomPosition & 0x0F00) >> 8; + list[5] = (zoomPosition & 0x00F0) >> 4; + list[6] = (zoomPosition & 0x000F); + + sendList(list, sizeof(list) / sizeof(list[0])); +} + +unsigned int ViscaLib::QUERY_ZOOM(){ + byte list[3] = {0x09, 0x04, 0x47}; + unsigned long startTime = millis(); + byte currentByte; + byte dataStream[4]; + unsigned int val; + sendList(list, sizeof(list) / sizeof(list[0])); + while(!_serial.available()){ + if(millis() - startTime > 1000){ + return 0xffff; + } + } + while(currentByte != 0xff){ + if(_serial.available()){ + currentByte = _serial.read(); + if(currentByte == 0xff){ + val = dataStream[3] + 0x10 * dataStream[2] + 0x100 * dataStream[1] + 0x1000 * dataStream[0]; + return val; + }else if (currentByte < 0x10){ + for(int i = 0; i < 3; i++){ + dataStream[i] = dataStream[i + 1]; + } + dataStream[3] = currentByte; + } + }else if(millis() - startTime > 2000){ + return 0xffff; + } + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 13fb98020961fa418ebfd97a1936f49ada44f9f2 Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:31:13 -0800 Subject: [PATCH 02/16] Update viscalib.h Zoom functions added. --- viscalib.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/viscalib.h b/viscalib.h index f9ed1f8..64fee33 100644 --- a/viscalib.h +++ b/viscalib.h @@ -22,10 +22,17 @@ class ViscaLib { void PAN_TILT_SLOW_MODE(bool enable); void PAN_TILT_ABSOLUTE_POSITION(byte speed, int panPosition, int tiltPosition); void PAN_TILT_RELATIVE_POSITION(byte speed, int panPosition, int tiltPosition); - + void ZOOM_TELE_STANDARD(); + void ZOOM_WIDE_STANDARD(); + void ZOOM_TELE_VARIABLE(byte speed); + void ZOOM_WIDE_VARIABLE(byte speed); + void ZOOM_STOP(); + void ZOOM_DIRECT(unsigned int zoomPosition); + unsigned int QUERY_ZOOM(); + private: Stream& _serial; void sendList(byte list[], size_t listsize); }; -#endif // VISCALIB_H \ No newline at end of file +#endif // VISCALIB_H From 2e27af3f140c3872d4ff647a0cfbc127c46fdb4b Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:32:59 -0800 Subject: [PATCH 03/16] Update keywords.txt Zoom functions update --- keywords.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/keywords.txt b/keywords.txt index a8e6276..a6cd6b9 100644 --- a/keywords.txt +++ b/keywords.txt @@ -15,4 +15,10 @@ PAN_TILT_RESET KEYWORD2 PAN_TILT_RAMP_CURVE KEYWORD2 PAN_TILT_SLOW_MODE KEYWORD2 PAN_TILT_ABSOLUTE_POSITION KEYWORD2 -PAN_TILT_RELATIVE_POSITION KEYWORD2 \ No newline at end of file +PAN_TILT_RELATIVE_POSITION KEYWORD2 +ZOOM_TELE_STANDARD KEYWORD2 +ZOOM_WIDE_STANDARD KEYWORD2 +ZOOM_TELE_VARIABLE KEYWORD2 +ZOOM_WIDE_VARIABLE KEYWORD2 +ZOOM_STOP KEYWORD2 +ZOOM_DIRECT KEYWORD2 From 631b649b80f2b911d409270740faa96fd68f29ef Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:40:31 -0800 Subject: [PATCH 04/16] Update README.md --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bb35102..b404abe 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ It will send the following command to the chosen serial interface: ``` ⚠️ **I only tested it on Sony Ipela SNC-RX550** ⚠️ +Also tested with PTZOptics Move SE. ## Installation @@ -66,14 +67,22 @@ void loop() { | `PAN_TILT_SLOW_MODE(x)` | `x: True / False` | | `PAN_TILT_ABSOLUTE_POSITION(s, x, y)` | `s = speed value 1 to 18 ; x = Pan value -8160 to 8160 ; y = Tilt value -2040 to 2040` | | `PAN_TILT_RELATIVE_POSITION(s, x, y)` | `s = speed value 1 to 18 ; x = Pan value -8160 to 8160 ; y = Tilt value -2040 to 2040` | +| `ZOOM_TELE_STANDARD()` | `none`| +| `ZOOM_WIDE_STANDARD()` | `none` | +| `ZOOM_TELE_VARIABLE(s)` | `s = speed value 1 to 7` | +| `ZOOM_WIDE_VARIABLE(s)` | `s = speed value 1 to 7` | +| `ZOOM_STOP()` | `none` | +| `ZOOM_DIRECT(z)` | `z = zoom position 0 to 16384` | +| `ZOOM_QUERY()` | `none` | ## Authors - [Unix5](https://unix5.net) +- Omnia Et Nihil https://www.youtube.com/@omnia8838 ## License GNU General Public License v3.0 or later -See COPYING to see the full text. \ No newline at end of file +See COPYING to see the full text. From f335b7ce66873dfd36d4bd79f5463eb180a5526a Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:40:51 -0800 Subject: [PATCH 05/16] Update keywords.txt --- keywords.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/keywords.txt b/keywords.txt index a6cd6b9..1c560f9 100644 --- a/keywords.txt +++ b/keywords.txt @@ -22,3 +22,4 @@ ZOOM_TELE_VARIABLE KEYWORD2 ZOOM_WIDE_VARIABLE KEYWORD2 ZOOM_STOP KEYWORD2 ZOOM_DIRECT KEYWORD2 +ZOOM_QUERY KEYWORD2 From e4d3fa8722af0d2e795699a8800b1bae73010f95 Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:41:09 -0800 Subject: [PATCH 06/16] Update keywords.txt --- keywords.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keywords.txt b/keywords.txt index 1c560f9..44681b4 100644 --- a/keywords.txt +++ b/keywords.txt @@ -22,4 +22,4 @@ ZOOM_TELE_VARIABLE KEYWORD2 ZOOM_WIDE_VARIABLE KEYWORD2 ZOOM_STOP KEYWORD2 ZOOM_DIRECT KEYWORD2 -ZOOM_QUERY KEYWORD2 +QUERY_ZOOM KEYWORD2 From 9ee9df7dd7d93bb6f373d8b0e21d765e48534dbb Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:41:29 -0800 Subject: [PATCH 07/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b404abe..15ba3a6 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ void loop() { | `ZOOM_WIDE_VARIABLE(s)` | `s = speed value 1 to 7` | | `ZOOM_STOP()` | `none` | | `ZOOM_DIRECT(z)` | `z = zoom position 0 to 16384` | -| `ZOOM_QUERY()` | `none` | +| `QUERY_ZOOM()` | `none` | ## Authors From c8d5acdb6803fa2203571b6b1d7bd011a57c086f Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:42:20 -0800 Subject: [PATCH 08/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15ba3a6..271e621 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ void loop() { ## Authors - [Unix5](https://unix5.net) -- Omnia Et Nihil https://www.youtube.com/@omnia8838 +- [Omnia Et Nihil].(https://www.youtube.com/@omnia8838) ## License From 4db57189653e3ddb5b6776522342fca7e48e35b6 Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:42:50 -0800 Subject: [PATCH 09/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 271e621..c7765be 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ void loop() { ## Authors - [Unix5](https://unix5.net) -- [Omnia Et Nihil].(https://www.youtube.com/@omnia8838) +- [Omnia Et Nihil](https://www.youtube.com/@omnia8838) ## License From a58c6c43656b93a7d06fddb448cc7b5428971223 Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:44:28 -0800 Subject: [PATCH 10/16] Rename sweep.ino to sweep.ino --- {exemple => example}/sweep/sweep.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {exemple => example}/sweep/sweep.ino (99%) diff --git a/exemple/sweep/sweep.ino b/example/sweep/sweep.ino similarity index 99% rename from exemple/sweep/sweep.ino rename to example/sweep/sweep.ino index f17dc65..a0934e9 100644 --- a/exemple/sweep/sweep.ino +++ b/example/sweep/sweep.ino @@ -15,4 +15,4 @@ void loop() { myVisca.PAN_TILT_RIGHT(5); // Send a PAN_TILT_RIGHT command with a speed of 5 (adjust speed as needed). delay(1000); // Wait 1 second. -} \ No newline at end of file +} From 6074a25ed7213d89907d3042793062f396511aee Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:48:41 -0800 Subject: [PATCH 11/16] Update viscalib.cpp --- viscalib.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/viscalib.cpp b/viscalib.cpp index 1946a61..1a4a35c 100644 --- a/viscalib.cpp +++ b/viscalib.cpp @@ -181,7 +181,76 @@ void ViscaLib::ZOOM_DIRECT(unsigned int zoomPosition){ sendList(list, sizeof(list) / sizeof(list[0])); } +int ViscaLib::QUERY_PAN_POSITION(){ + while(_serial.available()){ + _serial.read(); + } + byte list[3] = {0x09, 0x06, 0x12}; + unsigned long startTime = millis(); + byte currentByte; + byte dataStream[10]; + int val; + sendList(list, sizeof(list) / sizeof(list[0])); + while(!_serial.available()){ + if(millis() - startTime > 1000){ + return 0xffff; + } + } + while(currentByte != 0xff){ + if(_serial.available()){ + currentByte = _serial.read(); + if(currentByte == 0xff){ + val = dataStream[5] | (dataStream[4] << 4) | (dataStream[3] << 8) | (dataStream[2] << 12); + return val; + }else{ + for(int i = 0; i < 9; i++){ + dataStream[i] = dataStream[i + 1]; + } + dataStream[9] = currentByte; + } + }else if(millis() - startTime > 2000){ + return 0xffff; + } + } +} + +int ViscaLib::QUERY_TILT_POSITION(){ + while(_serial.available()){ + _serial.read(); + } + byte list[3] = {0x09, 0x06, 0x12}; + unsigned long startTime = millis(); + byte currentByte; + byte dataStream[10]; + int val; + sendList(list, sizeof(list) / sizeof(list[0])); + while(!_serial.available()){ + if(millis() - startTime > 1000){ + return 0xffff; + } + } + while(currentByte != 0xff){ + if(_serial.available()){ + currentByte = _serial.read(); + if(currentByte == 0xff){ + val = dataStream[9] | (dataStream[8] << 4) | (dataStream[7] << 8) | (dataStream[6] << 12); + return val; + }else{ + for(int i = 0; i < 9; i++){ + dataStream[i] = dataStream[i + 1]; + } + dataStream[9] = currentByte; + } + }else if(millis() - startTime > 2000){ + return 0xffff; + } + } +} + unsigned int ViscaLib::QUERY_ZOOM(){ + while(_serial.available()){ + _serial.read(); + } byte list[3] = {0x09, 0x04, 0x47}; unsigned long startTime = millis(); byte currentByte; From 9f5c58129e4b90092168200709341482aad06e0f Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:48:57 -0800 Subject: [PATCH 12/16] Update viscalib.h --- viscalib.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/viscalib.h b/viscalib.h index 64fee33..2b3c4ed 100644 --- a/viscalib.h +++ b/viscalib.h @@ -28,6 +28,8 @@ class ViscaLib { void ZOOM_WIDE_VARIABLE(byte speed); void ZOOM_STOP(); void ZOOM_DIRECT(unsigned int zoomPosition); + int QUERY_PAN_POSITION(); + int QUERY_TILT_POSITION(); unsigned int QUERY_ZOOM(); private: From b12617b62f0867afd5f75fc1dbf507ca4d5e2814 Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:49:45 -0800 Subject: [PATCH 13/16] Update keywords.txt --- keywords.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/keywords.txt b/keywords.txt index 44681b4..ec599f1 100644 --- a/keywords.txt +++ b/keywords.txt @@ -22,4 +22,6 @@ ZOOM_TELE_VARIABLE KEYWORD2 ZOOM_WIDE_VARIABLE KEYWORD2 ZOOM_STOP KEYWORD2 ZOOM_DIRECT KEYWORD2 +QUERY_PAN KEYWORD2 +QUERY_TILT KEYWORD2 QUERY_ZOOM KEYWORD2 From 7c9e97e100a0f9417c5a69151e18f9cc7e3a437c Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:50:23 -0800 Subject: [PATCH 14/16] Update keywords.txt --- keywords.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keywords.txt b/keywords.txt index ec599f1..265004c 100644 --- a/keywords.txt +++ b/keywords.txt @@ -22,6 +22,6 @@ ZOOM_TELE_VARIABLE KEYWORD2 ZOOM_WIDE_VARIABLE KEYWORD2 ZOOM_STOP KEYWORD2 ZOOM_DIRECT KEYWORD2 -QUERY_PAN KEYWORD2 -QUERY_TILT KEYWORD2 +QUERY_PAN_POSITION KEYWORD2 +QUERY_TILT_POSITION KEYWORD2 QUERY_ZOOM KEYWORD2 From 5fa8da09917d6e9de2dd07100816311f1ea12673 Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:51:48 -0800 Subject: [PATCH 15/16] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c7765be..52a876c 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ void loop() { | `ZOOM_WIDE_VARIABLE(s)` | `s = speed value 1 to 7` | | `ZOOM_STOP()` | `none` | | `ZOOM_DIRECT(z)` | `z = zoom position 0 to 16384` | +| `QUERY_PAN_POSITION()` | `none` | +| `QUERY_TILT_POSITION()` | `none` | | `QUERY_ZOOM()` | `none` | ## Authors From 55f5dd3c06e6854ecf7d9c9269f42dbd34a70538 Mon Sep 17 00:00:00 2001 From: Omnia-et-nihil <113312458+Omnia-et-nihil@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:56:24 -0800 Subject: [PATCH 16/16] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 52a876c..fe07a6b 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,11 @@ ViscaLib is an Arduino library that allows you to control Visca-compatible PTZ cameras. [![GPLv3 License](https://img.shields.io/badge/License-GPL%20v3-yellow.svg)](https://opensource.org/licenses/) +This is a fork of the library, originally created by Unix5. I(Omnia et Nihil), created this fork to add additional functions. I have only used this library with a PTZOptics Move SE camera. -## How it work ? +This is not a complete VISCA library. It only covers some of the more commonly used functions. + +## How does it work ? This library generates [Visca](https://en.wikipedia.org/wiki/VISCA_Protocol) commands from predefined functions. For example, if you call PAN_TILT_UP(5);