-
Notifications
You must be signed in to change notification settings - Fork 4
Initial commit of working version #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.
Thanks! Just two small things.
adafruit_tmp007.py
Outdated
control |= _TMP007_CFG_MODEON | ||
self._write_u16(_TMP007_CONFIG, control) | ||
|
||
def read_raw_voltage(self): |
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.
Please use properties for sensor values. I'd expect temperature
for the object and sensor_temperature
for the die temp. voltage can be private only.
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.
made properties -- the voltage is not actually used internally. I think it is to be available for detailed sensor calibration by the user.
adafruit_tmp007.py
Outdated
""" | ||
self._device = I2CDevice(i2c, address) | ||
|
||
def begin(self, samplerate=CFG_16SAMPLE): |
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.
Fold this into __init__
so its going immediately. It can always be slept after.
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 merged begin int init and just throw an error if the ID is not valid. Is this what you wanted?
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.
Super close. Thanks Jerry!
adafruit_tmp007.py
Outdated
|
||
dev_id = self.read_register(_TMP007_DEVID) | ||
if dev_id != 0x78: | ||
raise ValueError('Init failed - Did not find TMP007') |
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.
RuntimeError please. The argument could be valid but the circuit setup wrong.
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.
Done
adafruit_tmp007.py
Outdated
@@ -121,13 +119,15 @@ def sleep(self): | |||
control &= ~(_TMP007_CFG_MODEON) | |||
self._write_u16(_TMP007_CONFIG, control) | |||
|
|||
@property |
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.
Sleep and wake should be functions because they are behavior rather than state.
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.
Done
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.
Great! Thank you!
This is my initial commit of a working version of the TMP007 driver.
I have tested it on a feather_m4_express
Comments welcome