LittlevGL with RA8875 on Teensy 4.0

Status
Not open for further replies.

skpang

Well-known member
I'm trying to use the LittlevGL library with RA8875 LCD on Teensy 4.0. The LCD is a 800x480 and the RA8875 library is from sumotoy v0.70b11p11

There is no LittlevGL port for the Teensy 4.0 so I've attempted my own but with partial success.

lvgl needs to copy the display buffer to the actual LCD. I've managed to get it to work by copying one pixel at a time but it is very slow.

This bit of code work:
Code:
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{ 

   int16_t x, y;

    for(y = area->y1; y <= area->y2; y++) {
        for(x = area->x1; x <= area->x2; x++) {
            display.drawPixels((uint16_t *)color_p, 1, x,y);
            color_p++;
        }
    }

  lv_disp_flush_ready(disp); /* tell lvgl that flushing is done */
  
}

display.drawPixels() should be able to take the whole buffer and draw it. So have update my code to:
Code:
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{ 

  uint16_t width = (area->x2 - area->x1 +1);
  uint16_t height = (area->y2 - area->y1+1);
   
  display.drawPixels((uint16_t *)color_p, (width * height)  , area->x1 , area->y1);

  lv_disp_flush_ready(disp); /* tell lvgl that flushing is done */
  
}

It is now drawing a lot faster but the text is slanted. It looks like something is off a few pixel and I can't figure out where.
IMG_5523.jpg

Is it something inside the function display.drawPixels() ? Anyone can help ?
 
I am not sure... If it were me, first step would be to use the RA8875 that a few of us modified.
I believe our most up to date is at with mjs513\RA8875 with the branch RA8875_t4
 
Now you might look through some of the functions we have added to speed things up...

Example: Look at the function writeRect, which you pass in x, y, w, h, and pointer to rectangle of pixels ...
It has helper functions drawPixels... Which can output a row of pixels. But warning is that how orientations work on RA8875, causes you to have to do screwy things, as it does not actually change the underlying memory addressing...

Note as far as I know drawPixels only works for one row at a time, gagin try looking at how writeRect works... Or just call writeRect.

There is also some sort of screwy helper functions like combineAndDrawPixels, which we use in some places like drawing GFX fonts, which you act like you are calling the draw pixel, but it caches as many together that have the same color in a row and then outputs them as one draw primitive, to speed things up.

Again not sure if that would help your stuff or not.
 
SOLVED !!

I've changed it to use writeRect instead:
Code:
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{ 

  uint16_t width = (area->x2 - area->x1 +1);
  uint16_t height = (area->y2 - area->y1+1);

  display.writeRect(area->x1, area->y1, width, height, (uint16_t *)color_p);

  lv_disp_flush_ready(disp); /* tell lvgl that flushing is done */
  
}

Now it displays correctly.
IMG_5525.jpg

Thank you KurtE for your help. I now can carry on and try to get the touch screen to work.
 
The SPI is quite slow. The driver won't go above 22MHz.

Check in the file RA8875UserSettings.h about line 190

const static uint32_t MAXSPISPEED = 22000000UL;

I'm sure the RA8875 can go above 22MHz but the driver won't.

On the ILI9488 I managed to run the SPI at 60MHz
 
Saw on another thread RA8876 running at 75 MHz - not sure how that relates to use with 8875.

Also make sure to update to TD 1.52 b4 - an SPI timing (error) was recently changed - not sure if prior code messes up the display as the speed increases?
 
Saw on another thread RA8876 running at 75 MHz - not sure how that relates to use with 8875.

Also make sure to update to TD 1.52 b4 - an SPI timing (error) was recently changed - not sure if prior code messes up the display as the speed increases?

Sumotoy had a comment in his user_settings for PSI timing that the limit is 23Mhz and this is based on discussion with RAIO:
After som mail exchange with RAiO I solved the dilemma behind SPI speed limit:
The RA8875 has limitation of 12Mhz SPI but this has been set because not all internal macros
can run over that speed, the library automatically deal with this so I was able to go over 20Mhz!
At that speed you need to short cables as much you can, provide clean supply and good decoupling!
DO NOT Exceed 23Mhz for RA8875! It will result in garbage on screen or run very slow.
 
Status
Not open for further replies.
Back
Top