How to configure LVGL-9 for monochrome displays

Description

I would like to use LVGL with a 128x64 monochrome display (1 bit / pixel).

The documentation states that LVGL can be used with such displays, but
I didn’t find any in-tree example code. Via Google I found some existing examples
which set LV_COLOR_DEPTH to 1 for this. But this seems to be unsupported
with current LVGL-9.1.

As I use an embedded Linux system with tons of RAM, it wouldn’t be an issue
requiring more than 1 bit/pixel of RAM for buffers.

What MCU/Processor/Board and compiler are you using?

NXP i.MX6ULL

What LVGL version are you using?

Version 9.1

What do you want to achieve?

Using a monochrome display (ST7539 controller) with LVGL.

What have you tried so far?

  • Looking for existing projects using LVGL with monochrome displays (only found pre-9.0 stuff)
  • Setting LV_COLOR_DEPTH to 1 (results in compile errors, LV_COLOR_FORMAT_NATIVE undeclared)
  • Analyzed the GIT history of lv_conf_template.h (only found out that LV_COLOR_DEPTH 1 has been removed in f753265a799b (“arch(draw): add parallel rendering architecture”)
  • Analyzed the GIT history of docs/overview/colors.rst (only found out that LV_COLOR_DEPTH 1 has been removed in d5daccdd48f8 (“docs: update API comments”))

Small update:
Just noticed that in LVGL-9 there is also no set_px_cb() nor a rounder_cb() as mentioned in LittlevGL on a Monochrome OLED | LVGL’s Blog and Monochrome LCD tutorial

So it looks like I have to find out everything myself…

I haven’t tried using the lib on a monochrome display yet.
But version 9 does not yet support the monochrome standard according to the documentation.

https://docs.lvgl.io/master/porting/display.html#color-format

Have you tried using version 8?

If you intend to continue with version 9, perhaps you can change the way the framebuffer is sent to the display and convert the RGB to monochrome before sending it to the hardware.

Have a look at this function:

https://docs.lvgl.io/master/porting/display.html#flush-cb

This is my suggestion, I hope it helps you in some way. I’m still new to this library too

But version 9 does not yet support the monochrome standard according to the documentation.

Maybe the monochrome mode has been removed by intention? But for a library which states to support monochrome displays, the available examples could definitely be improved.

Have you tried using version 8?

I wasn’t aware of the fact that version 9 is more or less a complete rewrite. As a side effect, there are almost no working graphics drivers available (beside a hand full in the main repository). All drivers which I found in external repos (like lv_drivers or esp32) have been written for some older version (which one?) of LVGL.

I am starting a new development. Would it be future proof to start with an older version?

Have a look at this function:
Display interface — LVGL documentation

I already read somewhere that set_px_cb() should now be implemented within flush_cb(). But I am unsure how to convert px_data into monochrome (there used to be a lv_color_to1() method in older versions). The format of px_data seems to depend on the display`s color mode. But who is the stakeholder of this color mode?

  1. The application? → The display driver must be able to convert from any color mode into a supported one.
  2. The display driver (e.g. in lv_xxx_create()) → Usually no conversion is required in flush_cb (only for monochrome).

Another strange thing is, that px_data contains some non-zero data at the beginning of the buffer, although I didn’t create any widgets yet. Even if I create a single widget, only the first bytes of px_data seem to contain non-zero values.