-
Notifications
You must be signed in to change notification settings - Fork 20
Added tone() #12
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
Added tone() #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking these up!
simpleio.py
Outdated
|
||
:param pin: pin on which to stop the tone from being played | ||
""" | ||
pwm.deinit(pin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried this? I don't think the pwm object will persist across the tone
and noTone
calls. It also doesn't take a pin in.
Adding support for the analog out pin would also be nice. PWM doesn't work with it but AudioOut does.
simpleio.py
Outdated
|
||
:param dataPin: pin on which to input each bit | ||
:param clock: toggles to signal dataPin reads | ||
:param bitOrder: order to shift bits (either LSBFIRST or MSBFIRST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make this a bool instead of a string and give it a default. So something like msb_first=True
.
simpleio.py
Outdated
:param dataPin: pin on which to input each bit | ||
:param clock: toggles to signal dataPin reads | ||
:param bitOrder: order to shift bits (either LSBFIRST or MSBFIRST) | ||
:param value: RETURNS the value read |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simpleio.py
Outdated
clock = digitalio.DigitalInOut(D12) | ||
dataPin = digitalio.DigitalInOut(D11) | ||
clock.switch_to_output() | ||
dataPin.switch_to_output() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use the property in examples where we don't provide arguments to switch_to_output
.
So it should be clock.direction = digitalio.Direction.OUTPUT
Please rebase this now that the shift code is in. |
Rebased. |
What did you rebase onto? It looks likes the tone branch is still based on a commit from April. The |
b28fac7
to
b74bfb5
Compare
simpleio.py
Outdated
except ValueError: | ||
with pulseio.PWMOut(pin, frequency = frequency, variable_frequency = False) as pwm: | ||
pwm.duty_cycle = 0x8000 | ||
time.sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time.sleep(duration)
… and analog pins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for doing this!
Added tone() to generate square wave w/50% duty cycle and user-defined frequency. #2