From 71f81d2f18eaef7232433c367083b0d32cfaeb94 Mon Sep 17 00:00:00 2001 From: uae007 <74835465+uae007@users.noreply.github.com> Date: Thu, 1 May 2025 02:27:59 +0000 Subject: [PATCH] Component pca9685 - phase_begin always set to zero (#8379) Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- esphome/components/pca9685/pca9685_output.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/components/pca9685/pca9685_output.cpp b/esphome/components/pca9685/pca9685_output.cpp index d92312355a..1998f8d12f 100644 --- a/esphome/components/pca9685/pca9685_output.cpp +++ b/esphome/components/pca9685/pca9685_output.cpp @@ -101,8 +101,9 @@ void PCA9685Output::loop() { return; const uint16_t num_channels = this->max_channel_ - this->min_channel_ + 1; + const uint16_t phase_delta_begin = 4096 / num_channels; for (uint8_t channel = this->min_channel_; channel <= this->max_channel_; channel++) { - uint16_t phase_begin = uint16_t(channel - this->min_channel_) / num_channels * 4096; + uint16_t phase_begin = (channel - this->min_channel_) * phase_delta_begin; uint16_t phase_end; uint16_t amount = this->pwm_amounts_[channel]; if (amount == 0) {