Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProfiLED Fix #25518

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libraries/AP_HAL/RCOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ class AP_HAL::RCOutput {
// neopixel does not use pulse widths at all
static constexpr uint32_t PROFI_BIT_0_TICKS = 7;
static constexpr uint32_t PROFI_BIT_1_TICKS = 14;
static constexpr uint32_t PROFI_BIT_WIDTH_TICKS = 20;

// suitably long LED output period to support high LED counts
static constexpr uint32_t LED_OUTPUT_PERIOD_US = 10000;
Expand Down
7 changes: 5 additions & 2 deletions libraries/AP_HAL_ChibiOS/RCOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,7 @@ void RCOutput::set_group_mode(pwm_group &group)
#if HAL_SERIALLED_ENABLED
{
uint8_t bits_per_pixel = 24;
uint32_t bit_width = NEOP_BIT_WIDTH_TICKS;
bool active_high = true;

if (!start_led_thread()) {
Expand All @@ -1080,6 +1081,7 @@ void RCOutput::set_group_mode(pwm_group &group)

if (group.current_mode == MODE_PROFILED) {
bits_per_pixel = 25;
bit_width = PROFI_BIT_WIDTH_TICKS;
active_high = false;
}

Expand All @@ -1094,7 +1096,7 @@ void RCOutput::set_group_mode(pwm_group &group)
// calculate min time between pulses taking into account the DMAR parallelism
const uint32_t pulse_time_us = 1000000UL * bit_length / rate;

if (!setup_group_DMA(group, rate, NEOP_BIT_WIDTH_TICKS, active_high, buffer_length, pulse_time_us, false)) {
if (!setup_group_DMA(group, rate, bit_width, active_high, buffer_length, pulse_time_us, false)) {
group.current_mode = MODE_PWM_NONE;
break;
}
Expand Down Expand Up @@ -1698,7 +1700,8 @@ bool RCOutput::serial_led_send(pwm_group &group)
}

#if HAL_DSHOT_ENABLED
if (soft_serial_waiting() || (group.dshot_state != DshotState::IDLE && group.dshot_state != DshotState::RECV_COMPLETE)) {
if (soft_serial_waiting() || (group.dshot_state != DshotState::IDLE && group.dshot_state != DshotState::RECV_COMPLETE)
|| AP_HAL::micros64() - group.last_dmar_send_us < (group.dshot_pulse_time_us + 50)) {
// doing serial output or DMAR input, don't send DShot pulses
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_HAL_ChibiOS/RCOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class ChibiOS::RCOutput : public AP_HAL::RCOutput
#endif // HAL_WITH_BIDIR_DSHOT
// are we safe to send another pulse?
bool can_send_dshot_pulse() const {
return is_dshot_protocol(current_mode) && AP_HAL::micros() - last_dmar_send_us > (dshot_pulse_time_us + 50);
return is_dshot_protocol(current_mode) && AP_HAL::micros64() - last_dmar_send_us > (dshot_pulse_time_us + 50);
}

// return whether the group channel is both enabled in the group and for output
Expand Down