-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement clock and pwm modes #15
Conversation
How could it even work before?
So I also implemented simple pulse width modulation functionality.
Dimming led example:
|
Can @stianeikeland merge this? |
@stianeikeland, I know it's a lot of changes to review at once, I've done some refactoring even in your code and so on. But I would appreciate if you can check it and merge. Or, if you do not want to maintain this repo anymore, then I would like to ask your permission to separate my fork from your repo and make my own stand-alone repository (with a different name perhaps and with mention, it is based on your work, of course.) which I will maintain by myself. |
Hey, Anyway, I've had a go at it this evening, and managed to make a LED phase in and out using an old Raspberry PI 1 on pin 18. Code seems well written and works as intended, so I'll merge this as is. Would love to have an example program (maybe like the one you have above) that demonstrate how to use PWM. Feel free to add that if you want :) (Or I can just grab your example from above, let me know) :) EDIT: i copied your example program to the examples folder, feel free to change it if you want. Thanks! |
Great, thank you. I noticed a tiny error in the code. Will make PR soon. I would also consider adding a link to https://godoc.org/github.com/stianeikeland/go-rpio to readme - for people who do not know Golang so well and do not know this service exists, and just because it is convenient. |
Hi there.
I managed to add third pin mode - clock.
It is just clock (using
CM_GPnDIV
andCM_GPnCTL
registers) - no pwm (yet).Suggestions about better method/function naming are welcomed.
I tried to be consistent with current ideology, but not sure if it makes sense.
So this:
PinMode(pin, rpio.Clock)
<=>pin.Mode(rpio.Clock)
<=>pin.Clock()
is analogical to:
PinMode(pin, rpio.Output)
<=>pin.Mode(rpio.Output)
<=>pin.Output()
and this:
SetFreq(pin, 10000)
<=>pin.Freq(10000)
<=>???
is analogical to:
WritePin(pin, rpio.High)
<=>pin.Write(rpio.High)
<=>pin.High()
Also not sure if it might make sense to add more public methods eg. for stopping/resetting clocks.
Please merge this if you like it.