Documentation ¶
Overview ¶
Package piglow implements a driver for the Pimoroni PiGlow.
Example ¶
package main import ( "time" "github.com/goiot/devices/piglow" "golang.org/x/exp/io/i2c" ) func main() { p, err := piglow.Open(&i2c.Devfs{Dev: "/dev/i2c-1"}) if err != nil { panic(err) } if err := p.Setup(); err != nil { panic(err) } brightness := 0 for i := 0; i < 10; i++ { brightness ^= 1 p.SetBrightness(brightness) time.Sleep(300 * time.Millisecond) } }
Output:
Index ¶
- type PiGlow
- func (p *PiGlow) Blue(level int) error
- func (p *PiGlow) Close() error
- func (p *PiGlow) Enable() error
- func (p *PiGlow) Green(level int) error
- func (p *PiGlow) Orange(level int) error
- func (p *PiGlow) Red(level int) error
- func (p *PiGlow) Reset() error
- func (p *PiGlow) SetBrightness(level int) error
- func (p *PiGlow) SetLEDBrightness(led, level int) error
- func (p *PiGlow) SetLEDControlRegister(register, enables int) error
- func (p *PiGlow) Setup() error
- func (p *PiGlow) Shutdown() error
- func (p *PiGlow) White(level int) error
- func (p *PiGlow) Yellow(level int) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PiGlow ¶
type PiGlow struct {
// contains filtered or unexported fields
}
PiGlow represents a PiGlow device
func Open ¶
Open opens a new PiGlow. A PiGlow must be closed if no longer in use. If the PiGlow has not been powered down since last use, it will be opened with it's last programmed state.
func (*PiGlow) Close ¶
Close frees the underlying resources. It must be called once the PiGlow is no longer in use.
func (*PiGlow) SetBrightness ¶
SetBrightness sets all the LEDs to the level 0-255.
func (*PiGlow) SetLEDBrightness ¶
SetLEDBrightness sets the led 1-18 to the level 0-255.
func (*PiGlow) SetLEDControlRegister ¶
SetLEDControlRegister sets the control register 1-3 to the bitmask enables.
bitmask definition: 0 - LED disabled 1 - LED enabled LED Control Register 1 - LED channel 1 to 6 bits 0-5 LED Control Register 2 - LED channel 7 to 12 bits 0-5 LED Control Register 3 - LED channel 13 to 18 bits 0-5
func (*PiGlow) Setup ¶
Setup enables normal operations, resets the internal registers, and enables all LED control registers