AP_OSD: params always use set method
This commit is contained in:
parent
47105f0b03
commit
28007bfc1e
@ -240,7 +240,7 @@ AP_OSD::AP_OSD()
|
||||
AP_Param::setup_object_defaults(this, var_info);
|
||||
#if OSD_ENABLED
|
||||
// default first screen enabled
|
||||
screen[0].enabled = 1;
|
||||
screen[0].enabled.set(1);
|
||||
previous_pwm_screen = -1;
|
||||
#endif
|
||||
#ifdef WITH_SITL_OSD
|
||||
|
@ -375,11 +375,11 @@ void AP_OSD_ParamScreen::modify_configured_parameter(uint8_t number, Event ev)
|
||||
|
||||
if (param != nullptr) {
|
||||
// update the stored index
|
||||
setting._param_group = setting._current_token.group_element;
|
||||
setting._param_key = AP_Param::get_persistent_key(setting._current_token.key);
|
||||
setting._param_idx = setting._current_token.idx;
|
||||
setting._param_group.set(setting._current_token.group_element);
|
||||
setting._param_key.set(AP_Param::get_persistent_key(setting._current_token.key));
|
||||
setting._param_idx.set(setting._current_token.idx);
|
||||
setting._param = param;
|
||||
setting._type = OSD_PARAM_NONE;
|
||||
setting._type.set(OSD_PARAM_NONE);
|
||||
// force update() to refresh the token
|
||||
setting._current_token.key = 0;
|
||||
setting._current_token.idx = 0;
|
||||
|
@ -239,34 +239,34 @@ extern const AP_HAL::HAL& hal;
|
||||
AP_OSD_ParamSetting::AP_OSD_ParamSetting(uint8_t param_number, bool _enabled, uint8_t x, uint8_t y, int16_t key, int8_t idx, int32_t group, int8_t type, float min, float max, float incr)
|
||||
: AP_OSD_Setting(_enabled, x, y), _param_number(param_number)
|
||||
{
|
||||
_param_group = group;
|
||||
_param_idx = idx;
|
||||
_param_key = key;
|
||||
_param_min = min;
|
||||
_param_max = max;
|
||||
_param_incr = incr;
|
||||
_type = type;
|
||||
_param_group.set(group);
|
||||
_param_idx.set(idx);
|
||||
_param_key.set(key);
|
||||
_param_min.set(min);
|
||||
_param_max.set(max);
|
||||
_param_incr.set(incr);
|
||||
_type.set(type);
|
||||
}
|
||||
|
||||
// default constructor that just sets some sensible defaults that exist on all platforms
|
||||
AP_OSD_ParamSetting::AP_OSD_ParamSetting(uint8_t param_number)
|
||||
: AP_OSD_Setting(false, 2, param_number + 1), _param_number(param_number)
|
||||
{
|
||||
_param_min = 0.0f;
|
||||
_param_max = 1.0f;
|
||||
_param_incr = 0.001f;
|
||||
_type = OSD_PARAM_NONE;
|
||||
_param_min.set(0.0f);
|
||||
_param_max.set(1.0f);
|
||||
_param_incr.set(0.001f);
|
||||
_type.set(OSD_PARAM_NONE);
|
||||
}
|
||||
|
||||
// construct a setting from a compact static initializer structure
|
||||
AP_OSD_ParamSetting::AP_OSD_ParamSetting(const Initializer& initializer)
|
||||
: AP_OSD_ParamSetting(initializer.index)
|
||||
{
|
||||
_param_group = initializer.token.group_element;
|
||||
_param_idx = initializer.token.idx;
|
||||
_param_key = initializer.token.key;
|
||||
_type = initializer.type;
|
||||
enabled = true;
|
||||
_param_group.set(initializer.token.group_element);
|
||||
_param_idx.set(initializer.token.idx);
|
||||
_param_key.set(initializer.token.key);
|
||||
_type.set(initializer.type);
|
||||
enabled.set(true);
|
||||
}
|
||||
|
||||
// update the contained parameter
|
||||
@ -287,7 +287,7 @@ void AP_OSD_ParamSetting::update()
|
||||
}
|
||||
|
||||
if (_param == nullptr) {
|
||||
enabled = false;
|
||||
enabled.set(false);
|
||||
} else {
|
||||
guess_ranges();
|
||||
}
|
||||
@ -406,13 +406,13 @@ void AP_OSD_ParamSetting::guess_ranges(bool force)
|
||||
}
|
||||
|
||||
if (force || !_param_min.configured()) {
|
||||
_param_min = min;
|
||||
_param_min.set(min);
|
||||
}
|
||||
if (force || !_param_max.configured()) {
|
||||
_param_max = max;
|
||||
_param_max.set(max);
|
||||
}
|
||||
if (force || !_param_incr.configured()) {
|
||||
_param_incr = incr;
|
||||
_param_incr.set(incr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -438,9 +438,9 @@ bool AP_OSD_ParamSetting::set_from_metadata()
|
||||
{
|
||||
// check for statically configured setting metadata
|
||||
if (_type > 0 && _type < OSD_PARAM_NUM_TYPES && _param_metadata[_type - 1].values_max > 0) {
|
||||
_param_incr = _param_metadata[_type - 1].increment;
|
||||
_param_min = _param_metadata[_type - 1].min_value;
|
||||
_param_max = _param_metadata[_type - 1].max_value;
|
||||
_param_incr.set(_param_metadata[_type - 1].increment);
|
||||
_param_min.set(_param_metadata[_type - 1].min_value);
|
||||
_param_max.set(_param_metadata[_type - 1].max_value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1290,7 +1290,7 @@ void AP_OSD_Screen::draw_avgcellvolt(uint8_t x, uint8_t y)
|
||||
uint8_t p = (100 - pct) / 16.6;
|
||||
float v = battery.voltage();
|
||||
// calculate cell count - WARNING this can be inaccurate if the LIPO/LIION battery is far from fully charged when attached and is used in this panel
|
||||
osd->max_battery_voltage = MAX(osd->max_battery_voltage,v);
|
||||
osd->max_battery_voltage.set(MAX(osd->max_battery_voltage,v));
|
||||
if (osd->cell_count > 0) {
|
||||
v = v / osd->cell_count;
|
||||
backend->write(x,y, v < osd->warn_avgcellvolt, "%c%1.2f%c", SYMBOL(SYM_BATT_FULL) + p, v, SYMBOL(SYM_VOLT));
|
||||
|
@ -51,7 +51,7 @@ const AP_Param::GroupInfo AP_OSD_Setting::var_info[] = {
|
||||
// constructor
|
||||
AP_OSD_Setting::AP_OSD_Setting(bool _enabled, uint8_t x, uint8_t y)
|
||||
{
|
||||
enabled = _enabled;
|
||||
xpos = x;
|
||||
ypos = y;
|
||||
enabled.set(_enabled);
|
||||
xpos.set(x);
|
||||
ypos.set(y);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user