File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -54,14 +54,15 @@ static const uint8_t gpioPinFunc[]{
5454
5555HardwarePWM::HardwarePWM (const uint8_t * pins, uint8_t no_of_pins, bool usePhaseShift ) : channel_count(no_of_pins)
5656{
57- if (noOfPins == 0 ) {
57+ _usePhaseShift = usePhaseShift; // Not used on the ESP8266 right now, esp32 hardware can phase shift pwm signals, pretty sure 8266 can't
58+ if (no_of_pins == 0 ) {
5859 return ;
5960 }
6061
6162 uint32_t ioInfo[PWM_CHANNEL_NUM_MAX][3 ]; // pin information
6263 uint32_t pwmDutyInit[PWM_CHANNEL_NUM_MAX]; // pwm duty
6364 unsigned pinCount = 0 ;
64- for (uint8_t i = 0 ; i < noOfPins ; i++) {
65+ for (uint8_t i = 0 ; i < no_of_pins ; i++) {
6566 auto pin = pins[i];
6667 assert (pin < 16 );
6768 if (pin >= 16 ) {
Original file line number Diff line number Diff line change 3333
3434HardwarePWM::HardwarePWM (const uint8_t * pins, uint8_t no_of_pins, bool usePhaseShift ) : channel_count(no_of_pins)
3535{
36- assert (noOfPins > 0 && noOfPins <= PWM_CHANNEL_NUM_MAX);
37- noOfPins = std::min (uint8_t (PWM_CHANNEL_NUM_MAX), noOfPins);
38- std::copy_n (pins, noOfPins, channels);
36+ _usePhaseShift = usePhaseShift; // Not used on the RP2040 right now, esp32 hardware can phase shift pwm signals, not sure if that's available in RP2040
37+ assert (no_of_pins > 0 && no_of_pins <= PWM_CHANNEL_NUM_MAX);
38+ no_of_pins = std::min (uint8_t (PWM_CHANNEL_NUM_MAX), no_of_pins);
39+ std::copy_n (pins, no_of_pins, channels);
3940 setPeriod (1e6 / PWM_FREQ_DEFAULT);
4041
41- for (unsigned i = 0 ; i < noOfPins ; ++i) {
42+ for (unsigned i = 0 ; i < no_of_pins ; ++i) {
4243 auto pin = channels[i];
4344 gpio_set_function (pin, GPIO_FUNC_PWM);
4445 gpio_set_dir (pin, GPIO_OUT);
You can’t perform that action at this time.
0 commit comments