waveshare213v2: Move command and data sending code into error handler

This code isn't used directly and there's no need to keep the additional
complexity.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
pull/39/head
Michael Hanselmann 4 years ago committed by M-A
parent 969dc07218
commit b25f6410ea

@ -44,12 +44,20 @@ func (eh *errorHandler) sendCommand(cmd byte) {
if eh.err != nil { if eh.err != nil {
return return
} }
eh.err = eh.d.sendCommand(cmd)
eh.dcOut(gpio.Low)
eh.csOut(gpio.Low)
eh.cTx([]byte{cmd}, nil)
eh.csOut(gpio.High)
} }
func (eh *errorHandler) sendData(d []byte) { func (eh *errorHandler) sendData(data []byte) {
if eh.err != nil { if eh.err != nil {
return return
} }
eh.err = eh.d.sendData(d)
eh.dcOut(gpio.High)
eh.csOut(gpio.Low)
eh.cTx(data, nil)
eh.csOut(gpio.High)
} }

@ -357,28 +357,6 @@ func (d *Dev) String() string {
return fmt.Sprintf("epd.Dev{%s, %s, Height: %d, Width: %d}", d.c, d.dc, d.opts.Height, d.opts.Width) return fmt.Sprintf("epd.Dev{%s, %s, Height: %d, Width: %d}", d.c, d.dc, d.opts.Height, d.opts.Width)
} }
func (d *Dev) sendData(c []byte) error {
eh := errorHandler{d: *d}
eh.dcOut(gpio.High)
eh.csOut(gpio.Low)
eh.cTx(c, nil)
eh.csOut(gpio.High)
return eh.err
}
func (d *Dev) sendCommand(cmd byte) error {
eh := errorHandler{d: *d}
eh.dcOut(gpio.Low)
eh.csOut(gpio.Low)
eh.cTx([]byte{cmd}, nil)
eh.csOut(gpio.High)
return eh.err
}
func (d *Dev) turnOnDisplay() error { func (d *Dev) turnOnDisplay() error {
eh := errorHandler{d: *d} eh := errorHandler{d: *d}

Loading…
Cancel
Save