-
Notifications
You must be signed in to change notification settings - Fork 15
Dallas 1-Wire temperature sensor #1
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
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.
A couple more comments! Thanks for your work on this.
README.rst
Outdated
>>> ow_bus = OneWireBus(board.D2) | ||
>>> ds18 = DS18X20(ow_bus, ow_bus.scan()[0]) | ||
>>> ds18.temperature | ||
27.9375 |
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.
How about removing the prompt so you can copy it all into a file to run? It'd also be good in a separate file under an examples folder as well.
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 like the idea of examples folder. Allows for demonstrating other and more complex uses of the driver.
============ | ||
|
||
Contributions are welcome! Please read our `Code of Conduct | ||
<https://github.com/adafruit/Adafruit_CircuitPython_DS18X20/blob/master/CODE_OF_CONDUCT.md>`_ |
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.
cookiecutter assumes the X should be capitalized but the github repo is lower case. Let me know which you want and lets make sure its consistent.
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.
Let's got with capital X.
adafruit_ds18x20.py
Outdated
self._device = OneWireDevice(bus, address) | ||
self._buf = bytearray(9) | ||
else: | ||
raise Exception('Incorrect family code in device address.') |
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.
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, yeah, I was wondering about that and was just replicating some of what was already in the code. Should be a ValueError - but are you OK with the idea of raising an exception in general?
adafruit_ds18x20.py
Outdated
# configuration register | ||
self._buf[2] = RESOLUTION.index(bits) << 5 | 0x1F | ||
except ValueError: | ||
raise Exception('Incorrect resolution.') |
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.
Here too
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.
See above.
adafruit_ds18x20.py
Outdated
_CONVERSION_TIMEOUT = const(1) | ||
RESOLUTION = (9, 10, 11, 12) | ||
|
||
class DS18X20(object): |
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.
No need to have object here. Its implicit.
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.
the linter wanted that. old style class vs. new style class.
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.
Looks great! Thank you for your awesome work on OneWire.
Uses CircuitPython OneWire to access the DS18X20