Skip to content

Commit 6132f3b

Browse files
committed
harmonized the variable for number of pins to no_of_pins across all architectures
1 parent da69d82 commit 6132f3b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Sming/Arch/Esp8266/Core/HardwarePWM.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ static const uint8_t gpioPinFunc[]{
5454

5555
HardwarePWM::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) {

Sming/Arch/Rp2040/Core/HardwarePWM.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@
3333

3434
HardwarePWM::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);

0 commit comments

Comments
 (0)