IniterWorker / gc9a01

GC9A01 Display Driver
Apache License 2.0
14 stars 6 forks source link

Using with slint #5

Open rsov opened 1 month ago

rsov commented 1 month ago

Hello, great library!

I am trying to use it with slint on esp32-s3 and I am getting Exception occured 'LoadProhibited' error

The funny thing is, my equivalent implementation of https://github.com/slint-ui/slint/blob/cadfd9e1041214021a375795df9ef96e45d14999/examples/mcu-board-support/esp32_s3_box.rs#L219 is

display.clear();
display.flush().unwrap();

Do you have any ideas why this is happening?

If not, would it be worth while implementing set_pixels method in this driver like it is implemented in this one? https://github.com/almindor/st7789/blob/e18dc571c1e2adb56bf9c6511887845b852f69c6/src/lib.rs#L236

Thank you!

IniterWorker commented 1 month ago

Please provide more information:

Please do not provide external exceptions such as:

Exception occurred 'LoadProhibited'

At the library level, we cannot support issues caused by other libraries.

What are the requirements for set_pixels when set_pixel is already available with the buffered approach?

https://github.com/IniterWorker/gc9a01/blob/6b3ddc81c68e61b495825ab46a58a33a37bba1e9/src/mode/graphics.rs#L164

rsov commented 1 month ago

I think the key difference between set_pixel is that it changes data in the buffer, while set_pixels writes it straight to the device, line by line

Will try to submit minimal reproduceable example soon

rsov commented 1 month ago

In progress of stripping down everything, the exception went away but it's not displaying correctly

Here is what is expected: image

Here is what I get: Note the little line at the edge changes when background color is changed image

Branch with code: https://github.com/rsov/rusty_bucket_face/blob/feature/slint/src/main.rs

I have tried changing rotation and replacing the example fill_contiguous code that yielded same results

for (i, pixel_color) in buffer.iter().enumerate() {
  self.display.set_pixel(i as _, line as _, pixel_color.0);
}

It almost feels like it's either rendering the very last bit or one of the axis is flipped

Any help with this is appreciated

IniterWorker commented 1 month ago

@rsov did you/could you display a basic rectangle with embedded_graphics via https://github.com/IniterWorker/esp32-s3-touch-lcd-1-28/blob/d02db8cf16075181fba171390b3d3251ff3f2383/src/main.rs#L34 ?

1) Try to use the driver standalone, first to validate your setup. 2) Did you check for memory issues, stack/heap issue with double/triple allocation (slint + gc9a01 Buffered) of the 240*240*size_of(pixel_color) ?

rsov commented 1 month ago

Yes the example code worked well with direct draw calls

Sorry, I am out of my depth when it comes to embedded environments and rust. What would be some good keywords to search for to get started?

rsov commented 1 month ago

You may have been on the right track with the double buffering issue

I have forked and added a method to send buffer data directly. It works... but the colors are all wrong and it lost the sharpness. Will see if it's possible to improve it further

https://github.com/rsov/gc9a01/blob/7f5a94657cf327b9a23a1a80a28fe015edc09cdd/src/driver.rs#L287

and i send data to it this way

self.display
        .send_line(&buffer.iter().map(|&x| x.0).collect::<Vec<u16>>())
        .unwrap();

image

IniterWorker commented 1 month ago

Please always provide an example. Mainly a color shift from your end with map(|&x| x.0). But, I can't help you without more source.

EDIT

// Pure speculation
use embedded_graphics_core::pixelcolor::raw::RawU16;

self.display
        .send_line(&buffer.iter().map(|&x| RawU16::new(x.0).into()).collect::<Vec<RawU16>>())
        .unwrap();