From 31356b25e02f6e19ac7f3be67b61a01de38aa668 Mon Sep 17 00:00:00 2001 From: Ed Walker Date: Sun, 12 Jan 2020 15:24:40 -0800 Subject: [PATCH] Add more axid movements, add focus control. --- visca-controller/visca-controller.h | 3 ++ visca-controller/visca-controller.ino | 54 ++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/visca-controller/visca-controller.h b/visca-controller/visca-controller.h index fa1fada..de9216b 100644 --- a/visca-controller/visca-controller.h +++ b/visca-controller/visca-controller.h @@ -60,6 +60,9 @@ byte zoomPosReq[5] = { 0x81, 0x09, 0x04, 0x47, 0xff }; // Resp: y0 50 0p 0q 0r byte focusAuto[6] = { 0x81, 0x01, 0x04, 0x38, 0x02, 0xff }; byte focusManual[6] = { 0x81, 0x01, 0x04, 0x38, 0x03, 0xff }; byte focusDirect[9] = { 0x81, 0x01, 0x04, 0x48, 0x00, 0x00, 0x00, 0x00, 0xff }; // 8x 01 04 48 0p 0q 0r 0s ff pqrs: focus position +byte focusFar[6] = { 0x81, 0x01, 0x04, 0x08, 0x20, 0xff }; +byte focusNear[6] = { 0x81, 0x01, 0x04, 0x08, 0x30, 0xff }; +byte focusStop[6] = { 0x81, 0x01, 0x04, 0x08, 0x00, 0xff }; byte focusModeInq[5] = { 0x81, 0x09, 0x04, 0x38, 0xff }; // Resp: y0 50 0p ff ; p=2: Auto, p=3: Manual // Iris / Gain diff --git a/visca-controller/visca-controller.ino b/visca-controller/visca-controller.ino index 5aeec43..6e6e7b4 100644 --- a/visca-controller/visca-controller.ino +++ b/visca-controller/visca-controller.ino @@ -26,7 +26,7 @@ void loop() { // int talentDimmer = map(analogRead(TALENT_DIMMER_PIN), 0, 1023, 0, 255); } -void receiveData() { +byte receiveData() { static byte ndx = 0; byte rc; while (visca.available() > 0) { @@ -60,9 +60,14 @@ void readSerial() { char inChar = Serial.read(); // read incoming serial data: switch(inChar) { + +// General/Toggles case '1': initCameras(); break; + case '2': + toggleFocusControl(); + break; case '8': sendViscaPacket(callLedOn, sizeof(callLedOn)); break; @@ -73,22 +78,36 @@ void readSerial() { sendViscaPacket(callLedOff, sizeof(callLedOff)); break; +// Pan/Tilt + case 'q': + sendViscaPacket(panUpLeft, sizeof(panUpLeft)); + break; case 'w': sendViscaPacket(panUp, sizeof(panUp)); break; + case 'e': + sendViscaPacket(panUpRight, sizeof(panUpRight)); + break; case 'a': sendViscaPacket(panLeft, sizeof(panLeft)); break; case 's': - sendViscaPacket(panDown, sizeof(panDown)); + sendViscaPacket(panStop, sizeof(panStop)); break; case 'd': sendViscaPacket(panRight, sizeof(panRight)); break; - case 'q': - sendViscaPacket(panStop, sizeof(panStop)); + case 'z': + sendViscaPacket(panDownLeft, sizeof(panDownLeft)); + break; + case 'x': + sendViscaPacket(panDown, sizeof(panDown)); break; - + case 'c': + sendViscaPacket(panDownRight, sizeof(panDownRight)); + break; + +// Zoom case 'r': sendViscaPacket(zoomTele, sizeof(zoomTele)); break; @@ -98,6 +117,17 @@ void readSerial() { case 'v': sendViscaPacket(zoomWide, sizeof(zoomWide)); break; + +// Focus + case 't': + sendViscaPacket(focusFar, sizeof(focusFar)); + break; + case 'g': + sendViscaPacket(focusStop, sizeof(focusStop)); + break; + case 'b': + sendViscaPacket(focusNear, sizeof(focusNear)); + break; } } } @@ -114,6 +144,20 @@ void readButtons() { } } +void toggleFocusControl() { + sendViscaPacket(focusModeInq, sizeof(focusModeInq)); + delay(100); + receiveData(); + Serial.print("Current Focus Status: "); + if(viscaMessage[2] == 2) { + Serial.println("Auto, Toggling to manual"); + sendViscaPacket(focusManual, sizeof(focusManual)); + } else { + Serial.println("Manual, Toggling to auto"); + sendViscaPacket(focusAuto, sizeof(focusAuto)); + } +} + void sendViscaPacket(byte* packet, int byteSize) { Serial.print("Sending:"); for (int i = 0; i < byteSize; i++)