I've gotten my hands on a PTZ Camera which can be controlled via serial communication through 8 hex byte strings (proper term?) That is, I send the following commands to perform their operations:
char halt[8] = {0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf, 0x0f};
byte sup[8] = {0xa0, 0x00, 0x00, 0x08, 0x00, 0x20, 0xaf, 0x27};
byte sdown[8] = {0xa0, 0x00, 0x00, 0x10, 0x00, 0x20, 0xaf, 0x3f};
byte sleft[8] = {0xa0, 0x00, 0x00, 0x04, 0x20, 0x00, 0xaf, 0x2b};
byte sright[8] = {0xa0, 0x00, 0x00, 0x02, 0x20, 0x00, 0xaf, 0x2d};
byte sfocusin[8] = {0xa0, 0x00, 0x02, 0x00, 0x00, 0x00, 0xaf, 0x0d};
byte sfocusout[8] = {0xa0, 0x00, 0x01, 0x00, 0x00, 0x00, 0xaf, 0x0e};
byte szoomin[8] = {0xa0, 0x00, 0x00, 0x20, 0x00, 0x00, 0xaf, 0x2f};
byte szoomout[8] = {0xa0, 0x00, 0x00, 0x40, 0x00, 0x00, 0xaf, 0x4f};
byte sirisin[8] = {0xa0, 0x00, 0x04, 0x00, 0x00, 0x00, 0xaf, 0x0b};
byte sirisout[8] = {0xa0, 0x00, 0x08, 0x00, 0x00, 0x00, 0xaf, 0x07};
byte fleft[8] = {0xa0, 0x00, 0x00, 0x04, 0x40, 0x00, 0xaf, 0x4B};
Bytes 1, 2 and 7 are always constant (A0,00,AF) but bytes 3-6 control the nature of the camera, such as it's Pan / Tilt Speed. Byte 8 is an XOR Checksum of the first 7 bytes and my camera will not perform it's function if the checksum is incorrect.
I COULD pre-calculate the checksums and define the 8 directions @ 5 variable speeds giving me 40 definitions, plus the 7 other commands, but I'd PREFER generating a string on the fly, incorporating incoming values from my joystick (Wiimote Nunchuck) but frankly I'm busted on the code, that is...
Assemble The Following:
Byte 1 - 0xA0
Byte 2 - 0x00
Byte 3 - Are Zoom / Iris / Focus Buttons Being Pressed?
Byte 4 - Interpret Direction of both Axes
Byte 5 - Interpret Speed of X Axis
Byte 6 - Interpret Speed of Y Axis
Byte 7 - 0xAF
Byte 8 - xOR checksum of generated bytes 1-7
Serial.write(generatedByte);
I'm not looking for somebody to write the code for me, but it would be awesome to be pointed in the right direction. I do see the ID-12/XOR code but it hasn't helped me in the least.