aboutsummaryrefslogtreecommitdiff
path: root/apps/px4io/controls.c
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2012-12-01 16:30:21 +0100
committerLorenz Meier <lm@inf.ethz.ch>2012-12-01 16:30:21 +0100
commit126e6ac2073ffb96c3867e7cbdd4e51e8408d0ec (patch)
tree277f05a93bea57ada888302829f716dc46dd92ef /apps/px4io/controls.c
parent2bfb6727912e804325e5a512c9c09d36e8fe06d3 (diff)
downloadpx4-firmware-126e6ac2073ffb96c3867e7cbdd4e51e8408d0ec.tar.gz
px4-firmware-126e6ac2073ffb96c3867e7cbdd4e51e8408d0ec.tar.bz2
px4-firmware-126e6ac2073ffb96c3867e7cbdd4e51e8408d0ec.zip
Enabled manual override switch, work in progress. Added initial demix testing code to support delta mixing on the remote for convenient manual override
Diffstat (limited to 'apps/px4io/controls.c')
-rw-r--r--apps/px4io/controls.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/apps/px4io/controls.c b/apps/px4io/controls.c
index d4eace3df..0e0210373 100644
--- a/apps/px4io/controls.c
+++ b/apps/px4io/controls.c
@@ -59,6 +59,10 @@
#define DEBUG
#include "px4io.h"
+#define RC_FAILSAFE_TIMEOUT 2000000 /**< two seconds failsafe timeout */
+#define RC_CHANNEL_HIGH_THRESH 1600
+#define RC_CHANNEL_LOW_THRESH 1400
+
void
controls_main(void)
{
@@ -80,7 +84,22 @@ controls_main(void)
if (fds[1].revents & POLLIN)
sbus_input();
- /* XXX do ppm processing, bypass mode, etc. here */
+ /* force manual input override */
+ if (system_state.rc_channel_data[4] > RC_CHANNEL_HIGH_THRESH) {
+ system_state.mixer_use_fmu = false;
+ } else {
+ /* override not engaged, use FMU */
+ system_state.mixer_use_fmu = true;
+ }
+
+ /* detect rc loss event */
+ if (hrt_absolute_time() - system_state.rc_channels_timestamp > RC_FAILSAFE_TIMEOUT) {
+ system_state.rc_lost = true;
+ }
+
+ /* XXX detect fmu loss event */
+
+ /* XXX handle failsave events - RC loss and FMU loss - here */
/* do PWM output updates */
mixer_tick();