SwiftyGPIO
SwiftyGPIO copied to clipboard
Sys pwm
What's in this pull request?
Added a new file (SysPWM.swift) that supports PWM using the Raspberry Pi's pwm dtoverlay.
Is there something you want to discuss?
Please feel free to use this as is or modify as needed.
This PWM class uses the sysfs PWM interface created by loading the pwm or pwm-2chan dtoverlays supplied with Raspberry Pi OS. It has two benefits over the current PWM: it does not require the program to be run as root (as it does not access /dev/mem), and it can drive both PWM channels at the same time.
Pull Request Checklist
- [x] I've added the default copyright header to every new file.
- [x] Every new file has been correctly indented, no tabs, 4 spaces (you can use swiftlint).
- [x] Verify that you only import what's necessary, this reduces compilation time.
- [x] Try to declare the type of every variable and constant, not using type inference greatly reduces compilation time.
- [x] Verify that your code compiles with the currently supported Swift version (currently 4.1.3)
- [x] You've read the contribution guidelines.