Documentation ¶
Overview ¶
Package sn3218 controls a SN3218 LED driver with 18 LEDs over an i2c bus.
Datasheet ¶
http://www.si-en.com/uploadpdf/s2011517171720.pdf
Example ¶
if _, err := host.Init(); err != nil { log.Fatal(err) } b, err := i2creg.Open("") if err != nil { log.Fatal(err) } defer b.Close() d, err := sn3218.New(b) if err != nil { log.Fatal(err) } defer d.Halt() // By default, the device is disabled and brightness is 0 for all LEDs // So let's set the brightness to a low value and enable the device to // get started d.BrightnessAll(1) d.Sleep() // Switch LED 7 on if err := d.Switch(7, true); err != nil { log.Fatal("Error while switching LED", err) } time.Sleep(1000 * time.Millisecond)
Output:
Index ¶
- type Dev
- func (d *Dev) Brightness(channel int, value byte) error
- func (d *Dev) BrightnessAll(value byte) error
- func (d *Dev) GetState(channel int) (bool, byte, error)
- func (d *Dev) Halt() error
- func (d *Dev) Sleep() error
- func (d *Dev) Switch(channel int, state bool) error
- func (d *Dev) SwitchAll(state bool) error
- func (d *Dev) WakeUp() error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev is a handler to sn3218 controller.
func (*Dev) Brightness ¶
Brightness sets the brightness of led (0..17) to value (0..255).
func (*Dev) BrightnessAll ¶
BrightnessAll sets the brightness of all channels to the value (0..255).
func (*Dev) GetState ¶
GetState returns the state (on/off) and the brightness (0..255) of the Channel 0..17.
Click to show internal directories.
Click to hide internal directories.