Documentation ¶
Overview ¶
Package st7567 implements an interface to the single-chip dot matrix LCD
Datasheet ¶
https://www.newhavendisplay.com/appnotes/datasheets/LCDs/ST7567.pdf
Example ¶
package main import ( "fmt" "log" "os" "os/signal" "syscall" "time" "periph.io/x/periph/conn/gpio/gpioreg" "periph.io/x/periph/conn/spi/spireg" "periph.io/x/periph/experimental/devices/st7567" "periph.io/x/periph/host" ) func main() { if _, err := host.Init(); err != nil { log.Fatal(err) } conn, err := spireg.Open("SPI0.0") if err != nil { log.Fatal(err) } defer conn.Close() dc := gpioreg.ByName("6") reset := gpioreg.ByName("5") cs := gpioreg.ByName("8") o := &st7567.Opts{ Bias: st7567.Bias17, CommonDirection: st7567.CommonDirReverse, SegmentDirection: st7567.SegmentDirNormal, Display: st7567.DisplayNormal, RegulationRatio: st7567.RegulationRatio{st7567.RegResistorRR0, st7567.RegResistorRR1}, StartLine: 0, Contrast: 40, } dev, err := st7567.New(conn, dc, reset, cs, o) if err != nil { log.Fatal(err) } defer func() { fmt.Println("halting device") dev.Halt() }() //Control-C trap c := make(chan os.Signal) signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { <-c fmt.Println("halting device") dev.Halt() os.Exit(1) }() for x := 0; x < st7567.Width; x++ { for y := 0; y < st7567.Height; y++ { dev.SetPixel(x, y, true) } if err = dev.Update(); err != nil { log.Fatal(err) } time.Sleep(40 * time.Millisecond) } for i := 0; i < 64; i++ { fmt.Printf("current contrast value: %d\n", i) if err = dev.SetContrast(byte(i)); err != nil { log.Fatal(err) } if err = dev.Update(); err != nil { log.Fatal(err) } time.Sleep(100 * time.Millisecond) } if err = dev.Update(); err != nil { log.Fatal(err) } fmt.Println("entering power save mode") time.Sleep(2 * time.Second) if err = dev.PowerSave(); err != nil { log.Fatal(err) } time.Sleep(2 * time.Second) fmt.Println("leaving power save mode") if err = dev.WakeUp(); err != nil { log.Fatal(err) } time.Sleep(2 * time.Second) }
Output:
Index ¶
Examples ¶
Constants ¶
const ( // Width the max pixel width Width = 128 // Height the max pixel height Height = 64 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bias ¶
type Bias byte
Bias selects the LCD bias ratio of the voltage required for driving the LCD
type CommonDirection ¶
type CommonDirection byte
CommonDirection controls the common output status which changes the vertical display direction.
const ( // CommonDirNormal (0xc0): Column address 0 is mapped to SEG0 CommonDirNormal CommonDirection = 0xc0 // CommonDirReverse (0xc8): Column address 128 is mapped to SEG0 CommonDirReverse CommonDirection = 0xc8 )
func (*CommonDirection) Set ¶
func (cd *CommonDirection) Set(s string) error
func (*CommonDirection) String ¶
func (cd *CommonDirection) String() string
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev is a handle to a ST7567.
type Display ¶
type Display byte
Display contains if the display is in normal or inverse mode (black will be white and vice versa)
type Opts ¶
type Opts struct { // Bias selects the LCD bias ratio of the voltage required for driving the LCD. Bias Bias // SegmentDirection is the direction of the segments. SegmentDirection SegmentDirection // CommonDirection controls the common output status which changes the vertical display direction. CommonDirection CommonDirection // Display changes the selected and non-selected voltage of SEG. Display Display // RegulationRatio controls the regulation ratio of the built-in regulator. RegulationRatio RegulationRatio // StartLine sets the line address of the Display Data RAM to determine the initial display line. StartLine byte // Contrast the value to adjust the display contrast. Contrast byte }
Opts contains the configuration for the S7567 device.
type RegulationRatio ¶
type RegulationRatio []RegulationResistor
RegulationRatio selects the regulation resistor ratio
func (*RegulationRatio) Set ¶
func (rrs *RegulationRatio) Set(value string) error
func (*RegulationRatio) String ¶
func (rrs *RegulationRatio) String() string
type RegulationResistor ¶
type RegulationResistor byte
RegulationResistor is the single regulation resistor value
const ( // RegResistorRR0 (0x21): Regulation Resistor ratio RegResistorRR0 RegulationResistor = 0x21 // RegResistorRR1 (0x22): Regulation Resistor ratio RegResistorRR1 RegulationResistor = 0x22 // RegResistorRR2 (0x24): Regulation Resistor ratio RegResistorRR2 RegulationResistor = 0x24 )
func (*RegulationResistor) Set ¶
func (rr *RegulationResistor) Set(s string) error
func (*RegulationResistor) String ¶
func (rr *RegulationResistor) String() string
type SegmentDirection ¶
type SegmentDirection byte
SegmentDirection is the direction of the segments
const ( // SegmentDirNormal (0xa0): Column address 0 is mapped to SEG0 SegmentDirNormal SegmentDirection = 0xa0 // SegmentDirReverse (0xa1): Column address 128 is mapped to SEG0 SegmentDirReverse SegmentDirection = 0xa1 )
func (*SegmentDirection) Set ¶
func (sd *SegmentDirection) Set(s string) error
func (*SegmentDirection) String ¶
func (sd *SegmentDirection) String() string