Description
Is there any custom drivers example or template available to customize 4bit grayscale oled?
What MCU/Processor/Board and compiler are you using?
What LVGL version are you using?
v9.2
What do you want to achieve?
Integrate 4bit grayscale display with lvgl either via fbdev from 24 to 4 bit conversation or directly via custom driver
What have you tried so far?
Tried converting 24 bit to 4bit for flush_cb custom code. But fonts and images are not clear on edges.
Code to reproduce
The code block(s) should be formatted like:
uint8_t color24ToGray4(uint8_t r,uint8_t g, uint8_t b)
{
uint8_t gray = (uint8_t)(0.299 * r + 0.587 * g + 0.114 * b);
uint8_t gray_4bit = (gray + 8) / 17; - this gives bolder font then normal
uint8_t gray_4bit1 = (uint8_t)(pow((double)gray / 255.0, 2.0) * 15); - this gives thinner then normal
return gray_4bit;
}
void applyDithering(uint8_t *frame, int x, int y, int width, int height, int error) {
if (x + 1 < width)
frame[(y * width) + (x + 1)] += error * 7 / 16;
if (x > 0 && y + 1 < height)
frame[((y + 1) * width) + (x - 1)] += error * 3 / 16;
if (y + 1 < height)
frame[((y + 1) * width) + x] += error * 5 / 16;
if (x + 1 < width && y + 1 < height)
frame[((y + 1) * width) + (x + 1)] += error * 1 / 16;
}
uint8_t gray_4bit = color24ToGray4(r,g,b);
int error = (gray_4bit * 17) - (r * 0.299 + g * 0.587 + b * 0.114);
applyDithering((uint8_t *)color_p, x, y, w, h, error);
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.