Ich nutze die LVGL-library zur Grafikdarstellung auf einem 1.5" Oled-Display. Kurz zusammengefasst: Das Display mit SSD1351-Controller hat 128x128 Pixel, jedes Pixel belegt 2 Bytes im RGB565-Format. Es wird von einem ESP32 gesteuert, der das Display über SPI mit Daten füttert. Initialisierungs- und Flushroutine habe ich selbst geschrieben und funktionieren auch soweit.
Allerdings werden völlig falsche Farben dargestellt. Die Ursache ist, dass LVGL die 16-bit Pixelwerte im Little-Endian-Format mit low-Byte voran im Framebuffer ablegt, das Display sie aber als Big-Endian haben will, also high-Byte zuerst. Dies ist in der Doku von LVGL auch beschrieben:
"You may set LV_COLOR_16_SWAP in lv_conf.h to swap bytes of RGB565 colors. You may need this when sending 16-bit colors via a byte-oriented interface like SPI. As 16-bit numbers are stored in little-endian format (lower byte at the lower address), the interface will send the lower byte first. However, displays usually need the higher byte first. A mismatch in the byte order will result in highly distorted colors."
Leider gibt es LV_COLOR_16_SWAP als Konfigurationsoption anscheinend nicht mehr. Wie mache ich das Vertauschen der Bytes dann? In der flush-Routine ist das leider nicht möglich, da LVGL oft nur Teile des Framebuffers neu beschreibt und ich daher für jedes einzelne Pixel Buch führen müsste, ob es schon getauscht wurde oder nicht.