diff --git a/conf/airframes/CDW/ChimuTinyFwSpi.xml b/conf/airframes/CDW/ChimuTinyFwSpi.xml
index fdb2a11d12..1dcec8729d 100644
--- a/conf/airframes/CDW/ChimuTinyFwSpi.xml
+++ b/conf/airframes/CDW/ChimuTinyFwSpi.xml
@@ -144,7 +144,7 @@
diff --git a/conf/airframes/CDW/classix.xml b/conf/airframes/CDW/classix.xml
index fb10368725..a3fb9fd86a 100644
--- a/conf/airframes/CDW/classix.xml
+++ b/conf/airframes/CDW/classix.xml
@@ -171,7 +171,7 @@
diff --git a/conf/airframes/CDW/test/ChimuJTinyFwSpi.xml b/conf/airframes/CDW/test/ChimuJTinyFwSpi.xml
index 58f6539bce..0b328f6707 100644
--- a/conf/airframes/CDW/test/ChimuJTinyFwSpi.xml
+++ b/conf/airframes/CDW/test/ChimuJTinyFwSpi.xml
@@ -144,7 +144,7 @@
diff --git a/conf/airframes/CDW/test/ChimuTinyFw.xml b/conf/airframes/CDW/test/ChimuTinyFw.xml
index 5ad17e3885..cd3911d720 100644
--- a/conf/airframes/CDW/test/ChimuTinyFw.xml
+++ b/conf/airframes/CDW/test/ChimuTinyFw.xml
@@ -144,7 +144,7 @@
diff --git a/conf/airframes/CDW/test/yapa3_aspirin2.xml b/conf/airframes/CDW/test/yapa3_aspirin2.xml
index 05e9f2ff54..32f4036baf 100644
--- a/conf/airframes/CDW/test/yapa3_aspirin2.xml
+++ b/conf/airframes/CDW/test/yapa3_aspirin2.xml
@@ -194,7 +194,7 @@
diff --git a/conf/airframes/CDW/tiny2_chimu_spi_pt.xml b/conf/airframes/CDW/tiny2_chimu_spi_pt.xml
index 40416a9d74..501cc00d5f 100644
--- a/conf/airframes/CDW/tiny2_chimu_spi_pt.xml
+++ b/conf/airframes/CDW/tiny2_chimu_spi_pt.xml
@@ -151,7 +151,7 @@ YAPA + XSens + XBee
diff --git a/conf/airframes/CDW/yapa_xsens.xml b/conf/airframes/CDW/yapa_xsens.xml
index b3cbe56ccf..e50c495ac1 100644
--- a/conf/airframes/CDW/yapa_xsens.xml
+++ b/conf/airframes/CDW/yapa_xsens.xml
@@ -206,7 +206,7 @@
diff --git a/conf/airframes/OpenUAS/openuas_vivify_mk1.xml b/conf/airframes/OpenUAS/openuas_vivify_mk1.xml
index 78d85f684e..934ab142ec 100644
--- a/conf/airframes/OpenUAS/openuas_vivify_mk1.xml
+++ b/conf/airframes/OpenUAS/openuas_vivify_mk1.xml
@@ -227,7 +227,7 @@
-
+
diff --git a/conf/airframes/examples/MentorEnergy.xml b/conf/airframes/examples/MentorEnergy.xml
index 9a55854605..70826794c4 100644
--- a/conf/airframes/examples/MentorEnergy.xml
+++ b/conf/airframes/examples/MentorEnergy.xml
@@ -244,7 +244,7 @@
diff --git a/conf/airframes/examples/Twinstar_energyadaptive.xml b/conf/airframes/examples/Twinstar_energyadaptive.xml
index a92c93173d..3369a9f1c7 100644
--- a/conf/airframes/examples/Twinstar_energyadaptive.xml
+++ b/conf/airframes/examples/Twinstar_energyadaptive.xml
@@ -244,7 +244,7 @@ twog_1.0 + aspirin + ETS baro + ETS speed
diff --git a/conf/airframes/examples/separate_fbw_ap.xml b/conf/airframes/examples/separate_fbw_ap.xml
index 3fa41f1218..8f19313895 100644
--- a/conf/airframes/examples/separate_fbw_ap.xml
+++ b/conf/airframes/examples/separate_fbw_ap.xml
@@ -196,7 +196,7 @@
diff --git a/conf/airframes/examples/yapaChimuSpi.xml b/conf/airframes/examples/yapaChimuSpi.xml
index 400592828e..277d8d1d1f 100644
--- a/conf/airframes/examples/yapaChimuSpi.xml
+++ b/conf/airframes/examples/yapaChimuSpi.xml
@@ -175,7 +175,7 @@
diff --git a/conf/flight_plans/OpenUAS/include_obc2014_mission.xml b/conf/flight_plans/OpenUAS/include_obc2014_mission.xml
index d3f44a7e9f..35e7fd19a6 100644
--- a/conf/flight_plans/OpenUAS/include_obc2014_mission.xml
+++ b/conf/flight_plans/OpenUAS/include_obc2014_mission.xml
@@ -74,7 +74,7 @@ TESTS:
#include "generated/airframe.h"
// Completly replace with onboard recon copmpter interface
- #ifdef DC_AUTOSHOOT_QUARTERSEC_PERIOD
+ #ifdef DC_AUTOSHOOT_PERIOD
//TODO make shooting distance not periodic
#define LINE_START_FUNCTION dc_autoshoot = DC_AUTOSHOOT_PERIODIC;
#define LINE_STOP_FUNCTION dc_autoshoot = DC_AUTOSHOOT_STOP;
diff --git a/conf/messages.xml b/conf/messages.xml
index 4a1a36f9b4..91825cdbdd 100644
--- a/conf/messages.xml
+++ b/conf/messages.xml
@@ -542,7 +542,7 @@
-
+
diff --git a/conf/modules/digital_cam.xml b/conf/modules/digital_cam.xml
index a78837dc50..65a0b69359 100644
--- a/conf/modules/digital_cam.xml
+++ b/conf/modules/digital_cam.xml
@@ -11,10 +11,10 @@
-
-
+
+
-
+
@@ -35,7 +35,7 @@
-
+
@@ -54,7 +54,7 @@
-
+
diff --git a/conf/modules/digital_cam_i2c.xml b/conf/modules/digital_cam_i2c.xml
index 14e0245931..b9251f15c7 100644
--- a/conf/modules/digital_cam_i2c.xml
+++ b/conf/modules/digital_cam_i2c.xml
@@ -16,7 +16,7 @@
-
+
diff --git a/conf/modules/digital_cam_servo.xml b/conf/modules/digital_cam_servo.xml
index 7047dc7298..8e1a7173e0 100644
--- a/conf/modules/digital_cam_servo.xml
+++ b/conf/modules/digital_cam_servo.xml
@@ -8,7 +8,7 @@
-
+
@@ -21,7 +21,7 @@
-
+
diff --git a/conf/modules/digital_cam_uart.xml b/conf/modules/digital_cam_uart.xml
index 2a3b559972..a05de2d799 100644
--- a/conf/modules/digital_cam_uart.xml
+++ b/conf/modules/digital_cam_uart.xml
@@ -4,7 +4,7 @@
Digital Camera Triggering over UART link.
Send attitude and other relevant data to a computer based photocamera after a shootphoto command is given. And in return get certain value back from the computerbased photocamera to be able to intercat with the flightplan.
-
+
@@ -21,7 +21,7 @@
-
+
@@ -44,7 +44,7 @@
-
+
diff --git a/sw/airborne/modules/digital_cam/atmega_i2c_cam_ctrl.c b/sw/airborne/modules/digital_cam/atmega_i2c_cam_ctrl.c
index 8fed86bae6..ed97b64aa6 100644
--- a/sw/airborne/modules/digital_cam/atmega_i2c_cam_ctrl.c
+++ b/sw/airborne/modules/digital_cam/atmega_i2c_cam_ctrl.c
@@ -65,7 +65,7 @@ void atmega_i2c_cam_ctrl_init(void)
void atmega_i2c_cam_ctrl_periodic(void)
{
atmega_i2c_cam_ctrl_just_sent_command = 0;
- dc_periodic_4Hz();
+ dc_periodic();
// Request Status
if (atmega_i2c_cam_ctrl_just_sent_command == 0) {
diff --git a/sw/airborne/modules/digital_cam/dc.c b/sw/airborne/modules/digital_cam/dc.c
index 386011eb54..0280d7ba28 100644
--- a/sw/airborne/modules/digital_cam/dc.c
+++ b/sw/airborne/modules/digital_cam/dc.c
@@ -41,9 +41,11 @@
#include "firmwares/rotorcraft/navigation.h"
#endif
-/** default quartersec perioid = 0.5s */
-#ifndef DC_AUTOSHOOT_QUARTERSEC_PERIOD
-#define DC_AUTOSHOOT_QUARTERSEC_PERIOD 2
+#include "mcu_periph/sys_time.h"
+
+/** default time interval for periodic mode: 1sec */
+#ifndef DC_AUTOSHOOT_PERIOD
+#define DC_AUTOSHOOT_PERIOD 1.0
#endif
/** default distance interval for distance mode: 50m */
@@ -74,8 +76,7 @@ float dc_gps_y = 0;
static struct FloatVect2 last_shot_pos = {0.0, 0.0};
float dc_distance_interval;
-
-uint8_t dc_autoshoot_quartersec_period;
+float dc_autoshoot_period;
/** by default send DC_SHOT message when photo was taken */
#ifndef DC_SHOT_SYNC_SEND
@@ -131,7 +132,7 @@ void dc_send_shot_position(void)
void dc_init(void)
{
dc_autoshoot = DC_AUTOSHOOT_STOP;
- dc_autoshoot_quartersec_period = DC_AUTOSHOOT_QUARTERSEC_PERIOD;
+ dc_autoshoot_period = DC_AUTOSHOOT_PERIOD;
dc_distance_interval = DC_AUTOSHOOT_DISTANCE_INTERVAL;
}
@@ -140,6 +141,7 @@ uint8_t dc_info(void)
#ifdef DOWNLINK_SEND_DC_INFO
float course = DegOfRad(stateGetNedToBodyEulers_f()->psi);
int16_t mode = dc_autoshoot;
+ uint8_t shutter = dc_autoshoot_period * 10;
DOWNLINK_SEND_DC_INFO(DefaultChannel, DefaultDevice,
&mode,
&stateGetPositionLla_i()->lat,
@@ -155,7 +157,7 @@ uint8_t dc_info(void)
&dc_circle_interval,
&dc_circle_last_block,
&dc_gps_count,
- &dc_autoshoot_quartersec_period);
+ &shutter);
#endif
return 0;
}
@@ -235,20 +237,20 @@ static float dim_mod(float a, float b, float m)
return fminf(a - b, b + m - a);
}
-void dc_periodic_4Hz(void)
+void dc_periodic(void)
{
- static uint8_t dc_shutter_timer = 0;
+ static float last_shot_time = 0.;
switch (dc_autoshoot) {
- case DC_AUTOSHOOT_PERIODIC:
- if (dc_shutter_timer) {
- dc_shutter_timer--;
- } else {
- dc_shutter_timer = dc_autoshoot_quartersec_period;
+ case DC_AUTOSHOOT_PERIODIC: {
+ float now = get_sys_time_float();
+ if (now - last_shot_time > dc_autoshoot_period) {
+ last_shot_time = now;
dc_send_command(DC_SHOOT);
}
- break;
+ }
+ break;
case DC_AUTOSHOOT_DISTANCE: {
struct FloatVect2 cur_pos;
diff --git a/sw/airborne/modules/digital_cam/dc.h b/sw/airborne/modules/digital_cam/dc.h
index 5c480ab420..0e0b5ee26b 100644
--- a/sw/airborne/modules/digital_cam/dc.h
+++ b/sw/airborne/modules/digital_cam/dc.h
@@ -52,8 +52,8 @@ extern uint16_t dc_gps_count;
/*
* Variables for PERIODIC mode.
*/
-/** AutoShoot photos every X quarter_second */
-extern uint8_t dc_autoshoot_quartersec_period;
+/** AutoShoot photos every X seconds */
+extern float dc_autoshoot_period;
/*
@@ -151,8 +151,8 @@ void dc_send_shot_position(void);
/** initialize settings */
extern void dc_init(void);
-/** periodic 4Hz function */
-extern void dc_periodic_4Hz(void);
+/** periodic function */
+extern void dc_periodic(void);
/**
* Sets the dc control in distance mode.
diff --git a/sw/airborne/modules/digital_cam/gpio_cam_ctrl.c b/sw/airborne/modules/digital_cam/gpio_cam_ctrl.c
index c03e558a0b..15c68c47f8 100644
--- a/sw/airborne/modules/digital_cam/gpio_cam_ctrl.c
+++ b/sw/airborne/modules/digital_cam/gpio_cam_ctrl.c
@@ -35,6 +35,7 @@
#include "gpio_cam_ctrl.h"
#include "generated/airframe.h"
+#include "generated/modules.h"
// Include Standard Camera Control Interface
#include "dc.h"
@@ -49,12 +50,14 @@
#define DC_RELEASE gpio_clear
#endif
+/** how long to push shutter in seconds */
#ifndef DC_SHUTTER_DELAY
-#define DC_SHUTTER_DELAY 2 /* 4Hz -> 0.5s */
+#define DC_SHUTTER_DELAY 0.5
#endif
+/** how long to send power off in seconds */
#ifndef DC_POWER_OFF_DELAY
-#define DC_POWER_OFF_DELAY 3
+#define DC_POWER_OFF_DELAY 0.75
#endif
#ifdef DC_SHUTTER_LED
@@ -123,13 +126,14 @@ void gpio_cam_ctrl_periodic(void)
}
// Common DC Periodic task
- dc_periodic_4Hz();
+ dc_periodic();
}
/* Command The Camera */
void dc_send_command(uint8_t cmd)
{
- dc_timer = DC_SHUTTER_DELAY;
+ dc_timer = DC_SHUTTER_DELAY * GPIO_CAM_CTRL_PERIODIC_FREQ;
+
switch (cmd) {
case DC_SHOOT:
DC_PUSH(DC_SHUTTER_GPIO);
@@ -155,7 +159,7 @@ void dc_send_command(uint8_t cmd)
#ifdef DC_POWER_OFF_GPIO
case DC_OFF:
DC_PUSH(DC_POWER_OFF_GPIO);
- dc_timer = DC_POWER_OFF_DELAY;
+ dc_timer = DC_POWER_OFF_DELAY * GPIO_CAM_CTRL_PERIODIC_FREQ;
break;
#endif
default:
diff --git a/sw/airborne/modules/digital_cam/gpio_cam_ctrl.h b/sw/airborne/modules/digital_cam/gpio_cam_ctrl.h
index 442dba0563..92236beb80 100644
--- a/sw/airborne/modules/digital_cam/gpio_cam_ctrl.h
+++ b/sw/airborne/modules/digital_cam/gpio_cam_ctrl.h
@@ -25,7 +25,7 @@
* Provides the control of the shutter and the zoom of a digital camera
* through standard binary IOs of the board.
*
- * The required initialization (dc_init()) and periodic (4Hz) process.
+ * The required initialization (dc_init()) and periodic process.
*/
#ifndef GPIO_CAM_CTRL_H
@@ -33,7 +33,7 @@
extern void gpio_cam_ctrl_init(void);
-/** 4Hz Periodic */
+/** Periodic */
extern void gpio_cam_ctrl_periodic(void);
#endif // GPIO_CAM_CTRL_H
diff --git a/sw/airborne/modules/digital_cam/servo_cam_ctrl.c b/sw/airborne/modules/digital_cam/servo_cam_ctrl.c
index b95530a85b..a3e2fb50e9 100644
--- a/sw/airborne/modules/digital_cam/servo_cam_ctrl.c
+++ b/sw/airborne/modules/digital_cam/servo_cam_ctrl.c
@@ -20,15 +20,83 @@
*
*/
+/** @file modules/digital_cam/servo_cam_ctrl.c
+ * @brief Digital Camera Control
+ *
+ * Provides the control of the shutter and the zoom of a digital camera
+ * via servos.
+ *
+ */
+
#include "servo_cam_ctrl.h"
+#include "generated/modules.h"
+
+// Include Servo and airframe servo channels
+#include "std.h"
+#include "inter_mcu.h"
+#include "generated/airframe.h"
+
+#define DC_PUSH(X) ap_state->commands[X] = -MAX_PPRZ;
+#define DC_RELEASE(X) ap_state->commands[X] = MAX_PPRZ;
+
+/** how long to push shutter in seconds */
+#ifndef DC_SHUTTER_DELAY
+#define DC_SHUTTER_DELAY 0.5
+#endif
+
+#ifndef DC_SHUTTER_SERVO
+#error DC: Please specify at least a DC_SHUTTER_SERVO
+#endif
+
// Button Timer
-uint8_t dc_timer;
+static uint8_t dc_timer;
+
+
+void servo_cam_ctrl_init(void)
+{
+ // Call common DC init
+ dc_init();
+
+ // Do Servo specific DC init
+ dc_timer = 0;
+}
+
+
+/* Periodic */
+void servo_cam_ctrl_periodic(void)
+{
+#ifdef DC_SHOOT_ON_BUTTON_RELEASE
+ if (dc_timer == 1) {
+ dc_send_shot_position();
+ }
+#endif
+
+ if (dc_timer) {
+ dc_timer--;
+ } else {
+ DC_RELEASE(DC_SHUTTER_SERVO);
+#ifdef DC_ZOOM_IN_SERVO
+ DC_RELEASE(DC_ZOOM_IN_SERVO);
+#endif
+#ifdef DC_ZOOM_OUT_SERVO
+ DC_RELEASE(DC_ZOOM_OUT_SERVO);
+#endif
+#ifdef DC_POWER_SERVO
+ DC_RELEASE(DC_POWER_SERVO);
+#endif
+ }
+
+ // Common DC Periodic task
+ dc_periodic();
+}
+
/* Command The Camera */
void dc_send_command(uint8_t cmd)
{
- dc_timer = DC_SHUTTER_DELAY;
+ dc_timer = DC_SHUTTER_DELAY * SERVO_CAM_CTRL_PERIODIC_FREQ;
+
switch (cmd) {
case DC_SHOOT:
DC_PUSH(DC_SHUTTER_SERVO);
@@ -56,5 +124,3 @@ void dc_send_command(uint8_t cmd)
}
}
-
-
diff --git a/sw/airborne/modules/digital_cam/servo_cam_ctrl.h b/sw/airborne/modules/digital_cam/servo_cam_ctrl.h
index c2c1af2ee9..27394f98b1 100644
--- a/sw/airborne/modules/digital_cam/servo_cam_ctrl.h
+++ b/sw/airborne/modules/digital_cam/servo_cam_ctrl.h
@@ -33,7 +33,7 @@
*
* @endcode
*
- * Provides the required initialization (dc_init()) and periodic (4Hz) process.
+ * Provides the required initialization (dc_init()) and periodic process.
*/
#ifndef SERVO_CAM_CTRL_H
@@ -42,60 +42,10 @@
// Include Standard Camera Control Interface
#include "dc.h"
-// Include Servo and airframe servo channels
-#include "std.h"
-#include "inter_mcu.h"
-#include "generated/airframe.h"
-extern uint8_t dc_timer;
+extern void servo_cam_ctrl_init(void);
-static inline void servo_cam_ctrl_init(void)
-{
- // Call common DC init
- dc_init();
-
- // Do LED specific DC init
- dc_timer = 0;
-}
-
-#define DC_PUSH(X) ap_state->commands[X] = -MAX_PPRZ;
-#define DC_RELEASE(X) ap_state->commands[X] = MAX_PPRZ;
-
-#ifndef DC_SHUTTER_DELAY
-#define DC_SHUTTER_DELAY 2 /* 4Hz -> 0.5s */
-#endif
-
-#ifndef DC_SHUTTER_SERVO
-#error DC: Please specify at least a DC_SHUTTER_SERVO
-#endif
-
-
-/* 4Hz Periodic */
-static inline void servo_cam_ctrl_periodic(void)
-{
-#ifdef DC_SHOOT_ON_BUTTON_RELEASE
- if (dc_timer == 1) {
- dc_send_shot_position();
- }
-#endif
-
- if (dc_timer) {
- dc_timer--;
- } else {
- DC_RELEASE(DC_SHUTTER_SERVO);
-#ifdef DC_ZOOM_IN_SERVO
- DC_RELEASE(DC_ZOOM_IN_SERVO);
-#endif
-#ifdef DC_ZOOM_OUT_SERVO
- DC_RELEASE(DC_ZOOM_OUT_SERVO);
-#endif
-#ifdef DC_POWER_SERVO
- DC_RELEASE(DC_POWER_SERVO);
-#endif
- }
-
- // Common DC Periodic task
- dc_periodic_4Hz();
-}
+/* Periodic */
+extern void servo_cam_ctrl_periodic(void);
#endif // SERVO_CAM_CONTROL_H
diff --git a/sw/airborne/modules/digital_cam/sim_i2c_cam_ctrl.c b/sw/airborne/modules/digital_cam/sim_i2c_cam_ctrl.c
index 111030df1b..1525b3f590 100644
--- a/sw/airborne/modules/digital_cam/sim_i2c_cam_ctrl.c
+++ b/sw/airborne/modules/digital_cam/sim_i2c_cam_ctrl.c
@@ -43,7 +43,7 @@ void atmega_i2c_cam_ctrl_init(void)
void atmega_i2c_cam_ctrl_periodic(void)
{
- dc_periodic_4Hz();
+ dc_periodic();
// Request Status
dc_send_command(DC_GET_STATUS);
diff --git a/sw/airborne/modules/digital_cam/uart_cam_ctrl.c b/sw/airborne/modules/digital_cam/uart_cam_ctrl.c
index 5d88e293bb..b138a04f56 100644
--- a/sw/airborne/modules/digital_cam/uart_cam_ctrl.c
+++ b/sw/airborne/modules/digital_cam/uart_cam_ctrl.c
@@ -140,7 +140,7 @@ void digital_cam_uart_init(void)
void digital_cam_uart_periodic(void)
{
// Common DC Periodic task
- dc_periodic_4Hz();
+ dc_periodic();
}
diff --git a/sw/airborne/modules/digital_cam/uart_cam_ctrl.h b/sw/airborne/modules/digital_cam/uart_cam_ctrl.h
index d345812343..853adad2e1 100644
--- a/sw/airborne/modules/digital_cam/uart_cam_ctrl.h
+++ b/sw/airborne/modules/digital_cam/uart_cam_ctrl.h
@@ -25,7 +25,7 @@
* Provides the control of a camera over serial, typically connected to a computer which has
* full control of all camera functions via USB, including downloading of digital thumbnails
*
- * The required initialization (digital_cam_uart_init()) and periodic (4Hz) process.
+ * The required initialization (digital_cam_uart_init()) and periodic process.
*/
#ifndef DIGITAL_CAM_UART_H
@@ -35,7 +35,6 @@
extern void digital_cam_uart_init(void);
-/** 4Hz Periodic */
extern void digital_cam_uart_periodic(void);
extern void digital_cam_uart_event(void);