Menu

ST7789 - GLCD driver

Anobium
2023-06-23
2023-06-27
  • Anobium

    Anobium - 2023-06-23

    New ST7789 GLCD library added

    I am posting this ... I had failed to do this in the past.

    This is an improved GLCD library. The ST7789 is medium sized LCD (therefore bright), over 2 inches wide and is fast to update.

    The ST7789 is a single-chip controller/driver for 262K-color, graphic type TFT-LCD. It consists of 720 source line and 320 gate line driving circuits.

    Display data can be stored in the on-chip display data RAM of 240x320x18 color bits.

    It can perform display data RAM read/write operation with no external operation clock to minimize power consumption.
    In addition, because of the integrated power supply circuit necessary to drive liquid crystal; it is possible to make a display system with the fewest components.

    The Great Cow BASIC constants shown below control the configuration of the ST7789 controller. Great Cow BASIC supports SPI and I2C software connectivity - this is shown in the tables below.

    The ST7789 library supports 240 * 240 pixels or 320 * 240 pixels. The library supports software SPI or hardware SPI.

    An example program is shown below - thank you Dan Goss.


    #chip LGT8F328P 
    #include <LGT8F328P.h>
    #option explicit
    
    #include <glcd.h>
    #include <glcd_st7789.h>
    #define ST7789_HardwareSPI
    #define HWSPIMode MASTERULTRAFAST
    
    // Can be either pixels geometry    
        #define GLCD_TYPE GLCD_TYPE_ST7789_240_240
        //#define GLCD_TYPE GLCD_TYPE_ST7789_320_240
    
    //Pin mappings for SPI - this GLCD driver supports Hardware SPI and Software SPI
    #define GLCD_DC       DIGITAL_8           ' Data command line
    #define GLCD_CS       DIGITAL_10          ' Chip select line
    #define GLCD_RESET    DIGITAL_9           ' Reset line
    #define GLCD_DI       DIGITAL_12          ' Data in | MISO    - Not used therefore not really required
    #define GLCD_DO       DIGITAL_11          ' Data out | MOSI
    #define GLCD_SCK      DIGITAL_13          ' Clock Line
    
    #define GLCD_EXTENDEDFONTSET1
    GLCDBackground = TFT_BLACK
    GLCDCLS TFT_BLACK
    
    GLCDfntDefaultsize = 2
    
    GLCDRotate Portrait_Rev
    GLCDPrint (0,0,"Hello World",TFT_GREEN)
    
    GLCDRotate Portrait
    GLCDPrint (0,0,"Hello World",TFT_GREEN)
    
    GLCDROTATE Landscape
    GLCDPrint (0,0,"Hello World",TFT_GREEN)
    
    GLCDROTATE Landscape_Rev
    GLCDPrint (0,0,"Hello World",TFT_GREEN)
    


    Attached are some photos of the ST7780 working - again, thank you Dan Goss

    Enjoy

     

    Last edit: Anobium 2023-06-23
  • Anobium

    Anobium - 2023-06-23

    The new GLCD ST7789 capability is available in build 1253 or any build after 1253.

     
  • Angel Mier

    Angel Mier - 2023-06-23

    Update is online.

     
    • Anobium

      Anobium - 2023-06-25

      Thank you!

       
  • stan cartwright

    stan cartwright - 2023-06-24

    Nice work. Interesting display, also available 240 * 135.
    Also with touch and sd card.
    Is miso / sdi implemented?

     

    Last edit: stan cartwright 2023-06-24
    • Anobium

      Anobium - 2023-06-25

      A nice little display. The 240x135 should work but the library may need a change to fully support the rotation of the display.

      MISO/SDI is implemented.

       
  • stan cartwright

    stan cartwright - 2023-06-26

    So read pixel should work. An alternative to ili9341. Is it better/faster?

     
    • Anobium

      Anobium - 2023-06-26

      Sorry, not sure. I have not tested the performance.

       
  • stan cartwright

    stan cartwright - 2023-06-26

    gcstudio include ... #define ST7789_DI GLCD_DI ;DI IS NOT USED within the library - presence for completeness

     
    • Anobium

      Anobium - 2023-06-26

      The read function may need to checked. I think Dan has the games working so maybe rheythey do work.

       
  • Dan Goss

    Dan Goss - 2023-06-27

    I do not know if the ST7789 is faster than the ili9341 but it is a very fast display. One thing I like about it is that it is an IPS display so the viewing angles are great. It doesn't fade when viewing from the side. Attached is the Invaders game demo modified for this display. It uses the GCB TFT colors.

     

    Last edit: Dan Goss 2023-06-27
  • Dan Goss

    Dan Goss - 2023-06-27

    Stan, it appears readpixel is not included in the library although the ST7789 is capable of doing so.

     
  • stan cartwright

    stan cartwright - 2023-06-27

    Anobium implemented ssd1306 pixel read x,y when I asked and I wrote a tron game but that was reading from a 1K buffer. He also added read pixel x,y to ili9341 where as it said miso not used before. (reset can be tied hi also and it works.. save a pin?)
    Is it only the st7789 with touch and sd card uses miso? Not a problem really but handy for some games or even a blit function.
    it looks a tidy display and depending where you buy from , cheap.

    invaders - #define GLCD_DI DIGITAL_12 ' Data in | MISO - Not used therefore not really required

     
  • stan cartwright

    stan cartwright - 2023-06-27

    Dan, I think the LGT8F328P is a great 8bit chip.

     
  • stan cartwright

    stan cartwright - 2023-06-27

    I asked on another forum if there's a difference and with spi.. no. The viewing angle is the display not the st7789. using 378MHz 32 bit. spi slows it

     
  • stan cartwright

    stan cartwright - 2023-06-27

    I asked on another forum if there's a difference and with spi.. no. The viewing angle is the display not the st7789. using 378MHz 32 bit. spi slows it

     

Log in to post a comment.