olikraus / u8g2

U8glib library for monochrome displays, version 2
Other
5.03k stars 1.04k forks source link

Increase speed for some SSD13xx controller #302

Closed olikraus closed 7 years ago

olikraus commented 7 years ago

The code looks like this:

    case U8X8_MSG_DISPLAY_DRAW_TILE:
      ...
      do
      {
    c = ((u8x8_tile_t *)arg_ptr)->cnt;
    ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;

    do
    {
      u8x8_cad_SendCmd(u8x8, 0x015 );   /* set column address */
      u8x8_cad_SendArg(u8x8, x );   /* start */
      u8x8_cad_SendArg(u8x8, x+1 ); /* end */

      u8x8_cad_SendCmd(u8x8, 0x075 );   /* set row address */
      u8x8_cad_SendArg(u8x8, y);
      u8x8_cad_SendArg(u8x8, y+7);
      u8x8_cad_SendCmd(u8x8, 0x05c );   /* write to ram */
      u8x8_cad_SendData(u8x8, 32, u8x8_ssd1322_8to32(u8x8, ptr));
      ptr += 8;
      x += 2;
      c--;
    } while( c > 0 );
    arg_int--;
      } while( arg_int > 0 );

It might be optimized to:

    case U8X8_MSG_DISPLAY_DRAW_TILE:
      ...
      u8x8_cad_SendCmd(u8x8, 0x075 );   /* set row address */      
      u8x8_cad_SendArg(u8x8, y);
      u8x8_cad_SendArg(u8x8, y+7);
      do
      {
    c = ((u8x8_tile_t *)arg_ptr)->cnt;
    ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;

    do
    {
      u8x8_cad_SendCmd(u8x8, 0x015 );   /* set column address */
      u8x8_cad_SendArg(u8x8, x );   /* start */
      u8x8_cad_SendArg(u8x8, x+1 ); /* end */

      u8x8_cad_SendCmd(u8x8, 0x05c );   /* write to ram */
      u8x8_cad_SendData(u8x8, 32, u8x8_ssd1322_8to32(u8x8, ptr));
      ptr += 8;
      x += 2;
      c--;
    } while( c > 0 );
    arg_int--;
      } while( arg_int > 0 );

check:

Rappalot commented 7 years ago

I am doing this on a ssd1322 256x64 display, and it works for me. About 25% speed increase, when the full screen buffer is transfered.

olikraus commented 7 years ago

ok, cool. Thanks for reporting. I probably need to do some further testing and check whether all parts of u8g2/u8x8 still work.

olikraus commented 7 years ago

FPS results:

  U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI       Uno 8MHz 16 Bit Clip=9.0 Box=10.7  @=2.0 Pix=3.0        issue 302 before optimization
  U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI       Uno 8MHz 16 Bit Clip=10.9 Box=13.5  @=2.0 Pix=3.2   issue 302 after optimization

  U8G2_SSD1327_SEEED_96X96_1_HW_I2C     Uno         Clip=1.2 Box=1.2  @=0.9 Pix=1.0     issue 302 before optimization
  U8G2_SSD1327_SEEED_96X96_1_HW_I2C     Uno         Clip=1.4 Box=1.4  @=1.0 Pix=1.2     issue 302 after optimization

  U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI       Uno         Clip=18.2 Box=25.1  @=4.0 Pix=6.7       issue 302 before optimization
  U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI       Uno         Clip=19.1 Box=28.3  @=4.1 Pix=7.2       issue 302 after optimization
olikraus commented 7 years ago

SSD1322/25/27 modified and tested. This can be closed.