Display_Lib_RPI 2.5.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
GC9D01_TFT Class Reference

Class to control GC9D01 TFT basic functionality. More...

#include <GC9D01_TFT_LCD_RDL.hpp>

Inheritance diagram for GC9D01_TFT:
Inheritance graph
[legend]

Classes

struct  MADCTL_FLAGS_t
 MADCTL bit flags for register GC9D01_MADCTL (0x36). More...
 

Public Types

enum class  PowerState_e : uint8_t {
  NormalIdleOff , NormalIdleOn , PartialIdleOff , PartialIdleOn ,
  SleepNormalIdleOff , SleepNormalIdleOn , SleepPartialIdleOff , SleepPartialIdleOn
}
 GC9D01 power states based on the power control flow chart. These states combine the modes: Normal/Partial, Idle ON/OFF, and Sleep IN/OUT. They are listed from highest to lowest power consumption. Power states are based on the power control flow chart in the datasheet. FIG 89 5.10.2. Power Flow Chart. More...
 
enum class  Resolution_e : uint8_t { RGB160x160_DualGate , RGB120x160_DualGate , RGB80x160_SingleGate , RGB40x160_SingleGate }
 GC9D01 panel resolution and gate configuration. More...
 
- Public Types inherited from color16_graphics
enum class  AdvancedScreenBuffer_e : uint8_t { Off = 0 , On = 1 }
 enum to define buffer mode: on or off Default is off, commented OUT , tested in file examples/st7735/advanced_screen_buffer_mode More...
 
enum  pixel_color565_e : uint16_t {
  RDLC_BLACK = 0x0000 , RDLC_BLUE = 0x001F , RDLC_RED = 0xF800 , RDLC_GREEN = 0x07E0 ,
  RDLC_CYAN = 0x07FF , RDLC_MAGENTA = 0xF81F , RDLC_YELLOW = 0xFFE0 , RDLC_WHITE = 0xFFFF ,
  RDLC_TAN = 0xED01 , RDLC_GREY = 0x9CD1 , RDLC_BROWN = 0x6201 , RDLC_DGREEN = 0x01C0 ,
  RDLC_ORANGE = 0xFC00 , RDLC_NAVY = 0x000F , RDLC_DCYAN = 0x03EF , RDLC_MAROON = 0x7800 ,
  RDLC_PURPLE = 0x780F , RDLC_OLIVE = 0x7BE0 , RDLC_LGREY = 0xC618 , RDLC_DGREY = 0x7BEF ,
  RDLC_GYELLOW = 0xAFE5 , RDLC_PINK = 0xFC18 , RDLC_LBLUE = 0x7E5F , RDLC_BEIGE = 0xB5D2
}
 16-bit color definitions (RGB565 format). More...
 
enum  display_rotate_e : uint8_t { Degrees_0 = 0 , Degrees_90 , Degrees_180 , Degrees_270 }
 
- Public Types inherited from Print
enum  BaseNum : uint8_t { RDL_DEC = 10 , RDL_HEX = 16 , RDL_OCT = 8 , RDL_BIN = 2 }
 

Public Member Functions

 GC9D01_TFT ()
 Constructor for class GC9D01_TFT.
 
virtual void setAddrWindow (uint16_t, uint16_t, uint16_t, uint16_t) override
 SPI displays set an address window rectangle for blitting pixels.
 
void TFTSetupGPIO (int8_t, int8_t, int8_t, int8_t, int8_t)
 sets up TFT GPIO for software SPI
 
void TFTSetupGPIO (int8_t, int8_t)
 sets up TFT GPIO for Hardware SPi
 
void TFTInitScreenSize (uint16_t w=160, uint16_t h=160, Resolution_e r=Resolution_e::RGB160x160_DualGate, uint16_t Xstart=0, uint16_t Ystart=0)
 initialise the variables that define the size of the screen
 
rdlib::Return_Codes_e TFTInitSPI (uint16_t CommDelay, int gpioDev)
 intialise PCBtype and SPI, Software SPI
 
rdlib::Return_Codes_e TFTInitSPI (int device, int channel, int speed, int flags, int gpioDev)
 intialise SPI, Hardware SPI
 
rdlib::Return_Codes_e TFTPowerDown (void)
 Call when powering down TFT.
 
uint16_t HighFreqDelayGet (void)
 Freq delay used in SW SPI getter, uS delay used in SW SPI method.
 
void HighFreqDelaySet (uint16_t)
 Freq delay used in SW SPI setter, uS delay used in SW SPI method.
 
rdlib::Return_Codes_e TFTResetPin (void)
 Method for Hardware Reset pin control.
 
void TFTsetRotation (display_rotate_e r)
 : change rotation of display.
 
void TFTchangeInvertMode (bool m)
 Toggle the invert mode.
 
void TFTsetPowerMode (PowerState_e m)
 Set the power mode of the display.
 
void TFTenableDisplay (bool m)
 enable /disable display mode
 
void TFTsetBrightness (uint8_t level)
 Set display brightness (0–255).
 
void TFTsetScrollArea (uint16_t topFixed, uint16_t scrollArea, uint16_t bottomFixed)
 This method defines the Vertical Scrolling Area of the display where:
 
void TFTsetScrollStart (uint16_t vsp)
 This method is used together with the setScrollDefinition.
 
void TFTScrollModeLeave (void)
 Scroll Mode can be left ,by the Normal Display Mode ON cmd.
 
- Public Member Functions inherited from color16_graphics
 color16_graphics ()
 Construct a new graphics class object.
 
rdlib::Return_Codes_e setBuffer (void)
 Allocates memory for the screen buffer based on display resolution. The buffer size is calculated as width × height × 2 bytes (RGB565 format). If allocation fails, it returns a memory allocation error. In debug mode, it prints the allocated buffer size.
 
rdlib::Return_Codes_e clearBuffer (uint16_t color=RDLC_BLACK)
 Clears the screen buffer by filling it with a given color. The buffer is filled in RGB565 format. This function assumes the buffer has already been allocated via setBuffer().
 
rdlib::Return_Codes_e writeBuffer (void)
 Writes the contents of the screen buffer to the display. This function assumes the buffer has already been allocated and filled. It sets the address window for the entire screen and writes the buffer data.
 
rdlib::Return_Codes_e destroyBuffer (void)
 Destroys the screen buffer by resizing it to zero. This function checks if the buffer has been successfully destroyed and prints debug information.
 
void fillScreen (uint16_t color)
 Fills the whole screen with a given color.
 
void setCursor (int16_t x, int16_t y)
 Set the Cursor Position on screen.
 
void setAdvancedScreenBuffer_e (AdvancedScreenBuffer_e mode)
 setter for Advanced Screen Buffer mode
 
AdvancedScreenBuffer_e getAdvancedScreenBuffer_e () const
 getter for Advanced Screen Buffer mode
 
void drawPixel (uint16_t, uint16_t, uint16_t)
 Draw a pixel to screen.
 
rdlib::Return_Codes_e drawDotGrid (int16_t x, int16_t y, int16_t w, int16_t h, uint8_t DotGridGap, uint16_t color)
 Draws a grid of dots on the screen starting from the given coordinates. This function draws a grid of pixels with a specified gap between them. It checks that the provided coordinates and dimensions are within the screen bounds and adjusts them if necessary. It also validates The grid of dots gap value and defaults it to 2 if invalid.
 
void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 draws a line from (x0,y0) to (x1,y1).
 
rdlib::Return_Codes_e drawFastVLine (uint16_t x, uint16_t y, uint16_t h, uint16_t color)
 Draws a vertical line starting at (x,y) with height h.
 
rdlib::Return_Codes_e drawFastHLine (uint16_t x, uint16_t y, uint16_t w, uint16_t color)
 Draws a horizontal line starting at (x,y) with width w.
 
void drawLineAngle (int16_t x, int16_t y, int angle, uint8_t start, uint8_t length, int offset, uint16_t color)
 Draws a line using an angle and length as parameters. This function draws a line starting from (x, y), extending in the direction specified by angle, with a given length. The function also allows applying an offset to the angle before computing the line’s end coordinates.
 
