diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2021-01-17 17:44:21 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2021-01-17 17:44:21 (GMT) |
| commit | 6b41c8f3db1778826ec8556f8900878a8f32c87a (patch) | |
| tree | 8b65647a30cbf54f7a4bc314b4d4adcabda4701a /wasp/draw565.py | |
| parent | 5abae5a7f63f6841744ad63e7c8bbbb1d8452b37 (diff) | |
drivers: st7789: Pre-allocate a memoryview
Reduce the cost of slicing the linebuffer by pre-allocating a memoryview.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/draw565.py')
| -rw-r--r-- | wasp/draw565.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/wasp/draw565.py b/wasp/draw565.py index 5f61a6c..37e96b5 100644 --- a/wasp/draw565.py +++ b/wasp/draw565.py @@ -85,7 +85,7 @@ def _bounding_box(s, font): def _draw_glyph(display, glyph, x, y, bgfg): (px, h, w) = glyph - buf = memoryview(display.linebuffer)[0:2*(w+1)] + buf = display.linebuffer[0:2*(w+1)] buf[2*w] = 0 buf[2*w + 1] = 0 bytes_per_row = (w + 7) // 8 @@ -155,7 +155,7 @@ class Draw565(object): # Populate the line buffer buf = display.linebuffer - sz = len(display.linebuffer) // 2 + sz = len(buf) // 2 _fill(buf, bg, min(sz, remaining), 0) display.quick_start() @@ -163,7 +163,7 @@ class Draw565(object): quick_write(buf) remaining -= sz if remaining: - quick_write(memoryview(display.linebuffer)[0:2*remaining]) + quick_write(buf[0:2*remaining]) display.quick_end() @micropython.native @@ -195,7 +195,7 @@ class Draw565(object): display.set_window(pos[0], pos[1], sx, sy) - buf = memoryview(display.linebuffer)[0:2*sx] + buf = display.linebuffer[0:2*sx] bp = 0 color = bg @@ -233,7 +233,7 @@ class Draw565(object): palette = array.array('H', (0, c1, c2, fg)) next_color = 1 rl = 0 - buf = memoryview(display.linebuffer)[0:2*sx] + buf = display.linebuffer[0:2*sx] bp = 0 display.quick_start() |
