ST7920_SPI_master library not using delays for glcd128x64

God gave you Arduino Library documentation e.g. Tools->Reference

from file:///C:/Program%20Files%20(x86)/Arduino-1.8.13/reference/www.arduino.cc/en/Reference/SPISettings.html

SPISettings mySettting(speedMaximum, dataOrder, dataMode)
Note: Best when any setting is a variable''

Parameters

speedMaximum: The maximum speed of communication. For a SPI chip rated up to 20 MHz, use 20000000.

dataOrder: MSBFIRST or LSBFIRST

dataMode : SPI_MODE0, SPI_MODE1, SPI_MODE2, or SPI_MODE3

Returns

None.

Since you have a 16MHz Uno/Nano the available SPI speeds are:
8Mb/s, 4M, 2M, 1M, 500k, 250k, 125k, 62.5k.

So if you specify maximumSpeed = 950kB it will use the 950kB or next slower. i.e. 500kb/s
If you specify 20Mb/s it will use 8Mb/s on a 16MHz Nano.
However you will get 20Mb/s on an 80MHz ESP8266
Or 16Mb/s on a 64MHz STM32

There is no point is specifying 999.9kb/s or any other artificial speed.
Just follow the datasheet. If the chip is specified for 500kb/s just say 500000

From memory, cbm80amiga manipulates a full size shadow buffer in SRAM. Then blits the whole buffer in one go.
Also from memory, the ST7920 is fussy about how fast you send the SPI data. cbm80amiga achieves the "best possible throughput".

ST7920 LCD screens do not like fast updates. You can do running horse animations but they look smeary if you go too quickly.

His examples work very well on real ST7920 hardware.
I suggest that you just use his proven library.

Incidentally, you can drive a KS0108 parallel controller much faster than a ST7920 parallel controller. A bit pointless when LCD is smeary.
Driving ST7920 SPI works plenty fast enough. And it wastes LESS pins.

David.

1 Like