st7567: Minor cleanup (#453)

* correct comment of CommonDirection
* do not allocate unnecessary memory
pull/1/head
Lars Hoogestraat 6 years ago committed by GitHub
parent 2ac43be45e
commit a86ea4f5ce

@ -245,7 +245,7 @@ func (rr *RegulationResistor) String() string {
type RegulationRatio []RegulationResistor type RegulationRatio []RegulationResistor
func (rrs *RegulationRatio) String() string { func (rrs *RegulationRatio) String() string {
return "regulation resistor ratios" return "Regulation resistor ratio"
} }
func (rrs *RegulationRatio) Set(value string) error { func (rrs *RegulationRatio) Set(value string) error {
@ -278,7 +278,7 @@ type Opts struct {
Bias Bias Bias Bias
// SegmentDirection is the direction of the segments. // SegmentDirection is the direction of the segments.
SegmentDirection SegmentDirection SegmentDirection SegmentDirection
// CommonDirection is the direction of the segments. // CommonDirection controls the common output status which changes the vertical display direction.
CommonDirection CommonDirection CommonDirection CommonDirection
// Display changes the selected and non-selected voltage of SEG. // Display changes the selected and non-selected voltage of SEG.
Display Display Display Display
@ -305,19 +305,20 @@ func New(p spi.Port, dc gpio.PinOut, rst gpio.PinOut, cs gpio.PinIn, o *Opts) (*
cs: cs, cs: cs,
} }
cmd := make([]byte, 9) cmd := [...]byte{
cmd = append(cmd, byte(o.Bias)) byte(o.Bias),
cmd = append(cmd, byte(o.SegmentDirection)) byte(o.SegmentDirection),
cmd = append(cmd, byte(o.CommonDirection)) byte(o.CommonDirection),
cmd = append(cmd, byte(o.Display)) byte(o.Display),
cmd = append(cmd, setStartLine|o.StartLine) setStartLine | o.StartLine,
cmd = append(cmd, powerControl) powerControl,
cmd = append(cmd, byte(o.RegulationRatio.getValue())) byte(o.RegulationRatio.getValue()),
cmd = append(cmd, displayOn) displayOn,
cmd = append(cmd, setContrast) setContrast,
cmd = append(cmd, o.Contrast) o.Contrast,
}
if err := d.sendCommand(cmd); err != nil {
if err := d.sendCommand(cmd[:]); err != nil {
return nil, err return nil, err
} }

Loading…
Cancel
Save