diff --git a/devices/bmxx80/bmxx80.go b/devices/bmxx80/bmxx80.go index 2fe873c..5dc3e00 100644 --- a/devices/bmxx80/bmxx80.go +++ b/devices/bmxx80/bmxx80.go @@ -504,4 +504,3 @@ var doSleep = time.Sleep var _ conn.Resource = &Dev{} var _ physic.SenseEnv = &Dev{} -var _ fmt.Stringer = &Dev{} diff --git a/devices/ds248x/ds248x.go b/devices/ds248x/ds248x.go index 24563ad..01a94f4 100644 --- a/devices/ds248x/ds248x.go +++ b/devices/ds248x/ds248x.go @@ -313,7 +313,6 @@ func (e busError) BusError() bool { return true } var sleep = time.Sleep var _ conn.Resource = &Dev{} -var _ fmt.Stringer = &Dev{} const ( cmdReset = 0xf0 // reset ds248x diff --git a/devices/lepton/cci/cci.go b/devices/lepton/cci/cci.go index b1b1694..f420a2f 100644 --- a/devices/lepton/cci/cci.go +++ b/devices/lepton/cci/cci.go @@ -160,10 +160,19 @@ type Dev struct { serial uint64 } +// String implements conn.Resource. func (d *Dev) String() string { return d.c.String() } +// Halt implements conn.Resource. +// +// Halt stops the camera. +func (d *Dev) Halt() error { + // TODO(maruel): Doc says it won't restart. Yo. + return d.c.run(oemPowerDown) +} + // Init initializes the FLIR Lepton in raw 14 bits mode, enables telemetry as // header. func (d *Dev) Init() error { @@ -209,12 +218,6 @@ func (d *Dev) WaitIdle() (StatusBit, error) { return d.c.waitIdle() } -// Halt stops the camera. -func (d *Dev) Halt() error { - // TODO(maruel): Doc says it won't restart. Yo. - return d.c.run(oemPowerDown) -} - // GetStatus return the status of the camera as known by the camera itself. func (d *Dev) GetStatus() (*Status, error) { var v internal.Status @@ -568,4 +571,3 @@ var sleep = time.Sleep var _ conn.Resource = &Dev{} var _ physic.SenseEnv = &Dev{} -var _ fmt.Stringer = &cciConn{} diff --git a/devices/lepton/lepton.go b/devices/lepton/lepton.go index 0fa92d9..665cba1 100644 --- a/devices/lepton/lepton.go +++ b/devices/lepton/lepton.go @@ -447,4 +447,3 @@ func equalUint16(a, b []uint16) bool { } var _ conn.Resource = &Dev{} -var _ fmt.Stringer = &Dev{} diff --git a/devices/lirc/lirc.go b/devices/lirc/lirc.go index 30a1bf8..dc6dfa0 100644 --- a/devices/lirc/lirc.go +++ b/devices/lirc/lirc.go @@ -14,6 +14,7 @@ import ( "strings" "sync" + "periph.io/x/periph/conn" "periph.io/x/periph/conn/gpio/gpioreg" "periph.io/x/periph/conn/ir" ) @@ -44,10 +45,18 @@ type Conn struct { pendingList map[string][]string // list of remotes and associated keys being created. } +// String implements conn.Resource. func (c *Conn) String() string { return "lirc" } +// Halt implements conn.Resource. +// +// It has no effect. +func (c *Conn) Halt() error { + return nil +} + // Close closes the socket to lirc. It is not a requirement to close before // process termination. func (c *Conn) Close() error { @@ -264,4 +273,4 @@ func getPins() (int, int) { } var _ ir.Conn = &Conn{} -var _ fmt.Stringer = &Conn{} +var _ conn.Resource = &Conn{} diff --git a/devices/tm1637/tm1637.go b/devices/tm1637/tm1637.go index 8df7f40..d663d2c 100644 --- a/devices/tm1637/tm1637.go +++ b/devices/tm1637/tm1637.go @@ -208,4 +208,3 @@ func (d *Dev) sleepHalfCycle() { var spin = cpu.Nanospin var _ conn.Resource = &Dev{} -var _ fmt.Stringer = &Dev{} diff --git a/experimental/devices/bitbang/i2c.go b/experimental/devices/bitbang/i2c.go index 84629a1..3a647f0 100644 --- a/experimental/devices/bitbang/i2c.go +++ b/experimental/devices/bitbang/i2c.go @@ -256,4 +256,3 @@ func (i *I2C) sleepHalfCycle() { } var _ i2c.Bus = &I2C{} -var _ fmt.Stringer = &I2C{} diff --git a/experimental/devices/bitbang/spi.go b/experimental/devices/bitbang/spi.go index 750dc49..ec8c7b7 100644 --- a/experimental/devices/bitbang/spi.go +++ b/experimental/devices/bitbang/spi.go @@ -279,5 +279,5 @@ func (s *spiConn) unassertCS() error { return nil } +var _ spi.Conn = &spiConn{} var _ spi.PortCloser = &SPI{} -var _ fmt.Stringer = &SPI{} diff --git a/experimental/devices/hd44780/hd44780.go b/experimental/devices/hd44780/hd44780.go index e27640d..2dcfc14 100644 --- a/experimental/devices/hd44780/hd44780.go +++ b/experimental/devices/hd44780/hd44780.go @@ -239,4 +239,3 @@ func delayMs(ms int) { } var _ conn.Resource = &Dev{} -var _ fmt.Stringer = &Dev{} diff --git a/experimental/devices/mfrc522/mfrc522.go b/experimental/devices/mfrc522/mfrc522.go index eb48838..92796e1 100644 --- a/experimental/devices/mfrc522/mfrc522.go +++ b/experimental/devices/mfrc522/mfrc522.go @@ -134,11 +134,19 @@ type Dev struct { spiDev spi.Conn } +// String implements conn.Resource. func (r *Dev) String() string { return fmt.Sprintf("Mifare MFRC522 [bus: %v, reset pin: %s, irq pin: %s]", r.spiDev, r.resetPin.Name(), r.irqPin.Name()) } +// Halt implements conn.Resource. +// +// It soft-stops the chip - PowerDown bit set, command IDLE +func (r *Dev) Halt() error { + return r.devWrite(commands.CommandReg, 16) +} + // SetOperationtimeout updates the device timeout for card operations. // // Effectively that sets the maximum time the RFID device will wait for IRQ @@ -165,11 +173,6 @@ func (r *Dev) Reset() error { return r.devWrite(commands.CommandReg, commands.PCD_RESETPHASE) } -// Halt soft-stops the chip - PowerDown bit set, command IDLE -func (r *Dev) Halt() error { - return r.devWrite(commands.CommandReg, 16) -} - // SetAntenna configures the antenna state, on/off. func (r *Dev) SetAntenna(state bool) error { if state { @@ -754,10 +757,9 @@ var sequenceCommands = struct { }, } -var _ conn.Resource = &Dev{} -var _ fmt.Stringer = &Dev{} -var _ fmt.Stringer = &BlocksAccess{} - func wrapf(format string, a ...interface{}) error { return fmt.Errorf("mfrc522: "+format, a...) } + +var _ conn.Resource = &Dev{} +var _ fmt.Stringer = &BlocksAccess{}