package hardware import ( "periph.io/x/conn/v3/gpio" "periph.io/x/conn/v3/i2c" "periph.io/x/conn/v3/i2c/i2creg" "periph.io/x/conn/v3/physic" ) type I2CConfig struct { // Bus name. Bus string // Reset is the reset pin. Reset gpio.PinOut // BL is the backlight pin. BL gpio.PinOut // Address is the I2C address. Address uint16 // Frequency is the I2C bus frequency. Frequency physic.Frequency } // Open the configured bus. func (c I2CConfig) Open() (i2c.BusCloser, error) { b, err := i2creg.Open(c.Bus) if err != nil { return nil, err } if c.Frequency != 0 { if err := b.SetSpeed(c.Frequency); err != nil { _ = b.Close() return nil, err } } return b, nil } type SPIConfig struct { // Port is the SPI port name. Port string // Reset is the reset pin. Reset gpio.PinOut // CS is the chip select pin. CS gpio.PinOut // DC is the data/command pin. DC gpio.PinOut // BL is the backlight pin. BL gpio.PinOut // Frequency is the SPI bus frequency. Frequency physic.Frequency }