Paparazzi UAS  v7.0_unstable
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 "modules/core/commands.h"
37 #include "generated/airframe.h"
38 
39 #define DC_PUSH(X) command_set(X, -MAX_PPRZ);
40 #define DC_RELEASE(X) command_set(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  // Do Servo specific DC init
59  dc_timer = 0;
60 }
61 
62 
63 /* Periodic */
65 {
66 #ifdef DC_SHOOT_ON_BUTTON_RELEASE
67  if (dc_timer == 1) {
69  }
70 #endif
71 
72  if (dc_timer) {
73  dc_timer--;
74  } else {
75  DC_RELEASE(DC_SHUTTER_SERVO);
76 #ifdef DC_ZOOM_IN_SERVO
77  DC_RELEASE(DC_ZOOM_IN_SERVO);
78 #endif
79 #ifdef DC_ZOOM_OUT_SERVO
80  DC_RELEASE(DC_ZOOM_OUT_SERVO);
81 #endif
82 #ifdef DC_POWER_SERVO
83  DC_RELEASE(DC_POWER_SERVO);
84 #endif
85  }
86 
87  // Common DC Periodic task
88  dc_periodic();
89 }
90 
91 
92 /* Command The Camera */
94 {
95  dc_timer = DC_SHUTTER_DELAY * SERVO_CAM_CTRL_PERIODIC_FREQ;
96 
97  switch (cmd) {
98  case DC_SHOOT:
99  DC_PUSH(DC_SHUTTER_SERVO);
100 #ifndef DC_SHOOT_ON_BUTTON_RELEASE
102 #endif
103  break;
104 #ifdef DC_ZOOM_IN_SERVO
105  case DC_TALLER:
106  DC_PUSH(DC_ZOOM_IN_SERVO);
107  break;
108 #endif
109 #ifdef DC_ZOOM_OUT_SERVO
110  case DC_WIDER:
111  DC_PUSH(DC_ZOOM_OUT_SERVO);
112  break;
113 #endif
114 #ifdef DC_POWER_SERVO
115  case DC_ON:
116  DC_PUSH(DC_POWER_SERVO);
117  break;
118 #endif
119  default:
120  break;
121  }
122 
123  // call command send_command function
125 }
126 
Hardware independent code for commands handling.
void dc_periodic(void)
periodic function
Definition: dc.c:279
void dc_send_command_common(uint8_t cmd)
Command sending function.
Definition: dc.c:192
void dc_send_shot_position(void)
Send Down the coordinates of where the photo was taken.
Definition: dc.c:106
@ DC_WIDER
Definition: dc.h:104
@ DC_SHOOT
Definition: dc.h:102
@ DC_TALLER
Definition: dc.h:105
@ DC_ON
Definition: dc.h:117
#define DC_PUSH(X)
#define DC_RELEASE(X)
void dc_send_command(uint8_t cmd)
Send Command To Camera.
void servo_cam_ctrl_periodic(void)
#define DC_SHUTTER_DELAY
how long to push shutter in seconds
void servo_cam_ctrl_init(void)
static uint8_t dc_timer
Digital Camera Control.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98