i would like to use the camtrig option to trigger a cheap action camera for my quad. its 5v powered and needs a special formed signal to start/stop video recording. usally the signal line is high, but to start a recording it has to pushed to low for 750ms, than back to high.
i know that camtrig is normally used for servos, but i digged through the sourcecode and managed to come up with a "patch" for my needs. i think im 90% there, but i have to disable PWM signal generation somewhere else because it seems to conflict with my code. is there an easy way to do this?
her is my "patch", which replaces the original camtrig-code in mixTable() function.
Code: Select all
#if defined(CAMTRIG)
static uint8_t camCycle = 0;
static uint32_t camTime = 0;
static bool camSetup = false;
static bool camState = false;
static bool camWishedState = false;
// first run - setup cam
if (!camSetup) {
pinMode(A2,OUTPUT);
digitalWrite(A2,HIGH);
camSetup = true;
}
// when wished state != actual state, change state
if (camWishedState != camState) {
switch (camCycle) {
case 0: digitalWrite(A2,LOW); camTime = millis() + 750; camCycle++; break;
case 1: if (millis() > camTime) camCycle++; break;
case 2: digitalWrite(A2,HIGH); camState = camWishedState; camCycle = 0; break;
}
}
// select desired state
if (rcOptions[BOXCAMTRIG]) camWishedState = true; else camWishedState = false;
#endif