diff --git a/demo_pbm.py b/demo_pbm.py new file mode 100644 index 0000000..2076fff --- /dev/null +++ b/demo_pbm.py @@ -0,0 +1,108 @@ +"""ILI9341 demo (PBM - Portable Bitmap).""" +from ili9341 import Display, color565 +from struct import pack, unpack +from framebuf import FrameBuffer, MONO_HLSB, RGB565 # type: ignore +from machine import Pin, SPI # type: ignore +from time import sleep + + +def create_palette(foreground, background=0, invert=False): + """Create framebuffer palette to translate between MONO_HLSB and RGB565. + + Args: + foreground(int): Foreground color in RGB656 format + background(int): Background color in RGB656 format (default Black) + invert(bool): Invert foreground and background (default False) + Returns: + FrameBuffer: Color palette + """ + # Need to swap endian colors + foreground = unpack('>H', pack('H', pack('