"""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('