Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : 7 : This program is distributed in the hope that it will be useful, 8 : but WITHOUT ANY WARRANTY; without even the implied warranty of 9 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 : GNU General Public License for more details. 11 : 12 : You should have received a copy of the GNU General Public License 13 : along with this program. If not, see <http://www.gnu.org/licenses/>. 14 : */ 15 : 16 : #include "AP_WindVane_config.h" 17 : 18 : #if AP_WINDVANE_HOME_ENABLED 19 : 20 : #include "AP_WindVane_Home.h" 21 : 22 : #include <AP_AHRS/AP_AHRS.h> 23 : 24 0 : void AP_WindVane_Home::update_direction() 25 : { 26 0 : float direction_apparent_ef = _frontend._home_heading; 27 : 28 0 : if (_frontend._direction_type == _frontend.WINDVANE_PWM_PIN) { 29 0 : RC_Channel *chan = rc().find_channel_for_option(RC_Channel::AUX_FUNC::WIND_VANE_DIR_OFSSET); 30 0 : if (chan != nullptr) { 31 0 : direction_apparent_ef += chan->norm_input() * radians(45); 32 : } 33 : } 34 : 35 0 : _frontend._direction_apparent_raw = wrap_PI(direction_apparent_ef - AP::ahrs().get_yaw_rad()); 36 0 : } 37 : 38 : #endif // AP_WINDVANE_HOME_ENABLED