AP_WindVane: convert analog sensor to use latest value

This commit is contained in:
Iampete1 2021-04-14 18:55:54 +01:00 committed by Peter Barker
parent 0628aa9e29
commit ab1d54745d
1 changed files with 1 additions and 1 deletions

View File

@ -27,7 +27,7 @@ AP_WindVane_Analog::AP_WindVane_Analog(AP_WindVane &frontend) :
void AP_WindVane_Analog::update_direction()
{
_dir_analog_source->set_pin(_frontend._dir_analog_pin);
_current_analog_voltage = _dir_analog_source->voltage_average_ratiometric();
_current_analog_voltage = _dir_analog_source->voltage_latest();
const float voltage_ratio = linear_interpolate(0.0f, 1.0f, _current_analog_voltage, _frontend._dir_analog_volt_min, _frontend._dir_analog_volt_max);
const float direction = (voltage_ratio * radians(360 - _frontend._dir_analog_deadzone)) + radians(_frontend._dir_analog_bearing_offset);