From dcfd9c066dfcb1e949ca9dd2481bf3e92d44342f Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 10 Oct 2019 20:35:50 +0200 Subject: [PATCH] st7735: make SPI Tx faster 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. --- st7735/st7735.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/st7735/st7735.go b/st7735/st7735.go index 37e3c3d..fb0fef3 100644 --- a/st7735/st7735.go +++ b/st7735/st7735.go @@ -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.