From 59bb70fa649d1994d367e69fb6272f36a6176825 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Mon, 6 Apr 2020 21:47:30 +0100 Subject: [PATCH] wasp: simulator: Optimize the drawing process This makes per-pixel access more than double the performnace of a regular pixelview (but at the expense of requiring numpy). --- wasp/boards/simulator/display.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wasp/boards/simulator/display.py b/wasp/boards/simulator/display.py index 7fdbef6..c226050 100644 --- a/wasp/boards/simulator/display.py +++ b/wasp/boards/simulator/display.py @@ -41,7 +41,8 @@ class ST7789Sim(object): self.y = self.rowclip[0] elif self.cmd == RAMWR: - pixelview = sdl2.ext.PixelView(windowsurface) + #pixelview = sdl2.ext.PixelView(windowsurface) + pixelview = sdl2.ext.pixels2d(windowsurface) half = False for d in data: @@ -52,11 +53,14 @@ class ST7789Sim(object): rgb |= d half = False - pixel = ((rgb & 0xf800) >> 8, - (rgb & 0x07e0) >> 3, - (rgb & 0x001f) << 3) + #pixel = ((rgb & 0xf800) >> 8, + # (rgb & 0x07e0) >> 3, + # (rgb & 0x001f) << 3) + pixel = (((rgb & 0xf800) << 8) + + ((rgb & 0x07e0) << 5) + + ((rgb & 0x001f) << 3)) - pixelview[self.y][self.x] = pixel + pixelview[self.x][self.y] = pixel self.x += 1 if self.x > self.colclip[1]: