Line data Source code
1 : 2 : #include "AP_RCProtocol_config.h" 3 : 4 : #if AP_RCPROTOCOL_MAVLINK_RADIO_ENABLED 5 : 6 : #include "AP_RCProtocol_MAVLinkRadio.h" 7 : 8 0 : void AP_RCProtocol_MAVLinkRadio::update_radio_rc_channels(const mavlink_radio_rc_channels_t* packet) 9 : { 10 0 : const uint8_t count = MIN(packet->count, MAX_RCIN_CHANNELS); 11 : 12 : uint16_t rc_chan[MAX_RCIN_CHANNELS]; 13 0 : for (uint8_t i = 0; i < count; i++) { 14 : // The channel values are in centered 13 bit format. Range is [-4096,4096], center is 0. 15 : // According to specification, the conversion to PWM is x * 5/32 + 1500. 16 0 : rc_chan[i] = ((int32_t)packet->channels[i] * 5) / 32 + 1500; 17 : } 18 : 19 0 : bool failsafe = (packet->flags & RADIO_RC_CHANNELS_FLAGS_FAILSAFE); 20 : 21 0 : add_input(count, rc_chan, failsafe); 22 0 : } 23 : 24 : #endif // AP_RCPROTOCOL_MAVLINK_RADIO_ENABLED 25 :