aboutsummaryrefslogtreecommitdiff
path: root/apps/px4io
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-01-06 14:43:37 +0100
committerLorenz Meier <lm@inf.ethz.ch>2013-01-06 14:43:37 +0100
commit0945a2cc2fe2d4214a5796cdd85f19a3b017d13c (patch)
tree6a1b789a97ae25c0f1a1c94a499a93b2b5b21169 /apps/px4io
parentef2efabbd46ec7d29dc4ff5363feea779b7b1c30 (diff)
downloadpx4-firmware-0945a2cc2fe2d4214a5796cdd85f19a3b017d13c.tar.gz
px4-firmware-0945a2cc2fe2d4214a5796cdd85f19a3b017d13c.tar.bz2
px4-firmware-0945a2cc2fe2d4214a5796cdd85f19a3b017d13c.zip
Fixed RC mapping transmission, tested. Fixed RC scaling in manual mode
Diffstat (limited to 'apps/px4io')
-rw-r--r--apps/px4io/mixer.cpp31
-rw-r--r--apps/px4io/protocol.h2
-rw-r--r--apps/px4io/px4io.h4
3 files changed, 26 insertions, 11 deletions
diff --git a/apps/px4io/mixer.cpp b/apps/px4io/mixer.cpp
index 95484bc9d..93fe93b39 100644
--- a/apps/px4io/mixer.cpp
+++ b/apps/px4io/mixer.cpp
@@ -80,7 +80,7 @@ bool mixer_servos_armed = false;
static uint16_t *control_values;
static int control_count;
-static uint16_t rc_channel_data[PX4IO_CONTROL_CHANNELS];
+static uint16_t rc_channel_data[PX4IO_INPUT_CHANNELS];
static int mixer_callback(uintptr_t handle,
uint8_t control_group,
@@ -127,14 +127,25 @@ mixer_tick(void)
rc_channel_data[THROTTLE] = system_state.rc_channel_data[system_state.rc_map[THROTTLE] - 1];
/* get the remaining channels, no remapping needed */
- for (unsigned i = 4; i < system_state.rc_channels; i++)
+ for (unsigned i = 4; i < system_state.rc_channels; i++) {
rc_channel_data[i] = system_state.rc_channel_data[i];
+ }
+
+ /* scale the control inputs */
+ rc_channel_data[THROTTLE] = ((float)(rc_channel_data[THROTTLE] - system_state.rc_min[THROTTLE]) /
+ (float)(system_state.rc_max[THROTTLE] - system_state.rc_min[THROTTLE])) * 1000.0f + 1000;
- /* scale the control inputs */
- rc_channel_data[THROTTLE] = ((rc_channel_data[THROTTLE] - system_state.rc_min[THROTTLE]) /
- (system_state.rc_max[THROTTLE] - system_state.rc_min[THROTTLE])) * 1000 + 1000;
- //lib_lowprintf("Tmin: %d Ttrim: %d Tmax: %d T: %d \n",
- // system_state.rc_min[THROTTLE], system_state.rc_trim[THROTTLE], system_state.rc_max[THROTTLE], rc_channel_data[THROTTLE]);
+ if (rc_channel_data[THROTTLE] > 2000) {
+ rc_channel_data[THROTTLE] = 2000;
+ }
+
+ if (rc_channel_data[THROTTLE] < 1000) {
+ rc_channel_data[THROTTLE] = 1000;
+ }
+
+ // lib_lowprintf("Tmin: %d Ttrim: %d Tmax: %d T: %d \n",
+ // (int)(system_state.rc_min[THROTTLE]), (int)(system_state.rc_trim[THROTTLE]),
+ // (int)(system_state.rc_max[THROTTLE]), (int)(rc_channel_data[THROTTLE]));
control_values = &rc_channel_data[0];
sched_unlock();
@@ -218,7 +229,11 @@ mixer_callback(uintptr_t handle,
return -1;
/* scale from current PWM units (1000-2000) to mixer input values */
- control = ((float)control_values[control_index] - 1500.0f) / 500.0f;
+ if (system_state.manual_override_ok && system_state.mixer_manual_override && control_index == 3) {
+ control = ((float)control_values[control_index] - 1000.0f) / 1000.0f;
+ } else {
+ control = ((float)control_values[control_index] - 1500.0f) / 500.0f;
+ }
return 0;
}
diff --git a/apps/px4io/protocol.h b/apps/px4io/protocol.h
index 7aa3be02a..90236b40c 100644
--- a/apps/px4io/protocol.h
+++ b/apps/px4io/protocol.h
@@ -89,7 +89,7 @@ struct px4io_config {
uint16_t rc_min[4]; /**< min value for each channel */
uint16_t rc_trim[4]; /**< trim value for each channel */
uint16_t rc_max[4]; /**< max value for each channel */
- uint16_t rc_rev[4]; /**< rev value for each channel */
+ int8_t rc_rev[4]; /**< rev value for each channel */
uint16_t rc_dz[4]; /**< dz value for each channel */
};
diff --git a/apps/px4io/px4io.h b/apps/px4io/px4io.h
index 65d33f34b..139bbb321 100644
--- a/apps/px4io/px4io.h
+++ b/apps/px4io/px4io.h
@@ -75,7 +75,7 @@ struct sys_state_s {
/**
* Remote control input(s) channel mappings
*/
- uint8_t rc_map[4];
+ uint8_t rc_map[4];
/**
* Remote control channel attributes
@@ -83,7 +83,7 @@ struct sys_state_s {
uint16_t rc_min[4];
uint16_t rc_trim[4];
uint16_t rc_max[4];
- uint16_t rc_rev[4];
+ int16_t rc_rev[4];
uint16_t rc_dz[4];
/**