Skip to content

Commit 7e84c17

Browse files
authored
Update __init__.py to support channels 2, 3 for pi 5
1 parent 3d246bb commit 7e84c17

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rpi_hardware_pwm/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class HardwarePWM:
2828
Notes
2929
--------
3030
- For Rpi 1,2,3,4, use chip=0; For Rpi 5, use chip=2
31+
- For Rpi 1,2,3,4 only channels 0 and 1 are available
3132
- If you get "write error: Invalid argument" - you have to set duty_cycle to 0 before changing period
3233
- /sys/ pwm interface described here: https://jumpnowtek.com/rpi/Using-the-Raspberry-Pi-Hardware-PWM-timers.html
3334
@@ -38,8 +39,8 @@ class HardwarePWM:
3839

3940
def __init__(self, pwm_channel: int, hz: float, chip: int = 0) -> None:
4041

41-
if pwm_channel not in {0, 1}:
42-
raise HardwarePWMException("Only channel 0 and 1 are available on the Rpi.")
42+
if pwm_channel not in {0, 1, 2, 3}:
43+
raise HardwarePWMException("Only channel 0 and 1 and 2 and 3 are available on the Rpi.")
4344

4445
self.chippath: str = f"/sys/class/pwm/pwmchip{chip}"
4546
self.pwm_channel = pwm_channel

0 commit comments

Comments
 (0)