aboutsummaryrefslogtreecommitdiff
path: root/apps/px4io
diff options
context:
space:
mode:
authorSimon Wilks <sjwilks@gmail.com>2013-01-06 04:21:04 +0100
committerSimon Wilks <sjwilks@gmail.com>2013-01-06 04:21:04 +0100
commit7842caf3b2d5686c4e909d7d7f28758119e8918f (patch)
treebb0b773138ea9997543ef7c98a6433c4e19ba408 /apps/px4io
parent0a89ab7075e4d637c91e21246c4790599f046aec (diff)
downloadpx4-firmware-7842caf3b2d5686c4e909d7d7f28758119e8918f.tar.gz
px4-firmware-7842caf3b2d5686c4e909d7d7f28758119e8918f.tar.bz2
px4-firmware-7842caf3b2d5686c4e909d7d7f28758119e8918f.zip
Moved the channel mappings and attributes to the config section
Diffstat (limited to 'apps/px4io')
-rw-r--r--apps/px4io/comms.c27
-rw-r--r--apps/px4io/controls.c3
-rw-r--r--apps/px4io/mixer.cpp12
-rw-r--r--apps/px4io/protocol.h13
-rw-r--r--apps/px4io/px4io.h4
5 files changed, 31 insertions, 28 deletions
diff --git a/apps/px4io/comms.c b/apps/px4io/comms.c
index 2733877a2..85da65767 100644
--- a/apps/px4io/comms.c
+++ b/apps/px4io/comms.c
@@ -162,6 +162,20 @@ comms_handle_config(const void *buffer, size_t length)
}
frame_rx++;
+
+ /* fetch the rc mappings */
+ for (unsigned i = 0; i < 4; i++) {
+ system_state.rc_map[i] = cfg->rc_map[i];
+ }
+
+ /* fetch the rc channel attributes */
+ for (unsigned i = 0; i < 4; i++) {
+ system_state.rc_min[i] = cfg->rc_min[i];
+ system_state.rc_trim[i] = cfg->rc_trim[i];
+ system_state.rc_max[i] = cfg->rc_max[i];
+ system_state.rc_rev[i] = cfg->rc_rev[i];
+ system_state.rc_dz[i] = cfg->rc_dz[i];
+ }
}
static void
@@ -207,19 +221,6 @@ comms_handle_command(const void *buffer, size_t length)
system_state.servo_rate = new_servo_rate;
}
- /* fetch the rc mappings */
- for (unsigned i = 0; i < 4; i++)
- system_state.rc_map[i] = cmd->rc_map[i];
-
- /* fetch the rc channel attributes */
- for (unsigned i = 0; i < 4; i++) {
- system_state.rc_min[i] = cmd->rc_min[i];
- system_state.rc_trim[i] = cmd->rc_trim[i];
- system_state.rc_max[i] = cmd->rc_max[i];
- system_state.rc_rev[i] = cmd->rc_rev[i];
- system_state.rc_dz[i] = cmd->rc_dz[i];
- }
-
/*
* update servo values immediately.
* the updates are done in addition also
diff --git a/apps/px4io/controls.c b/apps/px4io/controls.c
index 564687b58..32fd7c33f 100644
--- a/apps/px4io/controls.c
+++ b/apps/px4io/controls.c
@@ -172,8 +172,9 @@ ppm_input(void)
/* PPM data exists, copy it */
system_state.rc_channels = ppm_decoded_channels;
- for (unsigned i = 0; i < ppm_decoded_channels; i++)
+ for (unsigned i = 0; i < ppm_decoded_channels; i++) {
system_state.rc_channel_data[i] = ppm_buffer[i];
+ }
/* copy the timestamp and clear it */
system_state.rc_channels_timestamp = ppm_last_valid_decode;
diff --git a/apps/px4io/mixer.cpp b/apps/px4io/mixer.cpp
index d65602587..341c2e276 100644
--- a/apps/px4io/mixer.cpp
+++ b/apps/px4io/mixer.cpp
@@ -99,7 +99,7 @@ mixer_tick(void)
/* too many frames without FMU input, time to go to failsafe */
system_state.mixer_manual_override = true;
system_state.mixer_fmu_available = false;
- //lib_lowprintf("RX timeout\n");
+ lib_lowprintf("RX timeout\n");
}
/*
@@ -121,10 +121,10 @@ mixer_tick(void)
sched_lock();
/* remap roll, pitch, yaw and throttle from RC specific to internal ordering */
- rc_channel_data[ROLL] = system_state.rc_channel_data[system_state.rc_map[ROLL]];
- rc_channel_data[PITCH] = system_state.rc_channel_data[system_state.rc_map[PITCH]];
- rc_channel_data[YAW] = system_state.rc_channel_data[system_state.rc_map[YAW]];
- rc_channel_data[THROTTLE] = system_state.rc_channel_data[system_state.rc_map[THROTTLE]];
+ rc_channel_data[ROLL] = system_state.rc_channel_data[system_state.rc_map[ROLL] - 1];
+ rc_channel_data[PITCH] = system_state.rc_channel_data[system_state.rc_map[PITCH] - 1];
+ rc_channel_data[YAW] = system_state.rc_channel_data[system_state.rc_map[YAW] - 1];
+ 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++)
@@ -133,6 +133,8 @@ mixer_tick(void)
/* 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]);
control_values = &rc_channel_data[0];
sched_unlock();
diff --git a/apps/px4io/protocol.h b/apps/px4io/protocol.h
index 2632604ca..303e4a674 100644
--- a/apps/px4io/protocol.h
+++ b/apps/px4io/protocol.h
@@ -60,12 +60,6 @@ struct px4io_command {
bool arm_ok; /**< FMU allows full arming */
bool vector_flight_mode_ok; /**< FMU aquired a valid position lock, ready for pos control */
bool manual_override_ok; /**< if true, IO performs a direct manual override */
- uint16_t rc_map[4]; /**< channel ordering of roll, pitch, yaw, throttle */
- 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 */
- uint16_t rc_dz[4]; /**< dz value for each channel */
};
/**
@@ -87,7 +81,12 @@ struct px4io_config {
uint16_t f2i_config_magic;
#define F2I_CONFIG_MAGIC 0x6366
- /* XXX currently nothing here */
+ uint8_t rc_map[4]; /**< channel ordering of roll, pitch, yaw, throttle */
+ 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 */
+ uint16_t rc_dz[4]; /**< dz value for each channel */
};
/**
diff --git a/apps/px4io/px4io.h b/apps/px4io/px4io.h
index ef1584026..01829e520 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
*/
- uint16_t rc_map[4];
+ uint8_t rc_map[4];
/**
* Remote control channel attributes
@@ -85,7 +85,7 @@ struct sys_state_s {
uint16_t rc_max[4];
uint16_t rc_rev[4];
uint16_t rc_dz[4];
-
+
/**
* Data from the remote control input(s)
*/