Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Aug 9, 2017
Merged

Added tone() #12

merged 1 commit into from
Aug 9, 2017

Conversation

brentru
Copy link
Member

@brentru brentru commented Jul 24, 2017

Added tone() to generate square wave w/50% duty cycle and user-defined frequency. #2

@brentru brentru requested a review from tannewt July 24, 2017 21:17
Copy link
Member

@tannewt tannewt left a 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)
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns are documented like:

:return: the device's usage page
:rtype: int

(from here)

simpleio.py Outdated
clock = digitalio.DigitalInOut(D12)
dataPin = digitalio.DigitalInOut(D11)
clock.switch_to_output()
dataPin.switch_to_output()
Copy link
Member

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

@tannewt
Copy link
Member

tannewt commented Aug 1, 2017

Please rebase this now that the shift code is in.

@tannewt tannewt self-assigned this Aug 6, 2017
@brentru
Copy link
Member Author

brentru commented Aug 9, 2017

Rebased.

@tannewt
Copy link
Member

tannewt commented Aug 9, 2017

What did you rebase onto? It looks likes the tone branch is still based on a commit from April. The Files changed tab shows a ton of changes unrelated to tone.

@brentru brentru force-pushed the tone branch 2 times, most recently from b28fac7 to b74bfb5 Compare August 9, 2017 18:51
simpleio.py Outdated
except ValueError:
with pulseio.PWMOut(pin, frequency = frequency, variable_frequency = False) as pwm:
pwm.duty_cycle = 0x8000
time.sleep(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time.sleep(duration)

Copy link
Member

@tannewt tannewt left a 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!

@tannewt tannewt merged commit f38e550 into master Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants