I found out it needs delays. I put sleep(0.000_072) after each SPI write because the datasheet says the commands can take up to 72 microseconds and it works fine now.
def _write(self, cmd, data):
self.cmd[0] = cmd
self.cmd[1] = (data & 0xF0)
self.cmd[2] = ((data << 4) & 0xF0)
self.spi.write(self.cmd)
sleep(0.000_072) # Most st7920 commands need 72 us delay
def init(self):
if self.rst:
self.rst(0)
sleep(0.1)
self.rst(1)
for cmd in (ST7920_BASIC,
ST7920_CLEAR_SCREEN,
ST7920_DISPLAY_CTRL,
ST7920_EXTEND,
ST7920_EXTEND | 0x02):
self._write(ST7920_CMD, cmd)
sleep(0.000_072)
self.show()
Thanks for posting this program. It's a good simple example and I found it very useful.
Hi, this would not work with a Raspberry Pi Pico.
I found out it needs delays. I put
sleep(0.000_072)
after each SPI write because the datasheet says the commands can take up to 72 microseconds and it works fine now.Thanks for posting this program. It's a good simple example and I found it very useful.