Menu

ST7735 graphics controller

Help
MBB
2018-12-15
2019-09-03
  • MBB

    MBB - 2018-12-15

    I'm trying to use a 1.8" TFT display that uses the ST7735 and it appears to be working but I cannot figure out how to 'calculate' what numbers to put in to create the other 262k color shades that are available.

    In the ST7735 data sheet starting on page 38 are Data Color Coding tables and starting on page 73 are Color Depth Conversion Look Up Tables. Apparently, you are supposed to use these to derive the different color shades.

    How do you decipher these tables?

    In the GCB Help file it says:
    ST7735_BLACK 'hexidecimal value 0x0000
    ST7735_BLUE 'hexidecimal value 0xF800
    ST7735_RED 'hexidecimal value 0x001F
    ST7735_GREEN 'hexidecimal value 0x07E0
    ST7735_CYAN 'hexidecimal value 0xFFE0
    ST7735_MAGENTA 'hexidecimal value 0xF81F
    ST7735_YELLOW 'hexidecimal value 0x07FF
    ST7735_WHITE 'hexidecimal value 0xFFFF

    How did you come up with these numbers for each color?

     
    • Anobium

      Anobium - 2018-12-16

      What a great question.

      Well the values are bit inversion of the RGB-565 colors. Where a 16-bit value is essentially bit flipped, so, RGB 565 RED is 0xF800 > 0b1111 1000 > flipped = 0b0001 1111 > 0x01F

      Why? Deep inside the datasheet at 10.1.26 MADCTL (36h): Memory Data Access Control the value we send is 0xC8 this set the direction of screen data write and the COLOR handling at bit D3. As we set the write direction and color handling as BGR565.

      There are many articles on BGR565 color formats.

      This makes sense as an explanation but this does not make sense in the context of the 'norm'. This driver was a very early driver. I can tell this because the driver identification #2. So, my first attempt at a GLCD driver.

      However, if you compare these color definitions to the latest norm (the later GLCD drivers) where I clearly use RGB565, the TFT colors can be found in GLCD.h. Where TFT_RED is 0xF800 and therefore RGB565.

      So, try this. https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/glcd_ST7735.h?format=raw

      I have revised to RGB use TFT colors. I also updated GLCDCLS to be a lot faster and updated GLCDRotate to support bits not constants.

      This now exposes the following plus you can now pass any RGB565 color code.

      ' Define Colors

      #define TFT_BLACK       0x0000
      #define TFT_NAVY        0x000F
      #define TFT_DARKGREEN   0x03E0
      #define TFT_DARKCYAN    0x03EF
      #define TFT_MAROON      0x7800
      #define TFT_PURPLE      0x780F
      #define TFT_OLIVE       0x7BE0
      #define TFT_LIGHTGREY   0xC618
      #define TFT_DARKGREY    0x7BEF
      #define TFT_BLUE        0x001F
      #define TFT_GREEN       0x07E0
      #define TFT_CYAN        0x07FF
      #define TFT_RED         0xF800
      #define TFT_MAGENTA     0xF81F
      #define TFT_YELLOW      0xFFE0
      #define TFT_WHITE       0xFFFF
      #define TFT_ORANGE      0xFD20
      #define TFT_GREENYELLOW 0xAFE5
      #define TFT_PINK        0xF81F
      

      Summary

      I have updated the library to support TFT RGB-565 colors.

       

      Last edit: Anobium 2018-12-16
      • Anobium

        Anobium - 2018-12-16

        My test program is attached.

         
  • Anobium

    Anobium - 2018-12-16
     
  • MBB

    MBB - 2018-12-16

    That was a great explanation.

    Thanks!

     
    • Anobium

      Anobium - 2018-12-16

      Pleasure.

      So, update your install with the revised .h file and all should be good.

       
  • sfyris

    sfyris - 2019-08-28

    Trying to load the demonstration I get this error message

     
  • Anobium

    Anobium - 2019-08-29

    Yes, that happens.

    Can you use the Textual based IDE. This will work for you.

     
  • sfyris

    sfyris - 2019-08-29

    yes it worked but it would be more comfort to me if its possible to make it directly from GCG

     
    • Anobium

      Anobium - 2019-08-29

      Yes. I understand.

      Let me look into the root cause of the issue.

      Meanwhile, use the IDE.

      :=)

       
  • sfyris

    sfyris - 2019-09-03

    ok I tested it on my adafruit with a 16f887 pic and it worked. But why is its drawing so slow? is that normal?

     
  • Anobium

    Anobium - 2019-09-03

    887.... what frequency?

     
  • sfyris

    sfyris - 2019-09-03

    8MHz, the internal osc

     
    • Anobium

      Anobium - 2019-09-03

      A little slow for a color GLCD. Try an 18f at 64mhz

       

Log in to post a comment.