Skip to content

Commit 12fed55

Browse files
committed
Make sure the buffer is big enough, if the HEIGHT is not evenly divisible by 8
1 parent 1b893ac commit 12fed55

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/framebuf_simpletest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
22
# SPDX-License-Identifier: MIT
33

4+
import math
45
import adafruit_framebuf
56

67
print("framebuf test will draw to the REPL")
78

89
WIDTH = 32
910
HEIGHT = 8
1011

11-
buffer = bytearray(round(WIDTH * HEIGHT / 8))
12+
buffer = bytearray(round(WIDTH * math.ceil(HEIGHT / 8)))
1213
fb = adafruit_framebuf.FrameBuffer(
1314
buffer, WIDTH, HEIGHT, buf_format=adafruit_framebuf.MVLSB
1415
)
1516

17+
1618
# Ascii printer for very small framebufs!
1719
def print_buffer(the_fb):
1820
print("." * (the_fb.width + 2))

0 commit comments

Comments
 (0)