Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displays smaller sprite if using 4bits instead of 16bits #3407

Open
Mike-Kuznetsov opened this issue Jul 16, 2024 · 1 comment
Open

Displays smaller sprite if using 4bits instead of 16bits #3407

Mike-Kuznetsov opened this issue Jul 16, 2024 · 1 comment

Comments

@Mike-Kuznetsov
Copy link

Mike-Kuznetsov commented Jul 16, 2024

  1. Problem: Everything is fine when i use 16bit color depth sprite but if i try to use 4bit sprite it displays only on the top of the display.

I have a Lilygo T-RGB. It's resolution is 480x480 so GIFs display pretty slow. I wanted to try to lower the color depth from 16 bit to 4 bit to make it work faster. But it makes the device read 4bit images like 16bit images so for example instead of displaying 100 4bit pixels it displays 25 16bit pixels.

Maybe i do something wrong, maybe i need to do some extra steps, maybe i need to change something in the library, maybe my setup works only with 16bit colors. I've tried to change uint16_t to uint8_t in the Lilygo's library panel class but it doesn't change anything. I would like to get any info on why this happens.

It's a good library and of course i'm not sure that the problem is in the library but i would like to get any suggestions on how to make gifs work faster or on how to change color depth properly.

  1. IDE: Arduino IDE
  2. TFT_eSPI version: 2.5.43 (latest) and 2.4.97
  3. ESP package version: 2.0.14
  4. Chip: ESP32 S3R8
  5. Driver: ST7701S
    Vendor's webpage - https://www.lilygo.cc/products/t-rgb
    Vendor's Github - https://github.com/Xinyuan-LilyGO/LilyGo-T-RGB
  6. 3-wire SPI + 18bit RGB interface

Simplified example from Lilygo T-RGB library. Thank you

#include <TFT_eSPI.h>   //https://github.com/Bodmer/TFT_eSPI
#include <LilyGo_RGBPanel.h>

TFT_eSPI tft = TFT_eSPI();
TFT_eSprite spr = TFT_eSprite(&tft);
LilyGo_RGBPanel panel;
#define WIDTH  480 //panel.width()
#define HEIGHT 480 //panel.height()

void setup()
{
    Serial.begin(115200);
    if (!panel.begin(LILYGO_T_RGB_ORDER_BGR)) {
        while (1) {
            Serial.println("Error, failed to initialize T-RGB"); delay(1000);
        }
    }
    spr.createSprite(WIDTH, HEIGHT);
    spr.setColorDepth(4);
    panel.setBrightness(16);
    spr.fillSprite(TFT_WHITE);
    panel.pushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)spr.getPointer());
}
void loop()
{
}

YDzKYiAq-_k

@Polar-Axis
Copy link

Set the colour depth before creating the sprite to save memory.

Use the pushSprite function. pushColors always assumes data is 16 bit so 4 of the sprite 4bit pixels will be sent to each 16 bit panel pixel. This means only 1/4 of the pixels get filled.

pushSprite converts each 4 bit pixel into a 16 bit value and sends it to the screen. Note that a 4 bit sprite has a 16 color palette associated with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants