Browse Source

AP_HAL: RCOutput_Tap: make LEDs blink on non-Aero ESCs

The protocol defines bits for controlling possible LEDs. On Aero the ESC
firmware simply ignores these bits and blink with a fixed frequency.
Add logic to be able to blink the ESC if not flashed with the Aero
version of the firmware.
master
Lucas De Marchi 7 years ago
parent
commit
7edde571e1
  1. 9
      libraries/AP_HAL/utility/RCOutput_Tap.cpp
  2. 2
      libraries/AP_HAL/utility/RCOutput_Tap.h

9
libraries/AP_HAL/utility/RCOutput_Tap.cpp

@ -556,8 +556,17 @@ void RCOutput_Tap::push() @@ -556,8 +556,17 @@ void RCOutput_Tap::push()
EscPacket packet = {0xfe, _channels_count, ESCBUS_MSG_ID_RUN};
packet.len *= sizeof(packet.d.reqRun.value[0]);
uint32_t tnow = AP_HAL::millis();
if (tnow - _last_led_update_msec > 250) {
_led_on = !_led_on;
_last_led_update_msec = tnow;
}
for (uint8_t i = 0; i < _channels_count; i++) {
packet.d.reqRun.value[i] = out[i] & RUN_CHANNEL_VALUE_MASK;
if (_led_on) {
packet.d.reqRun.value[i] |= RUN_LED_ON_MASK;
}
}
int ret = _send_packet(packet);

2
libraries/AP_HAL/utility/RCOutput_Tap.h

@ -89,12 +89,14 @@ private: @@ -89,12 +89,14 @@ private:
uint8_t _enabled_channels;
bool _corking;
bool _led_on;
uint8_t _channels_count = MAX_MOTORS;
uint16_t _period[MAX_MOTORS];
uint16_t _esc_pwm_min;
uint16_t _esc_pwm_max;
uint32_t _last_led_update_msec;
int _uart_fd = -1;
};

Loading…
Cancel
Save