Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 11 of 11

Thread: LittlevGL with RA8875 on Teensy 4.0

  1. #1
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    122

    LittlevGL with RA8875 on Teensy 4.0

    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.
    Click image for larger version. 

Name:	IMG_5523.jpg 
Views:	13 
Size:	204.9 KB 
ID:	19718

    Is it something inside the function display.drawPixels() ? Anyone can help ?

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    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

  3. #3
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    122
    Ok, I've deleted the original RA8875 library and install this one:

    https://github.com/mjs513/RA8875/tree/RA8875_t4

    but still the same problem. I think something is not right with drawPixels() or I'm not calling it correctly.

  4. #4
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    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.

  5. #5
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    122
    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.
    Click image for larger version. 

Name:	IMG_5525.jpg 
Views:	15 
Size:	119.8 KB 
ID:	19719

    Thank you KurtE for your help. I now can carry on and try to get the touch screen to work.

  6. #6
    Please, if you can, share the code
    Thank you in advance

  7. #7
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    122
    The Button and Label test code are at:

    https://github.com/skpang/Teensy40_L..._RA8875_button

    Ensure you have installed these library first:
    https://github.com/mjs513/RA8875/tree/RA8875_t4
    https://github.com/littlevgl/lv_arduino

    The touch screen still need work.

  8. #8
    Hi
    First, Thank you very much for the code, after adding touch screen, and making simple test, i find out it's working very slow, it's slower then even ESP32.
    Please, if you can, check out the example file, and see, if you can make it faster.

    https://github.com/momosh13/Teensy40...GL_RA8875_test

  9. #9
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    122
    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

  10. #10
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,490
    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?

  11. #11
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,099
    Quote Originally Posted by defragster View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •