Documentation ¶
Overview ¶
Package tm1637 controls a TM1637 device over GPIO pins.
Datasheet ¶
http://olimex.cl/website_MCI/static/documents/Datasheet_TM1637.pdf
Example ¶
package main import ( "log" "periph.io/x/periph/conn/gpio/gpioreg" "periph.io/x/periph/devices/tm1637" "periph.io/x/periph/host" ) func main() { // Make sure periph is initialized. if _, err := host.Init(); err != nil { log.Fatal(err) } clk := gpioreg.ByName("GPIO6") data := gpioreg.ByName("GPIO12") if clk == nil || data == nil { log.Fatal("Failed to find pins") } dev, err := tm1637.New(clk, data) if err != nil { log.Fatalf("failed to initialize tm1637: %v", err) } if err := dev.SetBrightness(tm1637.Brightness10); err != nil { log.Fatalf("failed to set brightness on tm1637: %v", err) } if _, err := dev.Write(tm1637.Clock(12, 00, true)); err != nil { log.Fatalf("failed to write to tm1637: %v", err) } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Brightness ¶
type Brightness uint8
Brightness defines the screen brightness as controlled by the internal PWM.
const ( Off Brightness = 0x80 // Completely off. Brightness1 Brightness = 0x88 // 1/16 PWM Brightness2 Brightness = 0x89 // 2/16 PWM Brightness4 Brightness = 0x8A // 4/16 PWM Brightness10 Brightness = 0x8B // 10/16 PWM Brightness11 Brightness = 0x8C // 11/16 PWM Brightness12 Brightness = 0x8D // 12/16 PWM Brightness13 Brightness = 0x8E // 13/16 PWM Brightness14 Brightness = 0x8F // 14/16 PWM )
Valid brightness values.
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev represents an handle to a tm1637.
func (*Dev) SetBrightness ¶
func (d *Dev) SetBrightness(b Brightness) error
SetBrightness changes the brightness and/or turns the display on and off.
Click to show internal directories.
Click to hide internal directories.