uncrustify libraries/AP_Common/AP_Param.cpp

This commit is contained in:
uncrustify 2012-08-16 23:18:11 -07:00 committed by Pat Hickey
parent c18e73a54d
commit 09c4f76b57
1 changed files with 28 additions and 28 deletions

View File

@ -23,9 +23,9 @@
// #define ENABLE_FASTSERIAL_DEBUG // #define ENABLE_FASTSERIAL_DEBUG
#ifdef ENABLE_FASTSERIAL_DEBUG #ifdef ENABLE_FASTSERIAL_DEBUG
# define serialDebug(fmt, args...) if (FastSerial::getInitialized(0)) do {Serial.printf("%s:%d: " fmt "\n", __FUNCTION__, __LINE__ , ##args); delay(0); } while(0) # define serialDebug(fmt, args ...) if (FastSerial::getInitialized(0)) do {Serial.printf("%s:%d: " fmt "\n", __FUNCTION__, __LINE__, ## args); delay(0); } while(0)
#else #else
# define serialDebug(fmt, args...) # define serialDebug(fmt, args ...)
#endif #endif
// some useful progmem macros // some useful progmem macros
@ -110,9 +110,9 @@ void AP_Param::erase_all(void)
} }
// validate a group info table // validate a group info table
bool AP_Param::check_group_info(const struct AP_Param::GroupInfo *group_info, bool AP_Param::check_group_info(const struct AP_Param::GroupInfo * group_info,
uint16_t *total_size, uint16_t * total_size,
uint8_t group_shift) uint8_t group_shift)
{ {
uint8_t type; uint8_t type;
int8_t max_idx = -1; int8_t max_idx = -1;
@ -309,13 +309,13 @@ const struct AP_Param::Info *AP_Param::find_by_header(struct Param_header phdr,
} }
// find the info structure for a variable in a group // find the info structure for a variable in a group
const struct AP_Param::Info *AP_Param::find_var_info_group(const struct GroupInfo *group_info, const struct AP_Param::Info *AP_Param::find_var_info_group(const struct GroupInfo * group_info,
uint8_t vindex, uint8_t vindex,
uint8_t group_base, uint8_t group_base,
uint8_t group_shift, uint8_t group_shift,
uint8_t *group_element, uint8_t * group_element,
const struct GroupInfo **group_ret, const struct GroupInfo **group_ret,
uint8_t *idx) uint8_t * idx)
{ {
uintptr_t base = PGM_POINTER(&_var_info[vindex].ptr); uintptr_t base = PGM_POINTER(&_var_info[vindex].ptr);
uint8_t type; uint8_t type;
@ -344,17 +344,17 @@ const struct AP_Param::Info *AP_Param::find_var_info_group(const struct GroupInf
} }
} else // Forgive the poor formatting - if continues below. } else // Forgive the poor formatting - if continues below.
#endif // AP_NESTED_GROUPS_ENABLED #endif // AP_NESTED_GROUPS_ENABLED
if ((uintptr_t)this == base + ofs) { if ((uintptr_t) this == base + ofs) {
*group_element = GROUP_ID(group_info, group_base, i, group_shift); *group_element = GROUP_ID(group_info, group_base, i, group_shift);
*group_ret = &group_info[i]; *group_ret = &group_info[i];
*idx = 0; *idx = 0;
return &_var_info[vindex]; return &_var_info[vindex];
} else if (type == AP_PARAM_VECTOR3F && } else if (type == AP_PARAM_VECTOR3F &&
(base+ofs+sizeof(float) == (uintptr_t)this || (base+ofs+sizeof(float) == (uintptr_t) this ||
base+ofs+2*sizeof(float) == (uintptr_t)this)) { base+ofs+2*sizeof(float) == (uintptr_t) this)) {
// we are inside a Vector3f. We need to work out which // we are inside a Vector3f. We need to work out which
// element of the vector the current object refers to. // element of the vector the current object refers to.
*idx = (((uintptr_t)this) - (base+ofs))/sizeof(float); *idx = (((uintptr_t) this) - (base+ofs))/sizeof(float);
*group_element = GROUP_ID(group_info, group_base, i, group_shift); *group_element = GROUP_ID(group_info, group_base, i, group_shift);
*group_ret = &group_info[i]; *group_ret = &group_info[i];
return &_var_info[vindex]; return &_var_info[vindex];
@ -364,9 +364,9 @@ const struct AP_Param::Info *AP_Param::find_var_info_group(const struct GroupInf
} }
// find the info structure for a variable // find the info structure for a variable
const struct AP_Param::Info *AP_Param::find_var_info(uint8_t *group_element, const struct AP_Param::Info *AP_Param::find_var_info(uint8_t * group_element,
const struct GroupInfo **group_ret, const struct GroupInfo ** group_ret,
uint8_t *idx) uint8_t * idx)
{ {
for (uint8_t i=0; i<_num_vars; i++) { for (uint8_t i=0; i<_num_vars; i++) {
uint8_t type = PGM_UINT8(&_var_info[i].type); uint8_t type = PGM_UINT8(&_var_info[i].type);
@ -378,17 +378,17 @@ const struct AP_Param::Info *AP_Param::find_var_info(uint8_t *group_element,
if (info != NULL) { if (info != NULL) {
return info; return info;
} }
} else if (base == (uintptr_t)this) { } else if (base == (uintptr_t) this) {
*group_element = 0; *group_element = 0;
*group_ret = NULL; *group_ret = NULL;
*idx = 0; *idx = 0;
return &_var_info[i]; return &_var_info[i];
} else if (type == AP_PARAM_VECTOR3F && } else if (type == AP_PARAM_VECTOR3F &&
(base+sizeof(float) == (uintptr_t)this || (base+sizeof(float) == (uintptr_t) this ||
base+2*sizeof(float) == (uintptr_t)this)) { base+2*sizeof(float) == (uintptr_t) this)) {
// we are inside a Vector3f. Work out which element we are // we are inside a Vector3f. Work out which element we are
// referring to. // referring to.
*idx = (((uintptr_t)this) - base)/sizeof(float); *idx = (((uintptr_t) this) - base)/sizeof(float);
*group_element = 0; *group_element = 0;
*group_ret = NULL; *group_ret = NULL;
return &_var_info[i]; return &_var_info[i];
@ -501,7 +501,7 @@ void AP_Param::copy_name(char *buffer, size_t buffer_size, bool force_scalar)
add_vector3f_suffix(buffer, buffer_size, idx); add_vector3f_suffix(buffer, buffer_size, idx);
} }
} else if ((force_scalar || idx != 0) && AP_PARAM_VECTOR3F == PGM_UINT8(&info->type)) { } else if ((force_scalar || idx != 0) && AP_PARAM_VECTOR3F == PGM_UINT8(&info->type)) {
add_vector3f_suffix(buffer, buffer_size, idx); add_vector3f_suffix(buffer, buffer_size, idx);
} }
} }
@ -621,7 +621,7 @@ bool AP_Param::save(void)
eeprom_write_check(ap, ofs+sizeof(phdr), type_size((enum ap_var_type)phdr.type)); eeprom_write_check(ap, ofs+sizeof(phdr), type_size((enum ap_var_type)phdr.type));
return true; return true;
} }
if (ofs == (uint16_t)~0) { if (ofs == (uint16_t) ~0) {
return false; return false;
} }