Merge remote-tracking branch 'upstream/master' into linux

Signed-off-by: Mark Charlebois <charlebm@gmail.com>

Conflicts:
	src/drivers/rgbled/rgbled.cpp
	src/modules/commander/PreflightCheck.cpp
	src/modules/commander/airspeed_calibration.cpp
	src/modules/commander/calibration_routines.cpp
	src/modules/commander/gyro_calibration.cpp
	src/modules/commander/mag_calibration.cpp
	src/modules/mc_att_control/mc_att_control_main.cpp
This commit is contained in:
Mark Charlebois
2015-04-28 11:48:26 -07:00
47 changed files with 935 additions and 656 deletions
+42 -5
View File
@@ -93,7 +93,7 @@ struct param_wbuf_s {
};
// XXX this should be param_info_count, but need to work out linking
uint8_t param_changed_storage[(600 / sizeof(uint8_t)) + 1] = {};
uint8_t param_changed_storage[(700 / sizeof(uint8_t)) + 1] = {};
/** flexible array holding modified parameter values */
UT_array *param_values;
@@ -266,8 +266,37 @@ param_count_used(void)
param_t
param_for_index(unsigned index)
{
if (index < param_info_count)
if (index < param_info_count) {
return (param_t)index;
}
return PARAM_INVALID;
}
param_t
param_for_used_index(unsigned index)
{
if (index < param_info_count) {
/* walk all params and count */
int count = 0;
for (unsigned i = 0; i < (unsigned)param_info_count + 1; i++) {
for (unsigned j = 0; j < 8; j++) {
if (param_changed_storage[i] & (1 << j)) {
/* we found the right used count,
* return the param value
*/
if (index == count) {
return (param_t)i;
}
count++;
}
}
}
}
return PARAM_INVALID;
}
@@ -275,8 +304,9 @@ param_for_index(unsigned index)
int
param_get_index(param_t param)
{
if (handle_in_range(param))
if (handle_in_range(param)) {
return (unsigned)param;
}
return -1;
}
@@ -284,7 +314,9 @@ param_get_index(param_t param)
int
param_get_used_index(param_t param)
{
if (!handle_in_range(param)) {
int param_storage_index = param_get_index(param);
if (param_storage_index < 0) {
return -1;
}
@@ -294,12 +326,17 @@ param_get_used_index(param_t param)
for (unsigned i = 0; i < (unsigned)param + 1; i++) {
for (unsigned j = 0; j < 8; j++) {
if (param_changed_storage[i] & (1 << j)) {
if (param_storage_index == i) {
return count;
}
count++;
}
}
}
return count;
return -1;
}
const char *
+8
View File
@@ -129,6 +129,14 @@ __EXPORT bool param_used(param_t param);
*/
__EXPORT param_t param_for_index(unsigned index);
/**
* Look up an used parameter by index.
*
* @param param The parameter to obtain the index for.
* @return The index of the parameter in use, or -1 if the parameter does not exist.
*/
__EXPORT param_t param_for_used_index(unsigned index);
/**
* Look up the index of a parameter.
*