diff --git a/experimental/devices/st7567/st7567.go b/experimental/devices/st7567/st7567.go index 51bf4a0..ab60f2a 100644 --- a/experimental/devices/st7567/st7567.go +++ b/experimental/devices/st7567/st7567.go @@ -245,7 +245,7 @@ func (rr *RegulationResistor) String() string { type RegulationRatio []RegulationResistor func (rrs *RegulationRatio) String() string { - return "regulation resistor ratios" + return "Regulation resistor ratio" } func (rrs *RegulationRatio) Set(value string) error { @@ -278,7 +278,7 @@ type Opts struct { Bias Bias // SegmentDirection is the direction of the segments. SegmentDirection SegmentDirection - // CommonDirection is the direction of the segments. + // 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 @@ -305,19 +305,20 @@ func New(p spi.Port, dc gpio.PinOut, rst gpio.PinOut, cs gpio.PinIn, o *Opts) (* cs: cs, } - cmd := make([]byte, 9) - cmd = append(cmd, byte(o.Bias)) - cmd = append(cmd, byte(o.SegmentDirection)) - cmd = append(cmd, byte(o.CommonDirection)) - cmd = append(cmd, byte(o.Display)) - cmd = append(cmd, setStartLine|o.StartLine) - cmd = append(cmd, powerControl) - cmd = append(cmd, byte(o.RegulationRatio.getValue())) - cmd = append(cmd, displayOn) - cmd = append(cmd, setContrast) - cmd = append(cmd, o.Contrast) - - if err := d.sendCommand(cmd); err != nil { + cmd := [...]byte{ + byte(o.Bias), + byte(o.SegmentDirection), + byte(o.CommonDirection), + byte(o.Display), + setStartLine | o.StartLine, + powerControl, + byte(o.RegulationRatio.getValue()), + displayOn, + setContrast, + o.Contrast, + } + + if err := d.sendCommand(cmd[:]); err != nil { return nil, err }