Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
servo_cam_ctrl.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 The Paparazzi Team
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
31 #include "servo_cam_ctrl.h"
32 #include "generated/modules.h"
33 
34 // Include Servo and airframe servo channels
35 #include "std.h"
36 #include "inter_mcu.h"
37 #include "generated/airframe.h"
38 
39 #define DC_PUSH(X) imcu_set_command(X, -MAX_PPRZ);
40 #define DC_RELEASE(X) imcu_set_command(X, MAX_PPRZ);
41 
43 #ifndef DC_SHUTTER_DELAY
44 #define DC_SHUTTER_DELAY 0.5
45 #endif
46 
47 #ifndef DC_SHUTTER_SERVO
48 #error DC: Please specify at least a DC_SHUTTER_SERVO
49 #endif
50 
51 
52 // Button Timer
54 
55 
57 {
58  // Call common DC init
59  dc_init();
60 
61  // Do Servo specific DC init
62  dc_timer = 0;
63 }
64 
65 
66 /* Periodic */
68 {
69 #ifdef DC_SHOOT_ON_BUTTON_RELEASE
70  if (dc_timer == 1) {
72  }
73 #endif
74 
75  if (dc_timer) {
76  dc_timer--;
77  } else {
78  DC_RELEASE(DC_SHUTTER_SERVO);
79 #ifdef DC_ZOOM_IN_SERVO
80  DC_RELEASE(DC_ZOOM_IN_SERVO);
81 #endif
82 #ifdef DC_ZOOM_OUT_SERVO
83  DC_RELEASE(DC_ZOOM_OUT_SERVO);
84 #endif
85 #ifdef DC_POWER_SERVO
86  DC_RELEASE(DC_POWER_SERVO);
87 #endif
88  }
89 
90  // Common DC Periodic task
91  dc_periodic();
92 }
93 
94 
95 /* Command The Camera */
97 {
98  dc_timer = DC_SHUTTER_DELAY * SERVO_CAM_CTRL_PERIODIC_FREQ;
99 
100  switch (cmd) {
101  case DC_SHOOT:
102  DC_PUSH(DC_SHUTTER_SERVO);
103 #ifndef DC_SHOOT_ON_BUTTON_RELEASE
105 #endif
106  break;
107 #ifdef DC_ZOOM_IN_SERVO
108  case DC_TALLER:
109  DC_PUSH(DC_ZOOM_IN_SERVO);
110  break;
111 #endif
112 #ifdef DC_ZOOM_OUT_SERVO
113  case DC_WIDER:
114  DC_PUSH(DC_ZOOM_OUT_SERVO);
115  break;
116 #endif
117 #ifdef DC_POWER_SERVO
118  case DC_ON:
119  DC_PUSH(DC_POWER_SERVO);
120  break;
121 #endif
122  default:
123  break;
124  }
125 
126  // call command send_command function
128 }
129 
dc_send_command_common
void dc_send_command_common(uint8_t cmd)
Command sending function.
Definition: dc.c:189
servo_cam_ctrl_periodic
void servo_cam_ctrl_periodic(void)
Definition: servo_cam_ctrl.c:67
servo_cam_ctrl_init
void servo_cam_ctrl_init(void)
Definition: servo_cam_ctrl.c:56
inter_mcu.h
DC_RELEASE
#define DC_RELEASE(X)
Definition: servo_cam_ctrl.c:40
std.h
DC_WIDER
@ DC_WIDER
Definition: dc.h:102
DC_SHUTTER_DELAY
#define DC_SHUTTER_DELAY
how long to push shutter in seconds
Definition: servo_cam_ctrl.c:44
uint8_t
unsigned char uint8_t
Definition: types.h:14
DC_TALLER
@ DC_TALLER
Definition: dc.h:103
dc_send_shot_position
void dc_send_shot_position(void)
Send Down the coordinates of where the photo was taken.
Definition: dc.c:104
DC_PUSH
#define DC_PUSH(X)
Definition: servo_cam_ctrl.c:39
dc_send_command
void dc_send_command(uint8_t cmd)
Send Command To Camera.
Definition: servo_cam_ctrl.c:96
DC_SHOOT
@ DC_SHOOT
Definition: dc.h:100
DC_ON
@ DC_ON
Definition: dc.h:115
servo_cam_ctrl.h
Digital Camera Control.
dc_init
void dc_init(void)
initialize settings
Definition: dc.c:156
dc_periodic
void dc_periodic(void)
periodic function
Definition: dc.c:273
dc_timer
static uint8_t dc_timer
Definition: servo_cam_ctrl.c:53