Skip to content

software rotation with rgb_display #196

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

Closed
h-milz opened this issue Nov 26, 2024 · 15 comments
Closed

software rotation with rgb_display #196

h-milz opened this issue Nov 26, 2024 · 15 comments

Comments

@h-milz
Copy link

h-milz commented Nov 26, 2024

I'm using the Elecrow 5" HMI display and would like to use it in portrait mode. Default is landscape. Is software rotation supposed to work in 6391c16 with rgb_display? If I do

display.set_rotation(lv.DISPLAY_ROTATION._90)

the display does not get rotated but crippled like shown in the photo. (this is from the hello world / slider example from the git repo README).
IMG_20241126_145711

@kdschlosser
Copy link
Collaborator

That's an RGB display and you should clone the repo leaving it on the master branch and do not change to a different commit.

I just got the new RGB driver up and running.

@h-milz
Copy link
Author

h-milz commented Nov 26, 2024

Hi Kevin,

that was the commit that you suggested me to use yesterday. Couldn't know it was outdated so fast ;-)

Anyway, the compile throws this error:

/home/hm/local/lvgl_micropython/ext_mod/lcd_bus/esp32_src/rgb_bus_rotation.c:234:21: error: implicit declaration of function 'ets_mp_printf'; did you mean 'ets_printf'? [-Werror=implicit-function-declaration]
234 |                     ets_mp_printf(&mp_plat_print, "Uncaught exception in IRQ callback handler!\n");
|                     ^~~~~~~~~~~~~
|                     ets_printf
cc1: some warnings being treated as errors
...
ninja: build stopped: subcommand failed.
...

ets_printf doesn't work though, as expected:

/home/hm/local/lvgl_micropython/ext_mod/lcd_bus/esp32_src/rgb_bus_rotation.c:234:32: warning: passing argument 1 of 'ets_printf' from incompatible pointer type [-Wincompatible-pointer-types]
234 |                     ets_printf(&mp_plat_print, "Uncaught exception in IRQ callback handler!\n");
|                                ^~~~~~~~~~~~~~
|                                |
|                                const mp_print_t * {aka const struct _mp_print_t *}

@kdschlosser
Copy link
Collaborator

i just fixed it

@h-milz
Copy link
Author

h-milz commented Nov 26, 2024

Now it's

In file included from /home/hm/local/lvgl_micropython/ext_mod/lcd_bus/lcd_types.h:7,
from /home/hm/local/lvgl_micropython/ext_mod/lcd_bus/esp32_src/rgb_bus.c:6:
/home/hm/local/lvgl_micropython/ext_mod/lcd_bus/esp32_src/rgb_bus.c: In function 'rgb_del':
/home/hm/local/lvgl_micropython/lib/micropython/py/obj.h:102:39: warning: returning 'void *' from a function with return type 'mp_lcd_err_t' {aka 'int'} makes integer from pointer without a cast [-Wint-conversion]
102 | #define MP_OBJ_NEW_IMMEDIATE_OBJ(val) ((mp_obj_t)(((val) << 3) | 6))
|                                       ^
/home/hm/local/lvgl_micropython/lib/micropython/py/obj.h:886:23: note: in expansion of macro 'MP_OBJ_NEW_IMMEDIATE_OBJ'
886 | #define mp_const_none MP_OBJ_NEW_IMMEDIATE_OBJ(0)
|                       ^~~~~~~~~~~~~~~~~~~~~~~~
/home/hm/local/lvgl_micropython/ext_mod/lcd_bus/esp32_src/rgb_bus.c:282:20: note: in expansion of macro 'mp_const_none'
282 |             return mp_const_none;
|                    ^~~~~~~~~~~~~
/home/hm/local/lvgl_micropython/ext_mod/lcd_bus/esp32_src/rgb_bus.c: In function 'rgb_tx_color':
/home/hm/local/lvgl_micropython/ext_mod/lcd_bus/esp32_src/rgb_bus.c:527:34: error: 'mp_lcd_rgb_bus_obj_t' {aka 'struct _mp_lcd_rgb_bus_obj_t'} has no member named 'partial_copy'; did you mean 'partial_buf'?
527 |         rgb_bus_event_set(&self->partial_copy);
|                                  ^~~~~~~~~~~~
|                                  partial_buf

@h-milz
Copy link
Author

h-milz commented Nov 26, 2024

OK, fixing the assumed typo the build compiles but rotation doesn't appear to work. After restarting the script, the REPL freezes and the display only occasionally flashes.

Jst reflashed and re-ran my script without rotation. Same happens.

Interestingly, the framebuffers are now created in MEMORY_INTERNAL and without only 1/10 of the max size:

rgb_allocate_framebuffer(self, size=76800, caps=2056)
rgb_allocate_framebuffer(self, size=76800, caps=2056)
rgb_init(self, width=i, height=i, bpp=800, buffer_size=480, rgb565_byte_swap=16)
h_res=800
v_res=480
bits_per_pixel=16
rgb565_byte_swap=0
D (60032) lcd_panel.rgb: installed pm lock and hold the lock during the whole panel lifecycle
D (60032) lcd_panel.rgb: new rgb panel(0) @0x3fce4370, num_fbs=2, fb_size=768000, bb0 @0x0, bb1 @0x0, bb_size=0
D (60042) lcd_panel.rgb: fb[0] @0x3c260ac0
D (60052) lcd_panel.rgb: fb[1] @0x3c31c300
D (60052) lcd_panel.rgb: rgb panel(0) start, pclk=12000000Hz
rgb_bus_lock_init
rgb_bus_lock_init
rgb_bus_event_init
rgb_bus_event_init
rgb_bus_event_init
rgb_bus_lock_init
rgb_bus_copy_task - STARTED
rgb_bus_lock_acquire
rgb_bus_lock_acquire
rgb_bus_event_isset
rgb_bus_lock_acquire

Then the GT911 chip initializes and the system crashes.

@h-milz
Copy link
Author

h-milz commented Nov 27, 2024

Ah I See you fixed the compile error. It does compile now, but when I run the script with no predefined framebuffers, the system crashes again after

rgb_allocate_framebuffer(self, size=76800, caps=2056)
rgb_allocate_framebuffer(self, size=76800, caps=2056)
rgb_init(self, width=i, height=i, bpp=800, buffer_size=480, rgb565_byte_swap=16)
h_res=800
v_res=480
bits_per_pixel=16
rgb565_byte_swap=0
D (230802) lcd_panel.rgb: installed pm lock and hold the lock during the whole panel lifecycle
D (230802) lcd_panel.rgb: new rgb panel(0) @0x3fce4370, num_fbs=2, fb_size=768000, bb0 @0x0, bb1 @0x0, bb_size=0
D (230812) lcd_panel.rgb: fb[0] @0x3c260ac0
D (230822) lcd_panel.rgb: fb[1] @0x3c31c300
D (230822) lcd_panel.rgb: rgb panel(0) start, pclk=12000000Hz
rgb_bus_copy_task - STARTED

When I try to preallocate buffers in size WH2 (768000 byte) in SPIRAM, I get MemoryError: Not enough memory available (768000) again. Strange.

@kdschlosser
Copy link
Collaborator

delete your clone of the repo and clone it again. I actually just got the damned thing to actually work properly.

allocate 2 frame buffers that are int(width * height * 2 / 10) in size. Do not allocate them as DMA. If you can get both buffers to fit in internal memory great, and if not it will work in SPIRAM as well.

pass those to the RGB display driver. don't use rotate yet as I have not fully tested that portion of it. Going to be working on that later today. It is 1:45 AM where I am and it is time for me to get some rest. I will be up in 3-4 hours, possibly less.

@h-milz
Copy link
Author

h-milz commented Nov 27, 2024

Excellent, it now compiles cleanly and sort of works. Although I can't tell if what does not work is in any way related to your code. Supposed not.

The thing comes up and instead of displaying my keyboard and textarea, the entire display content flashes shortly and then degenerates to the first picture. The "H" in the top left corner is the first letter of the placeholder string. It seems that only the cursor area is being displayed. When I tap on the keyboard area, the display content is fully displayed albeit with the strange lines in the textarea. The strange lines disappear as soon as a character is typed in the corresponding text line. And the cursor is not visible which I believe should be the default.

The code is straightforward I suppose:

    kb_map = [ "Q", "W", "E", "R", "T", "Z", "U", "I", "O", "P", lv.SYMBOL.BACKSPACE, "\n",
               "A", "S", "D", "F", "G", "H", "J", "K", "L", lv.SYMBOL.NEW_LINE, "\n",
               "Y", "X", "C", "V", "B", "N", "M", ",", ".", ":", "!", "?", "\n",
               lv.SYMBOL.CLOSE, " ",  " ", " ", lv.SYMBOL.OK, ""
             ]
    kb_ctrlmap = [ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6,
                   4, 4, 4, 4, 4, 4, 4, 4, 4, 6,
                   4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                   2, 2, 6, 2, 2
                 ]                                       


    kb = lv.keyboard(scrn)
    kb.set_map(lv.keyboard.MODE.USER_1, kb_map, kb_ctrlmap);
    kb.set_mode(lv.keyboard.MODE.USER_1);

    ta = lv.textarea(scrn)
    ta.align(lv.ALIGN.TOP_MID, 0, 10)
    ta.set_size(lv.pct(90), 200)
    ta.set_style_bg_color(lv.color_hex(0xFFFFFF), 0)
    ta.set_style_text_color(lv.color_hex(0x000000), 0)
    ta.set_placeholder_text("Hello")
    ta.add_state(lv.STATE.FOCUSED)

    kb.set_textarea(ta)

IMG_20241127_120234

IMG_20241127_120216

But get some sleep first. :-)

1 similar comment
@h-milz
Copy link
Author

h-milz commented Nov 30, 2024

Excellent, it now compiles cleanly and sort of works. Although I can't tell if what does not work is in any way related to your code. Supposed not.

The thing comes up and instead of displaying my keyboard and textarea, the entire display content flashes shortly and then degenerates to the first picture. The "H" in the top left corner is the first letter of the placeholder string. It seems that only the cursor area is being displayed. When I tap on the keyboard area, the display content is fully displayed albeit with the strange lines in the textarea. The strange lines disappear as soon as a character is typed in the corresponding text line. And the cursor is not visible which I believe should be the default.

The code is straightforward I suppose:

    kb_map = [ "Q", "W", "E", "R", "T", "Z", "U", "I", "O", "P", lv.SYMBOL.BACKSPACE, "\n",
               "A", "S", "D", "F", "G", "H", "J", "K", "L", lv.SYMBOL.NEW_LINE, "\n",
               "Y", "X", "C", "V", "B", "N", "M", ",", ".", ":", "!", "?", "\n",
               lv.SYMBOL.CLOSE, " ",  " ", " ", lv.SYMBOL.OK, ""
             ]
    kb_ctrlmap = [ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6,
                   4, 4, 4, 4, 4, 4, 4, 4, 4, 6,
                   4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                   2, 2, 6, 2, 2
                 ]                                       


    kb = lv.keyboard(scrn)
    kb.set_map(lv.keyboard.MODE.USER_1, kb_map, kb_ctrlmap);
    kb.set_mode(lv.keyboard.MODE.USER_1);

    ta = lv.textarea(scrn)
    ta.align(lv.ALIGN.TOP_MID, 0, 10)
    ta.set_size(lv.pct(90), 200)
    ta.set_style_bg_color(lv.color_hex(0xFFFFFF), 0)
    ta.set_style_text_color(lv.color_hex(0x000000), 0)
    ta.set_placeholder_text("Hello")
    ta.add_state(lv.STATE.FOCUSED)

    kb.set_textarea(ta)

IMG_20241127_120234

IMG_20241127_120216

But get some sleep first. :-)

@h-milz h-milz closed this as completed Nov 30, 2024
@h-milz
Copy link
Author

h-milz commented Nov 30, 2024

This has been resolved with the latest commits. Kudos to Kevin and Thomas.

@kdschlosser
Copy link
Collaborator

@h-milz

How's the performance for you. Is it pretty good?

@h-milz
Copy link
Author

h-milz commented Nov 30, 2024

@kdschlosser can't complain but then I have no moving widgets, just a keyboard and a textarea (it's going to be a scientific calculator after all). Maybe this will be different if I do certain things in the Wolfram cloud (symbolic integration) and display the returned images, don't know. When the screen bg_color is bright, like white, I sometimes see a faint flickering from top to bottom in landscape mode but I assume it's a hardware issue because. In _90 with pclk = 12 MHz and a dark theme I cannot see it right now.

@kdschlosser
Copy link
Collaborator

if you are getting a flicker when the display is idle with nothing on the display changing then it is going to be a limitation of the hardware and outside of my control. when nothing is being updated in LVGL the same frame buffer is getting sent over and over again and that is controlled by the ESP32 SDK and the hardware.

@kdschlosser
Copy link
Collaborator

what you can do is overclock the psram and flash spi bus to get some more speed out of it. we can try to do that for ya if you want.. let me know if you are interested in trying to do that.

@h-milz
Copy link
Author

h-milz commented Dec 1, 2024

Thank you but don't bother for the moment. The current laggyness I encounter is probably more due to the keyboard and textarea handling and not related.

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