void drawRectWH (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
 draws rectangle at (x,y) where h is height and w is width of the rectangle.
 
rdlib::Return_Codes_e fillRectangle (uint16_t, uint16_t, uint16_t, uint16_t, uint16_t)
 fills a rectangle starting from coordinates (x,y) with width of w and height of h.
 
void fillRect (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
 fills a rectangle at (x,y) where h is height and w is width of the rectangle.
 
void drawRoundRect (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t r, uint16_t color)
 draws a rectangle with rounded edges
 
void fillRoundRect (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t r, uint16_t color)
 Fills a rectangle with rounded edges.
 
void drawCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 draws a circle where (x0,y0) are center coordinates an r is circle radius.
 
void fillCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 fills a circle where (x0,y0) are center coordinates an r is circle radius.
 
void drawEllipse (int16_t cx, int16_t cy, int16_t semiMajorAxis, int16_t semiMinorAxis, bool fill, uint16_t color)
 Draw an ellipse on the display. This function uses the midpoint ellipse algorithm to efficiently draw an ellipse centered at (cx, cy) with the given semi-major (horizontal) and semi-minor (vertical) axes.
 
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 draws a triangle of coordinates (x0,y0), (x1,y1) and (x2,y2).
 
void fillTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 Fills a triangle of coordinates (x0,y0), (x1,y1) and (x2,y2).
 
void drawQuadrilateral (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3, uint16_t color)
 Draws a quadrilateral (four-sided polygon) by connecting four points with lines. This function draws a quadrilateral by drawing four lines between the given vertices. The lines are drawn in the order: (x0, y0) to (x1, y1), (x1, y1) to (x2, y2), (x2, y2) to (x3, y3), and finally (x3, y3) back to (x0, y0).
 
void fillQuadrilateral (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3, uint16_t color)
 Fills a quadrilateral with the specified color using triangles. This function fills a quadrilateral by dividing it into triangles and filling them individually. The quadrilateral is filled by calling the fillTriangle function three times with appropriate vertex coordinates. The useTriangleSplit parameter determines whether the quadrilateral is divided into two triangles or if only one triangle is used.
 
rdlib::Return_Codes_e drawPolygon (int16_t x, int16_t y, uint8_t sides, int16_t diameter, float rotation, bool fill, uint16_t color)
 Draws a polygon with a specified number of sides, diameter, rotation, and color. This function draws a regular polygon by connecting points equally spaced around a circle, with each point having a distance defined by the diameter. The polygon is rotated by the given angle (in degrees) before being drawn. The number of sides is enforced to be at least 3.
 
void drawSimpleArc (int16_t cx, int16_t cy, int16_t radius, float startAngle, float endAngle, uint16_t color)
 Draw a simple arc of one pixel on the display( no offsets , thickness or maximum arc calculations) This function draws an arc between two angles (start and end) on a circle with a given radius.
 
void drawArc (uint16_t cx, uint16_t cy, uint16_t radius, uint16_t thickness, float startAngle, float endAngle, uint16_t color)
 Draw an arc on the TFT display. This function draws an arc between two angles (start and end) on a circle with a given radius.
 
float getArcAngleMax () const
 Get the current maximum angle of the arc.
 
void setArcAngleMax (float arcAngleMax)
 Set a new maximum angle for the arc.
 
int getArcAngleOffset () const
 Get the current angle offset.
 
void setArcAngleOffset (int arcAngleOffset)
 Set a new angle offset.
 
virtual size_t write (uint8_t) override
 write method used in the print class when user calls print
 
rdlib::Return_Codes_e writeChar (int16_t x, int16_t y, char value)
 Write 1 character on Display.
 
rdlib::Return_Codes_e writeCharString (int16_t x, int16_t y, char *text)
 Write Text character array on display.
 
void setTextWrap (bool w)
 turn on or off screen wrap of the text (fonts 1-6)
 
void setTextColor (uint16_t c, uint16_t bg)
 Set text color foreground and background.
 
void setTextColor (uint16_t c)
 Set text color foreground.
 
void setTextCharPixelOrBuffer (bool mode)
 Set the text rendering mode to either buffered or pixel-by-pixel.
 
bool getTextCharPixelOrBuffer () const
 Get the current text rendering mode.
 
rdlib::Return_Codes_e drawIcon (uint16_t x, uint16_t y, uint16_t w, uint16_t color, uint16_t bgcolor, const std::span< const uint8_t > data)
 Draws an custom Icon of X by 8 size to screen , where X = 0 to 127.
 
rdlib::Return_Codes_e drawBitmap (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color, uint16_t bgcolor, const std::span< const uint8_t > data)
 : Draws an bi-color bitmap to screen
 
rdlib::Return_Codes_e drawBitmap24 (uint16_t x, uint16_t y, const std::span< const uint8_t > data, uint16_t w, uint16_t h)
 Draws an 24 bit color bitmap to screen from a data array.
 
rdlib::Return_Codes_e drawBitmap16 (uint16_t x, uint16_t y, const std::span< const uint8_t > data, uint16_t w, uint16_t h)
 : Draws an 16 bit color bitmap to screen from a data array
 
rdlib::Return_Codes_e drawSprite (uint16_t x, uint16_t y, const std::span< const uint8_t > data, uint16_t w, uint16_t h, uint16_t backgroundColor, bool printBg=false)
 : Draws an 16 bit color sprite bitmap to screen with transparent background
 
uint16_t Color565 (int16_t, int16_t, int16_t)
 : Convert: 24-bit color to 565 16-bit color
 
int getDisplaySPIBlockSize () const
 Gets the maximum SPI transaction block size.
 
void setDisplaySPIBlockSize (int size)
 Sets the maximum SPI transaction block size.
 
- Public Member Functions inherited from display_Fonts
 display_Fonts ()
 init the OLED font class object constructor
 
rdlib::Return_Codes_e setFont (display_Font_name_e)
 SetFont.
 
void setInvertFont (bool invertStatus)
 setInvertFont
 
bool getInvertFont (void)
 getInvertFont
 
- Public Member Functions inherited from Print
int getWriteError ()
 gets the error flag status, zero no error
 
void clearWriteError ()
 clears the error flag by setting it to zero
 
virtual size_t write (const uint8_t *buffer, size_t size)
 define in the sub class
 
size_t write (const char *str)
 Writes a string to the output.
 
size_t write (const char *buffer, size_t size)
 Writes a buffer of a specified size to the output.
 
virtual int availableForWrite ()
 define in the sub class
 
size_t print (const char[])
 print an array
 
size_t print (char)
 print an character
 
size_t print (int, int=RDL_DEC)
 print an integer of base number system
 
size_t print (unsigned int, int=RDL_DEC)
 print an unsigned integer of base number system
 
size_t print (long, int=RDL_DEC)
 print an long integer of base number system
 
size_t print (unsigned long, int=RDL_DEC)
 print an unsigned long integer of base number system
 
size_t print (double, int=2)
 print an double
 
size_t print (const std::string &)
 print an C++ string object
 
size_t println (const char[])
 Prints a character array followed by a newline.
 
size_t println (char)
 print an character followed by new line
 
size_t println (int, int=RDL_DEC)
 print an integer of base number system followed by new line
 
size_t println (unsigned int, int=RDL_DEC)
 print an unsigned integer of base number system followed by new line
 
size_t println (long, int=RDL_DEC)
 print an long integer of base number system followed by new line
 
size_t println (unsigned long, int=RDL_DEC)
 print an unsigned long integer of base number system followed by new line
 
size_t println (double, int=2)
 print an double
 
size_t println (void)
 Goto to new line.
 
size_t println (const std::string &s)
 print an C++ string object followed by new line
 
template<typename T >
size_t print (const std::vector< T > &v, int format=defaultFormat< T >())
 Print a vector of any type.
 
template<typename T >
size_t println (const std::vector< T > &vec, int format=defaultFormat< T >())
 Print a vector of elements followed by a newline.
 
template<typename T , size_t N>
size_t print (const std::array< T, N > &arr, int format=defaultFormat< T >())
 Print a std::array of any type.
 
template<typename T , size_t N>
size_t println (const std::array< T, N > &arr, int format=defaultFormat< T >())
 Print a std::array of elements followed by a newline.
 

Public Attributes

display_rotate_e displayRotate = Degrees_0
 

Private Member Functions

rdlib::Return_Codes_e TFTDataCommandPin (void)
 : Method for Data or Command pin setup
 
rdlib::Return_Codes_e TFTClock_Data_ChipSelect_Pins (void)
 : Method for Clock, data and chip select pin setup routine for software SPI.
 
void TFTSetupResetPin (int8_t rst)
 sets up TFT GPIO reset pin
 
rdlib::Return_Codes_e TFTGC9D01Initialize (void)
 init routine for GC9D01 controller
 
void DualGatecmdInitSequence (void)
 GC9D01 init command sequence for Dual Gate variant Dual Gate variants include 160x160 and 120x160 resolutions.
 
void SingleGatecmdInitSequence (void)
 GC9D01 init command sequence for Single Gate variant Single Gate variants include 80x160 and 40x160 resolutions.
 

Private Attributes

PowerState_e _currentPowerState = PowerState_e::NormalIdleOff
 
Resolution_e _currentResolution = Resolution_e::RGB160x160_DualGate
 
bool _displayOn = false
 
const uint16_t _sleepDelay = 120
 
uint16_t _widthStartTFT = 160
 
uint16_t _heightStartTFT = 160
 
uint16_t _GC9D01_X_Offset_Start = 0
 
uint16_t _GC9D01_Y_Offset_Start = 0
 
uint16_t _GC9D01_X_Offset = 0
 
uint16_t _GC9D01_Y_Offset = 0
 
int _spiDev = 0
 
int _spiChan = 0
 
int _spiBaud = 50000
 
int _spiFlags = 0
 
bool _resetPinOn = true
 

Static Private Attributes

static constexpr uint8_t GC9D01_SWRESET = 0x01
 
static constexpr uint8_t GC9D01_RDDID = 0x04
 
static constexpr uint8_t GC9D01_RDDST = 0x09
 
static constexpr uint8_t GC9D01_SLPIN = 0x10
 
static constexpr uint8_t GC9D01_SLPOUT = 0x11
 
static constexpr uint8_t GC9D01_PTLON = 0x12
 
static constexpr uint8_t GC9D01_NORON = 0x13
 
static constexpr uint8_t GC9D01_DISPOFF = 0x28
 
static constexpr uint8_t GC9D01_DISPON = 0x29
 
static constexpr uint8_t GC9D01_IDLEOFF = 0x38
 
static constexpr uint8_t GC9D01_IDLEON = 0x39
 
static constexpr uint8_t GC9D01_INVOFF = 0x20
 
static constexpr uint8_t GC9D01_INVON = 0x21
 
static constexpr uint8_t GC9D01_CASET = 0x2A
 
static constexpr uint8_t GC9D01_RASET = 0x2B
 
static constexpr uint8_t GC9D01_RAMWR = 0x2C
 
static constexpr uint8_t GC9D01_PTLAR = 0x30
 
static constexpr uint8_t GC9D01_VSCRDEF = 0x33
 
static constexpr uint8_t GC9D01_TEOFF = 0x34
 
static constexpr uint8_t GC9D01_TEON = 0x35
 
static constexpr uint8_t GC9D01_MADCTL = 0x36
 
static constexpr uint8_t GC9D01_VSCRSADD = 0x37
 
static constexpr uint8_t GC9D01_COLMOD = 0x3A
 
static constexpr uint8_t GC9D01_CONTINUE = 0x3C
 
static constexpr uint8_t GC9D01_TEARSET = 0x44
 
static constexpr uint8_t GC9D01_GETLINE = 0x45
 
static constexpr uint8_t GC9D01_SETBRIGHT = 0x51
 
static constexpr uint8_t GC9D01_SETCTRL = 0x53
 
static constexpr uint8_t GC9D01_RGB_CTRL = 0xB0
 
static constexpr uint8_t GC9D01_TEWC = 0xB4
 
static constexpr uint8_t GC9D01_BLANK_PORCH_CTRL = 0xB5
 
static constexpr uint8_t GC9D01_FUNCTION_CTRL = 0xB6
 
static constexpr uint8_t GC9D01_DUAL_SINGLE = 0xBF
 
static constexpr uint8_t GC9D01_POWER_CTRL = 0xC1
 
static constexpr uint8_t GC9D01_VREG1A_CTRL = 0xC3
 
static constexpr uint8_t GC9D01_VREG1B_CTRL = 0xC4
 
static constexpr uint8_t GC9D01_VREG2A_CTRL = 0xC9
 
static constexpr uint8_t GC9D01_RDID1 = 0xDA
 
static constexpr uint8_t GC9D01_RDID2 = 0xDB
 
static constexpr uint8_t GC9D01_RDID3 = 0xDC
 
static constexpr uint8_t GC9D01_GAMMA1 = 0xF0
 
static constexpr uint8_t GC9D01_GAMMA2 = 0xF1
 
static constexpr uint8_t GC9D01_GAMMA3 = 0xF2
 
static constexpr uint8_t GC9D01_GAMMA4 = 0xF3
 
static constexpr uint8_t GC9D01_SPI2DATA = 0xB1
 
static constexpr uint8_t GC9D01_INVERSION = 0xEC
 
static constexpr uint8_t GC9D01_IFACE = 0xF6
 
static constexpr uint8_t GC9D01_INREGEN1 = 0xFE
 
static constexpr uint8_t GC9D01_INREGEN2 = 0xEF
 

Additional Inherited Members

- Protected Member Functions inherited from color16_graphics
void pushColor (uint16_t color)
 pushColor
 
void writeCommand (uint8_t)
 : Write an SPI command to
 
void writeData (uint8_t)
 Write an SPI data byte to device.
 
uint8_t spiRead (void)
 read a byte with SPI from MISO pin
 
rdlib::Return_Codes_e spiWrite (uint8_t)
 Write byte to SPI.
 
rdlib::Return_Codes_e spiWriteDataBuffer (uint8_t *spidata, int len)
 Write a buffer to SPI, both Software and hardware SPI supported.
 
- Protected Member Functions inherited from Print
void setWriteError (int err=0)
 
- Protected Attributes inherited from color16_graphics
bool _textwrap = true
 
uint16_t _textcolor = 0xFFFF
 
uint16_t _textbgcolor = 0x0000
 
int16_t _cursorX = 0
 
int16_t _cursorY = 0
 
uint16_t _width
 
uint16_t _height
 
uint8_t _XStart = 0
 
uint8_t _YStart = 0
 
float _arcAngleMax = 360.0f
 
int _arcAngleOffset = 0
 
int8_t _Display_DC
 
int8_t _Display_RST
 
int8_t _Display_CS
 
int8_t _Display_SCLK
 
int8_t _Display_SDATA
 
int8_t _Display_MISO
 
int _DeviceNumGpioChip = 0
 
int _GpioHandle = 0
 
bool _hardwareSPI =true
 
uint16_t _HighFreqDelay = 0
 
int _spiHandle = 0
 
- Protected Attributes inherited from display_Fonts
std::span< const uint8_t > _FontSelect = pFontDefault
 
uint8_t _Font_X_Size = 0x08
 
uint8_t _Font_Y_Size = 0x08
 
uint8_t _FontOffset = 0x20
 
uint8_t _FontNumChars = 0x5E
 

Detailed Description

Class to control GC9D01 TFT basic functionality.

Member Enumeration Documentation

◆ PowerState_e

GC9D01 power states based on the power control flow chart. These states combine the modes: Normal/Partial, Idle ON/OFF, and Sleep IN/OUT. They are listed from highest to lowest power consumption. Power states are based on the power control flow chart in the datasheet. FIG 89 5.10.2. Power Flow Chart.

Enumerator
NormalIdleOff 

SLPOUT + NORON + IDMOFF

NormalIdleOn 

SLPOUT + NORON + IDMON

PartialIdleOff 

SLPOUT + PLTON + IDMOFF

PartialIdleOn 

SLPOUT + PLTON + IDMON

SleepNormalIdleOff 

SLPIN + NORON + IDMOFF

SleepNormalIdleOn 

SLPIN + NORON + IDMON

SleepPartialIdleOff 

SLPIN + PLTON + IDMOFF

SleepPartialIdleOn 

SLPIN + PLTON + IDMON

◆ Resolution_e

GC9D01 panel resolution and gate configuration.

Enumerator
RGB160x160_DualGate 

160RGB × 160, S1–S240, Dual gate (default)

RGB120x160_DualGate 

120RGB × 160, S31–S210, Dual gate

RGB80x160_SingleGate 

80RGB × 160, S1–S240, Single gate

RGB40x160_SingleGate 

40RGB × 160, S61–S180, Single gate

Member Function Documentation

◆ HighFreqDelayGet()

uint16_t GC9D01_TFT::HighFreqDelayGet ( void  )

Freq delay used in SW SPI getter, uS delay used in SW SPI method.

Returns
The GPIO communications delay in uS

◆ HighFreqDelaySet()

void GC9D01_TFT::HighFreqDelaySet ( uint16_t  CommDelay)

Freq delay used in SW SPI setter, uS delay used in SW SPI method.

Parameters
CommDelayThe GPIO communications delay in uS

◆ setAddrWindow()

void GC9D01_TFT::setAddrWindow ( uint16_t  x1,
uint16_t  y1,
uint16_t  w,
uint16_t  h 
)
overridevirtual

SPI displays set an address window rectangle for blitting pixels.

Parameters
x1Top left corner x coordinate
y1Top left corner y coordinate
wWidth of window
hHeight of window
Note
https://en.wikipedia.org/wiki/Bit_blit

Implements color16_graphics.

◆ TFTchangeInvertMode()

void GC9D01_TFT::TFTchangeInvertMode ( bool  invert)

Toggle the invert mode.

Parameters
inverttrue = invert off , false = invert on

◆ TFTClock_Data_ChipSelect_Pins()

rdlib::Return_Codes_e GC9D01_TFT::TFTClock_Data_ChipSelect_Pins ( void  )
private

: Method for Clock, data and chip select pin setup routine for software SPI.

Returns
a rdlib::Return_Codes_e code
  1. rdlib::Success
  2. rdlib::GpioPinClaim

◆ TFTDataCommandPin()

rdlib::Return_Codes_e GC9D01_TFT::TFTDataCommandPin ( void  )
private

: Method for Data or Command pin setup

Returns
a rdlib::Return_Codes_e code
  1. rdlib::Success
  2. rdlib::GpioPinClaim

◆ TFTenableDisplay()

void GC9D01_TFT::TFTenableDisplay ( bool  enableDisplay)

enable /disable display mode

Parameters
enableDisplaytrue enable on false disable
Note
Temporarily blank the screen. Use Case: Screen blanking, brief off periods without resetting or reinitializing the display.

◆ TFTGC9D01Initialize()

rdlib::Return_Codes_e GC9D01_TFT::TFTGC9D01Initialize ( void  )
private

◆ TFTInitScreenSize()

void GC9D01_TFT::TFTInitScreenSize ( uint16_t  width_TFT = 160,
uint16_t  height_TFT = 160,
Resolution_e  resolution = Resolution_e::RGB160x160_DualGate,
uint16_t  Xstart = 0,
uint16_t  Ystart = 0 
)

initialise the variables that define the size of the screen

Parameters
width_TFTwidth in pixels
height_TFTheight in pixels
resolutionCurrent Resolution see enum gc9d01_resolution_e for options
XstartColumn start offset based on resolution and display type
YstartRow start offset based on resolution and display type

◆ TFTInitSPI() [1/2]

rdlib::Return_Codes_e GC9D01_TFT::TFTInitSPI ( int  device,
int  channel,
int  speed,
int  flags,
int  gpioDev 
)

intialise SPI, Hardware SPI

Parameters
deviceA SPI device, >= 0.
channelA SPI channel, >= 0.
speedThe speed of serial communication in bits per second.
flagsThe flags may be used to modify the default behaviour. Set to 0(mode 0) for this device.
gpioDevThe device number of a gpiochip.
Returns
  1. rdlib::Success = success
  2. upstream failure from TFTGC9D01Initialize()
Note
overloaded 2 off, 1 for HW SPI , 1 for SW SPI

◆ TFTInitSPI() [2/2]

rdlib::Return_Codes_e GC9D01_TFT::TFTInitSPI ( uint16_t  CommDelay,
int  gpioDev 
)

intialise PCBtype and SPI, Software SPI

Parameters
CommDelayuS GPIO delay used in software SPI
gpioDevThe device number of a gpiochip.
Returns
  1. rdlib::Success = success
  2. upstream failure from TFTGC9D01Initialize()
Note
overloaded 2 off, 1 for HW SPI , 1 for SW SPI

◆ TFTPowerDown()

rdlib::Return_Codes_e GC9D01_TFT::TFTPowerDown ( void  )

Call when powering down TFT.

Returns
a rdlib::Return_Codes_e code
  1. rdlib::Success
  2. rdlib::GpioChipDevice
  3. rdlib::GpioPinFree
  4. rdlib::SPIOpenClose
Note
Turns off Display Sets GPIO low and turns off SPI

◆ TFTResetPin()

rdlib::Return_Codes_e GC9D01_TFT::TFTResetPin ( void  )

Method for Hardware Reset pin control.

Returns
a rdlib::Return_Codes_e code
  1. rdlib::Success
  2. rdlib::GpioPinClaim

◆ TFTsetBrightness()

void GC9D01_TFT::TFTsetBrightness ( uint8_t  level)

Set display brightness (0–255).

Parameters
levelBrightness level, 0 = darkest, 255 = brightest
Note
This is a software brightness control, not hardware PWM, may not work on all displays.

◆ TFTsetPowerMode()

void GC9D01_TFT::TFTsetPowerMode ( PowerState_e  mode)

Set the power mode of the display.

Parameters
modeThe power state to set

Power states are based on the power control flow chart in the datasheet. FIG 89 5.10.2. Power Flow Chart

◆ TFTsetRotation()

void GC9D01_TFT::TFTsetRotation ( display_rotate_e  mode)

: change rotation of display.

Parameters
modedisplay_rotate_e enum

0 = Normal 1= 90 rotate 2 = 180 rotate 3 = 270 rotate Offsets passed in by user in setup() via TFTInitScreenSize offsets 0,0 for 160x160 resolution offsets -60,60 for 40x160 resolution in 90 and 270 rotations

◆ TFTsetScrollArea()

void GC9D01_TFT::TFTsetScrollArea ( uint16_t  topFixed,
uint16_t  scrollArea,
uint16_t  bottomFixed 
)

This method defines the Vertical Scrolling Area of the display where:

Parameters
topFixeddescribes the Top Fixed Area.
scrollAreadescribes the Scrolling Area.
bottomFixeddescribes the Bottom Fixed Area.

◆ TFTsetScrollStart()

void GC9D01_TFT::TFTsetScrollStart ( uint16_t  vsp)

This method is used together with the setScrollDefinition.

Parameters
vspscrolling mode

◆ TFTSetupGPIO() [1/2]

void GC9D01_TFT::TFTSetupGPIO ( int8_t  rst,
int8_t  dc 
)

sets up TFT GPIO for Hardware SPi

Parameters
rstreset GPIO
dcdata or command GPIO.

for software reset pass -1 to rst

Note
overloaded 2 off, 1 for HW SPI , 1 for SW SPI

◆ TFTSetupGPIO() [2/2]

void GC9D01_TFT::TFTSetupGPIO ( int8_t  rst,
int8_t  dc,
int8_t  cs,
int8_t  sclk,
int8_t  din 
)

sets up TFT GPIO for software SPI

Parameters
rstreset GPIO
dcdata or command GPIO.
cschip select GPIO
sclkData clock GPIO
dinData to TFT GPIO

for software reset pass -1 to rst

Note
overloaded 2 off, 1 for HW SPI , 1 for SW SPI

◆ TFTSetupResetPin()

void GC9D01_TFT::TFTSetupResetPin ( int8_t  rst)
private

sets up TFT GPIO reset pin

Parameters
rstreset GPIO

if rst value is -1 use software reset, else use Hardware reset.

Member Data Documentation

◆ _currentPowerState

PowerState_e GC9D01_TFT::_currentPowerState = PowerState_e::NormalIdleOff
private

Enum to hold display mode

◆ _currentResolution

Resolution_e GC9D01_TFT::_currentResolution = Resolution_e::RGB160x160_DualGate
private

enum to hold display resolution

◆ _displayOn

bool GC9D01_TFT::_displayOn = false
private

Enum to hold display on/off status

◆ _GC9D01_X_Offset

uint16_t GC9D01_TFT::_GC9D01_X_Offset = 0
private

Column offset based on rotation, resolution and display type

◆ _GC9D01_X_Offset_Start

uint16_t GC9D01_TFT::_GC9D01_X_Offset_Start = 0
private

column offset, never change after first init

◆ _GC9D01_Y_Offset

uint16_t GC9D01_TFT::_GC9D01_Y_Offset = 0
private

Row offset based on rotation, resolution and display type

◆ _GC9D01_Y_Offset_Start

uint16_t GC9D01_TFT::_GC9D01_Y_Offset_Start = 0
private

row offset, never change after first init

◆ _heightStartTFT

uint16_t GC9D01_TFT::_heightStartTFT = 160
private

never change after first init

◆ _resetPinOn

bool GC9D01_TFT::_resetPinOn = true
private

reset pin? true:hw rst pin, false:sw rt

◆ _sleepDelay

const uint16_t GC9D01_TFT::_sleepDelay = 120
private

Sleep delay in ms ?

◆ _spiBaud

int GC9D01_TFT::_spiBaud = 50000
private

The speed of serial communication in bits per second.

◆ _spiChan

int GC9D01_TFT::_spiChan = 0
private

A SPI channel, >= 0.

◆ _spiDev

int GC9D01_TFT::_spiDev = 0
private

A SPI device, >= 0.

◆ _spiFlags

int GC9D01_TFT::_spiFlags = 0
private

The flags 2 LSB defines SPI mode

◆ _widthStartTFT

uint16_t GC9D01_TFT::_widthStartTFT = 160
private

never change after first init

◆ displayRotate

display_rotate_e GC9D01_TFT::displayRotate = Degrees_0

Enum to hold rotation

◆ GC9D01_BLANK_PORCH_CTRL

constexpr uint8_t GC9D01_TFT::GC9D01_BLANK_PORCH_CTRL = 0xB5
staticconstexprprivate

Blanking Porch Control

◆ GC9D01_CASET

constexpr uint8_t GC9D01_TFT::GC9D01_CASET = 0x2A
staticconstexprprivate

Column Address Set

◆ GC9D01_COLMOD

constexpr uint8_t GC9D01_TFT::GC9D01_COLMOD = 0x3A
staticconstexprprivate

Pixel Format Set

◆ GC9D01_CONTINUE

constexpr uint8_t GC9D01_TFT::GC9D01_CONTINUE = 0x3C
staticconstexprprivate

Write Memory Continue

◆ GC9D01_DISPOFF

constexpr uint8_t GC9D01_TFT::GC9D01_DISPOFF = 0x28
staticconstexprprivate

Display OFF

◆ GC9D01_DISPON

constexpr uint8_t GC9D01_TFT::GC9D01_DISPON = 0x29
staticconstexprprivate

Display ON

◆ GC9D01_DUAL_SINGLE

constexpr uint8_t GC9D01_TFT::GC9D01_DUAL_SINGLE = 0xBF
staticconstexprprivate

Dual-Single gate select

◆ GC9D01_FUNCTION_CTRL

constexpr uint8_t GC9D01_TFT::GC9D01_FUNCTION_CTRL = 0xB6
staticconstexprprivate

Display Function Control

◆ GC9D01_GAMMA1

constexpr uint8_t GC9D01_TFT::GC9D01_GAMMA1 = 0xF0
staticconstexprprivate

Set gamma 1

◆ GC9D01_GAMMA2

constexpr uint8_t GC9D01_TFT::GC9D01_GAMMA2 = 0xF1
staticconstexprprivate

Set gamma 2

◆ GC9D01_GAMMA3

constexpr uint8_t GC9D01_TFT::GC9D01_GAMMA3 = 0xF2
staticconstexprprivate

Set gamma 3

◆ GC9D01_GAMMA4

constexpr uint8_t GC9D01_TFT::GC9D01_GAMMA4 = 0xF3
staticconstexprprivate

Set gamma 4

◆ GC9D01_GETLINE

constexpr uint8_t GC9D01_TFT::GC9D01_GETLINE = 0x45
staticconstexprprivate

Get Scanline

◆ GC9D01_IDLEOFF

constexpr uint8_t GC9D01_TFT::GC9D01_IDLEOFF = 0x38
staticconstexprprivate

Idle mode OFF

◆ GC9D01_IDLEON

constexpr uint8_t GC9D01_TFT::GC9D01_IDLEON = 0x39
staticconstexprprivate

Idle mode ON

◆ GC9D01_IFACE

constexpr uint8_t GC9D01_TFT::GC9D01_IFACE = 0xF6
staticconstexprprivate

Interface control

◆ GC9D01_INREGEN1

constexpr uint8_t GC9D01_TFT::GC9D01_INREGEN1 = 0xFE
staticconstexprprivate

Inter register enable 1

◆ GC9D01_INREGEN2

constexpr uint8_t GC9D01_TFT::GC9D01_INREGEN2 = 0xEF
staticconstexprprivate

Inter register enable 2

◆ GC9D01_INVERSION

constexpr uint8_t GC9D01_TFT::GC9D01_INVERSION = 0xEC
staticconstexprprivate

Inversion

◆ GC9D01_INVOFF

constexpr uint8_t GC9D01_TFT::GC9D01_INVOFF = 0x20
staticconstexprprivate

Display Inversion OFF

◆ GC9D01_INVON

constexpr uint8_t GC9D01_TFT::GC9D01_INVON = 0x21
staticconstexprprivate

Display Inversion ON

◆ GC9D01_MADCTL

constexpr uint8_t GC9D01_TFT::GC9D01_MADCTL = 0x36
staticconstexprprivate

Memory Access Control

◆ GC9D01_NORON

constexpr uint8_t GC9D01_TFT::GC9D01_NORON = 0x13
staticconstexprprivate

Normal Display Mode ON

◆ GC9D01_POWER_CTRL

constexpr uint8_t GC9D01_TFT::GC9D01_POWER_CTRL = 0xC1
staticconstexprprivate

Power Criterion Control

◆ GC9D01_PTLAR

constexpr uint8_t GC9D01_TFT::GC9D01_PTLAR = 0x30
staticconstexprprivate

Partial Area

◆ GC9D01_PTLON

constexpr uint8_t GC9D01_TFT::GC9D01_PTLON = 0x12
staticconstexprprivate

Partial Mode ON

◆ GC9D01_RAMWR

constexpr uint8_t GC9D01_TFT::GC9D01_RAMWR = 0x2C
staticconstexprprivate

Memory Write

◆ GC9D01_RASET

constexpr uint8_t GC9D01_TFT::GC9D01_RASET = 0x2B
staticconstexprprivate

Row/page Address Set

◆ GC9D01_RDDID

constexpr uint8_t GC9D01_TFT::GC9D01_RDDID = 0x04
staticconstexprprivate

Read display identification information

◆ GC9D01_RDDST

constexpr uint8_t GC9D01_TFT::GC9D01_RDDST = 0x09
staticconstexprprivate

Read Display Status

◆ GC9D01_RDID1

constexpr uint8_t GC9D01_TFT::GC9D01_RDID1 = 0xDA
staticconstexprprivate

Read ID 1

◆ GC9D01_RDID2

constexpr uint8_t GC9D01_TFT::GC9D01_RDID2 = 0xDB
staticconstexprprivate

Read ID 2

◆ GC9D01_RDID3

constexpr uint8_t GC9D01_TFT::GC9D01_RDID3 = 0xDC
staticconstexprprivate

Read ID 3

◆ GC9D01_RGB_CTRL

constexpr uint8_t GC9D01_TFT::GC9D01_RGB_CTRL = 0xB0
staticconstexprprivate

RGB Interface Signal Control

◆ GC9D01_SETBRIGHT

constexpr uint8_t GC9D01_TFT::GC9D01_SETBRIGHT = 0x51
staticconstexprprivate

Write Display Brightness

◆ GC9D01_SETCTRL

constexpr uint8_t GC9D01_TFT::GC9D01_SETCTRL = 0x53
staticconstexprprivate

Write CTRL Display

◆ GC9D01_SLPIN

constexpr uint8_t GC9D01_TFT::GC9D01_SLPIN = 0x10
staticconstexprprivate

Enter Sleep Mode

◆ GC9D01_SLPOUT

constexpr uint8_t GC9D01_TFT::GC9D01_SLPOUT = 0x11
staticconstexprprivate

Sleep Out

◆ GC9D01_SPI2DATA

constexpr uint8_t GC9D01_TFT::GC9D01_SPI2DATA = 0xB1
staticconstexprprivate

SPI 2DATA control

◆ GC9D01_SWRESET

constexpr uint8_t GC9D01_TFT::GC9D01_SWRESET = 0x01
staticconstexprprivate

Software Reset undocumented ???

◆ GC9D01_TEARSET

constexpr uint8_t GC9D01_TFT::GC9D01_TEARSET = 0x44
staticconstexprprivate

Set Tear Scanline

◆ GC9D01_TEOFF

constexpr uint8_t GC9D01_TFT::GC9D01_TEOFF = 0x34
staticconstexprprivate

Tearing Effect Line OFF

◆ GC9D01_TEON

constexpr uint8_t GC9D01_TFT::GC9D01_TEON = 0x35
staticconstexprprivate

Tearing Effect Line ON

◆ GC9D01_TEWC

constexpr uint8_t GC9D01_TFT::GC9D01_TEWC = 0xB4
staticconstexprprivate

Tearing effect width control

◆ GC9D01_VREG1A_CTRL

constexpr uint8_t GC9D01_TFT::GC9D01_VREG1A_CTRL = 0xC3
staticconstexprprivate

Vreg1a voltage Control

◆ GC9D01_VREG1B_CTRL

constexpr uint8_t GC9D01_TFT::GC9D01_VREG1B_CTRL = 0xC4
staticconstexprprivate

Vreg1b voltage Control

◆ GC9D01_VREG2A_CTRL

constexpr uint8_t GC9D01_TFT::GC9D01_VREG2A_CTRL = 0xC9
staticconstexprprivate

Vreg2a voltage Control

◆ GC9D01_VSCRDEF

constexpr uint8_t GC9D01_TFT::GC9D01_VSCRDEF = 0x33
staticconstexprprivate

Vertical Scrolling Definition

◆ GC9D01_VSCRSADD

constexpr uint8_t GC9D01_TFT::GC9D01_VSCRSADD = 0x37
staticconstexprprivate

Vertical Scrolling Start Address


The documentation for this class was generated from the following files: