using camtrig option to trigger an "action cam"

Post Reply
tofuwurst
Posts: 2
Joined: Fri Oct 02, 2015 2:53 pm

using camtrig option to trigger an "action cam"

Post by tofuwurst »

hi,

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
Last edited by tofuwurst on Fri Oct 02, 2015 4:18 pm, edited 1 time in total.

tofuwurst
Posts: 2
Joined: Fri Oct 02, 2015 2:53 pm

Re: using camtrig option to trigger an "action cam"

Post by tofuwurst »

nevermind. i found an "easy" way to solve this for my board (328p)

in def.h change SERVO_3_PIN_HIGH and SERVO_3_PIN_LOW to ";"

Code: Select all

//#define SERVO_3_PIN_HIGH         PORTC |= 1<<2;
//#define SERVO_3_PIN_LOW          PORTC &= ~(1<<2);
#define SERVO_3_PIN_HIGH           ;
#define SERVO_3_PIN_LOW            ;

Post Reply