-
Notifications
You must be signed in to change notification settings - Fork 21
Update to the correct distance call #20
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
Update to the correct distance call #20
Conversation
It looks like the `distance property replaces the `dist_cm()` function. Also gave a hint here that the board pin objects are needed, and not just integers.
README.rst
Outdated
@@ -99,15 +99,15 @@ Without a Context Manager | |||
------------------------- | |||
|
|||
In the example below, we create the `HCSR04` object directly, get the distance every 2 seconds, then | |||
de-initialize the device. | |||
de-initialize the device. Note trig and echo should come from the `board` module - they aren't just integers. | |||
|
|||
:: | |||
|
|||
from adafruit_hcsr04 import HCSR04 | |||
sonar = HCSR04(trig, echo) |
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 for fixing the out of date example in the readme!
Instead of making a note in the paragraph above can you update this line in the example code to show it's usage with the board pins. You can copy it form the example file in the repo if you want:
https://github.com/adafruit/Adafruit_CircuitPython_HCSR04/blob/master/examples/hcsr04_simpletest.py
You can add import board
at the top and then change the sonar constructor like this:
sonar = HCSR04(trigger_pin=board.D5, echo_pin=board.D6)
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.
Good idea. I've committed this change.
Updating based on PR comments
Thank you @dannystaple. There is a minor issue with the docs building on this PR currently. I've submitted a PR on your branch that should fix it. I think if you merge my PR it should automatically show up here as well and fix the docs building when it retries the CI actions. |
fix docs building
Looks like putting in the import, I missed the blank line - RST doesn't like that. The language hints can't hurt. More fool me for not trying the Sphinx build locally - done so now and it looks good. |
@dannystaple Testing this out now on a HC0SR04 sensor I've hit a few more snags. The code in the readme is using Also it seems like there is some sort of RuntimeError that needs to be caught and then retried after in order for the sensor to work (at least for my sensor with Itsy Bitsy M0). Though I also realized from this learn guide page: https://learn.adafruit.com/ultrasonic-sonar-distance-sensors/python-circuitpython that it is required to use some resistors to hook this up and I didn't do that the first time, so perhaps that is part of my problem. Can you go ahead and copy the entire contents hcsr04_simpletest.py into the readme please. It looks like the example was updated at some point to address these things, but the readme never was. Sorry for all of the changes, I didn't notice some of these issues until putting the circuit together. I really appreciate you working on this to get the readme example back to functional. I will try to get some resistors dug up and get my circuit set up to properly test this out all the way a bit later on today. |
@dannystaple Have you had a chance to follow up on FoamyGuy's latest comment? |
Apologies no - I have a tight deadline to hit and have been flat out. I may return to this at some point in the future.
… On 17 Aug 2020, at 21:46, Kattni ***@***.***> wrote:
@dannystaple <https://github.com/dannystaple> Have you had a chance to follow up on FoamyGuy's latest comment?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#20 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AADIG27YOANQCEUQTGZ6WYDSBGJKHANCNFSM4OCBI32Q>.
|
@dannystaple Thank you for letting me know. I will see if FoamyGuy can finish it up. |
@FoamyGuy The original author is unavailable at the moment. Would you mind finishing up this PR as per your suggestions? Thanks! |
It looks like the
distance property replaces the
dist_cm()` function.Also gave a hint here that the board pin objects are needed, and not just integers.