Skip to content

Commit

Permalink
st7735: make SPI Tx faster
Browse files Browse the repository at this point in the history
Most of the ceremony around pin toggling was in fact unnecessary. This
improves performance measurably (rougly 6% in one measurement) and cuts
down on binary size by 80 bytes.
  • Loading branch information
aykevl committed Oct 10, 2019
1 parent 955b3a5 commit dcfd9c0
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions st7735/st7735.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,21 +383,8 @@ func (d *Device) Data(data uint8) {

// Tx sends data to the display
func (d *Device) Tx(data []byte, isCommand bool) {
if isCommand {
d.csPin.High()
d.dcPin.Low()
d.csPin.Low()

d.bus.Tx(data, nil)
d.csPin.High()
} else {
d.csPin.High()
d.dcPin.High()
d.csPin.Low()

d.bus.Tx(data, nil)
d.csPin.High()
}
d.dcPin.Set(!isCommand)
d.bus.Tx(data, nil)
}

// Size returns the current size of the display.
Expand Down

0 comments on commit dcfd9c0

Please sign in to comment.