1
0
Fork 0
mirror of https://github.com/kidoman/embd synced 2025-07-04 20:37:46 +02:00

initialize configuration so we aren't unintentionally overwriting something on the first configuration change

This commit is contained in:
Adam Bright 2016-09-29 05:51:00 +00:00
parent 95e4b68b74
commit 24db7580a4
2 changed files with 15 additions and 6 deletions

View file

@ -39,8 +39,12 @@ type MCP9808 struct {
}
// New returns a handle to a MCP9808 sensor.
func New(bus embd.I2CBus) *MCP9808 {
return &MCP9808{Bus: bus}
func New(bus embd.I2CBus) (*MCP9808, error) {
d := &MCP9808{Bus: bus}
// initialize the configuration
_, err := d.Config()
return d, err
}
// ManufacturerID reads the device manufacturer ID