Skip to content

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

Merged
merged 12 commits into from
Aug 7, 2018
Merged

Initial commit of working version #1

merged 12 commits into from
Aug 7, 2018

Conversation

jerryneedell
Copy link
Contributor

This is my initial commit of a working version of the TMP007 driver.
I have tested it on a feather_m4_express

Comments welcome

@jerryneedell jerryneedell requested a review from tannewt August 3, 2018 17:06
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! Just two small things.

control |= _TMP007_CFG_MODEON
self._write_u16(_TMP007_CONFIG, control)

def read_raw_voltage(self):
Copy link
Member

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.

Copy link
Contributor Author

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.

"""
self._device = I2CDevice(i2c, address)

def begin(self, samplerate=CFG_16SAMPLE):
Copy link
Member

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.

Copy link
Contributor Author

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?

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.

Super close. Thanks Jerry!


dev_id = self.read_register(_TMP007_DEVID)
if dev_id != 0x78:
raise ValueError('Init failed - Did not find TMP007')
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -121,13 +119,15 @@ def sleep(self):
control &= ~(_TMP007_CFG_MODEON)
self._write_u16(_TMP007_CONFIG, control)

@property
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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.

Great! Thank you!

@tannewt tannewt merged commit e803b0c into adafruit:master Aug 7, 2018
@jerryneedell jerryneedell deleted the jerryn_initial branch October 29, 2018 01:06
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