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:
parent
95e4b68b74
commit
24db7580a4
2 changed files with 15 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue