Closed CharlesCCC closed 4 years ago
I see the source of the confusion. It seems that the underlying sysfs interface has one flat list of PWM channels ranging from 0 to /sys/class/pwm/npwm
, which organized in chunks at various /sys/class/pwm/pwmchipN
chips, each of which start at channel base N.
To fix this, the PWM constructor should really just accept a channel number and find the right channel under one of the pwmchip bases or write /sys/class/pwm/export
export it. I'll fix this for 1.2.0.
I was incorrect about my analysis above. The channel numbers are namespaced under each pwmchip, not a flat list, so the solution ended up being simply renaming channel
to chip
and pin
to channel
in the constructor and documentation.
Not sure if any body has followed the documents to worked with PWM, but it is totally misleading. I spent hours doing research finally was able to figure this part out by looking at the snippet code provided by @scottellis https://github.com/scottellis/pwmpy
In the code: Original mapping
PWM(channel, pin)
is WRONGinstead, it actually should work like this:
PWM(channel-->chip/pin, pin-->channel)
e.g. with the example from the README
but what it is actually doing is: (open chip/pin 0, with the 11th channel)
so the paramer should be passed in as this
PWM(pin, channel)
so the the example from the README become
add additional info: