Browse Source

Add more axid movements, add focus control.

extract-visca-communication-to-class
Ed Walker 6 years ago
parent
commit
31356b25e0
2 changed files with 52 additions and 5 deletions
  1. +3
    -0
      visca-controller/visca-controller.h
  2. +49
    -5
      visca-controller/visca-controller.ino

+ 3
- 0
visca-controller/visca-controller.h View File

@ -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


+ 49
- 5
visca-controller/visca-controller.ino View File

@ -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++)


Loading…
Cancel
Save