Skip to content

Commit

Permalink
Merge pull request #420 from newtonick/larger-spidev-buffer
Browse files Browse the repository at this point in the history
Update ST7789 to support writing to larger SPIDEV buffer
  • Loading branch information
newtonick authored Aug 4, 2023
2 parents b7e5252 + 3276628 commit 886391b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 7 additions & 0 deletions docs/manual_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ workon seedsigner-env
pwd
```

### Optional: increase spidev buffer size
This allows `ST7789.py` to update the LCD without performing multiple write operations because the default buffer size is 4096 bytes. The default can be changed via the `/boot/cmdline.txt` file. You will need to add `spidev.bufsiz=131072` to the end of this single lined file command.

Example `cmdline.txt` contents:
```
console=serial0,115200 console=tty1 root=PARTUUID=2fa4ba7e-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether spidev.bufsiz=131072
```

### Configure `systemd` to run SeedSigner at boot:

Expand Down
2 changes: 1 addition & 1 deletion src/seedsigner/gui/screens/scan_screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ScanScreen(BaseScreen):
decoder: DecodeQR = None
instructions_text: str = "< back | Scan a QR code"
resolution: tuple[int,int] = (480, 480)
framerate: int = 5 # TODO: alternate optimization for Pi Zero 2W?
framerate: int = 6 # TODO: alternate optimization for Pi Zero 2W?
render_rect: tuple[int,int,int,int] = None


Expand Down
6 changes: 2 additions & 4 deletions src/seedsigner/hardware/ST7789.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,11 @@ def ShowImage(self,Image,Xstart,Ystart):
pix = arr.tobytes()
self.SetWindows ( 0, 0, self.width, self.height)
GPIO.output(self._dc,GPIO.HIGH)
for i in range(0,len(pix),4096):
self._spi.writebytes(pix[i:i+4096])
self._spi.writebytes2(pix)

def clear(self):
"""Clear contents of image buffer"""
_buffer = [0xff]*(self.width * self.height * 2)
self.SetWindows ( 0, 0, self.width, self.height)
GPIO.output(self._dc,GPIO.HIGH)
for i in range(0,len(_buffer),4096):
self._spi.writebytes(_buffer[i:i+4096])
self._spi.writebytes2(_buffer)

0 comments on commit 886391b

Please sign in to comment.