Make sure the buffer is big enough, if the HEIGHT is not evenly divisible by 8

This commit is contained in:
Stefan Karlsson 2023-04-14 23:13:09 +02:00
parent 1b893ace17
commit 12fed55496

View file

@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import math
import adafruit_framebuf
print("framebuf test will draw to the REPL")
@ -8,11 +9,12 @@ print("framebuf test will draw to the REPL")
WIDTH = 32
HEIGHT = 8
buffer = bytearray(round(WIDTH * HEIGHT / 8))
buffer = bytearray(round(WIDTH * math.ceil(HEIGHT / 8)))
fb = adafruit_framebuf.FrameBuffer(
buffer, WIDTH, HEIGHT, buf_format=adafruit_framebuf.MVLSB
)
# Ascii printer for very small framebufs!
def print_buffer(the_fb):
print("." * (the_fb.width + 2))