Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
ST7735_TFT_LCD_RDL.hpp
Go to the documentation of this file.
1
7#pragma once
8
9// Section Libraries
10#include <cstdint>
11#include <cstdbool>
12#include <cstring>
13#include <lgpio.h>
15
16
21{
22
23public:
24
25 ST7735_TFT();
26 ~ST7735_TFT(){};
27
28 // Enums
29
42
43
52
57 // Functions
58 // From graphics virtual
59 virtual void setAddrWindow(uint16_t, uint16_t, uint16_t, uint16_t) override;
60 //Setup related
61 void TFTSetupGPIO(int8_t, int8_t, int8_t, int8_t, int8_t); //SW SPI
62 void TFTSetupGPIO(int8_t, int8_t); // HW SPI
66
67 // SPI related
72 // Screen related
78
79private:
87
88 void Rcmd1(void);
89 void Rcmd2red(void);
90 void Rcmd3(void);
91 void Bcmd(void);
92 void Rcmd2green(void);
93
94 //screen
100 //SPI
101 int _spiDev = 0;
102 int _spiChan = 0;
103 int _spiBaud = 50000;
104 int _spiFlags = 0;
106 // ST7735 registers + Commands
107 // ST7735 general purpose
108 static constexpr uint8_t ST7735_NOP = 0x00 ;
109 static constexpr uint8_t ST7735_SWRESET= 0x01 ;
110 static constexpr uint8_t ST7735_RDDID = 0x04 ;
111 static constexpr uint8_t ST7735_RDDST = 0x09 ;
113 // ST7735 Modes
114 static constexpr uint8_t ST7735_SLPIN = 0x10 ;
115 static constexpr uint8_t ST7735_SLPOUT = 0x11 ;
116 static constexpr uint8_t ST7735_PTLON = 0x12 ;
117 static constexpr uint8_t ST7735_NORON = 0x13 ;
118 static constexpr uint8_t ST7735_INVOFF = 0x20 ;
119 static constexpr uint8_t ST7735_INVON = 0x21 ;
120 static constexpr uint8_t ST7735_DISPOFF= 0x28 ;
121 static constexpr uint8_t ST7735_DISPON = 0x29 ;
122 static constexpr uint8_t ST7735_TFT_Idle_modeON= 0x39 ;
123 static constexpr uint8_t ST7735_TFT_Idle_modeOF = 0x38 ;
125 // ST7735 Addressing
126 static constexpr uint8_t ST7735_CASET = 0x2A ;
127 static constexpr uint8_t ST7735_RASET = 0x2B ;
128 static constexpr uint8_t ST7735_RAMWR = 0x2C ;
129 static constexpr uint8_t ST7735_RAMRD = 0x2E ;
130 static constexpr uint8_t ST7735_PTLAR = 0x30 ;
131 static constexpr uint8_t ST7735_VSCRDEF= 0x33 ;
132 static constexpr uint8_t ST7735_COLMOD = 0x3A ;
133 static constexpr uint8_t ST7735_MADCTL = 0x36 ;
134 static constexpr uint8_t ST7735_VSCRSADD= 0x37 ;
136 // Frame Rate Control
137 static constexpr uint8_t ST7735_FRMCTR1= 0xB1 ;
138 static constexpr uint8_t ST7735_FRMCTR2= 0xB2 ;
139 static constexpr uint8_t ST7735_FRMCTR3= 0xB3 ;
141 static constexpr uint8_t ST7735_INVCTR = 0xB4 ;
142 static constexpr uint8_t ST7735_DISSET5= 0xB6 ;
144 // ST7735 Power_Control
145 static constexpr uint8_t ST7735_PWCTR1 = 0xC0 ;
146 static constexpr uint8_t ST7735_PWCTR2 = 0xC1 ;
147 static constexpr uint8_t ST7735_PWCTR3 = 0xC2 ;
148 static constexpr uint8_t ST7735_PWCTR4 = 0xC3 ;
149 static constexpr uint8_t ST7735_PWCTR5 = 0xC4 ;
150 static constexpr uint8_t ST7735_PWCTR6 = 0xFC ;
152 static constexpr uint8_t ST7735_VMCTR1 = 0xC5 ;
154 static constexpr uint8_t ST7735_RDID1 = 0xDA ;
155 static constexpr uint8_t ST7735_RDID2 = 0xDB ;
156 static constexpr uint8_t ST7735_RDID3 = 0xDC ;
157 static constexpr uint8_t ST7735_RDID4 = 0xDD ;
159 // ST7735 color control
160 static constexpr uint8_t ST7735_GMCTRP1= 0xE0 ;
161 static constexpr uint8_t ST7735_GMCTRN1= 0xE1 ;
163 // Memory Access Data Control Register
164 static constexpr uint8_t ST7735_MADCTL_MY= 0x80 ;
165 static constexpr uint8_t ST7735_MADCTL_MX= 0x40 ;
166 static constexpr uint8_t ST7735_MADCTL_MV= 0x20 ;
167 static constexpr uint8_t ST7735_MADCTL_ML= 0x10 ;
168 static constexpr uint8_t ST7735_MADCTL_RGB= 0x00 ;
169 static constexpr uint8_t ST7735_MADCTL_BGR= 0x08 ;
170 static constexpr uint8_t ST7735_MADCTL_MH= 0x04 ;
172}; //end of ST7735_TFT class
173
174// ********************** EOF *********************
static constexpr int defaultFormat()
Called from vector & string template , Get the default format for a given type.
Definition print_data_RDL.hpp:206
Class to control ST7735 TFT basic functionality.
Definition ST7735_TFT_LCD_RDL.hpp:21
rdlib::Return_Codes_e TFTDataCommandPin(void)
Method for Data or Command pin setup.
Definition ST7735_TFT_LCD_RDL.cpp:199
static constexpr uint8_t ST7735_CASET
Definition ST7735_TFT_LCD_RDL.hpp:126
TFT_modes_e
Definition ST7735_TFT_LCD_RDL.hpp:32
@ TFT_Sleep_mode
Definition ST7735_TFT_LCD_RDL.hpp:36
@ TFT_Partial_mode
Definition ST7735_TFT_LCD_RDL.hpp:34
@ TFT_Invert_mode
Definition ST7735_TFT_LCD_RDL.hpp:38
@ TFT_Display_off_mode
Definition ST7735_TFT_LCD_RDL.hpp:40
@ TFT_Display_on_mode
Definition ST7735_TFT_LCD_RDL.hpp:39
@ TFT_Normal_mode
Definition ST7735_TFT_LCD_RDL.hpp:33
@ TFT_Idle_mode
Definition ST7735_TFT_LCD_RDL.hpp:35
void Bcmd(void)
init sub-routine for ST7735B controller
Definition ST7735_TFT_LCD_RDL.cpp:336
void TFTchangeInvertMode(bool invertModeOn)
Toggle the invert mode.
Definition ST7735_TFT_LCD_RDL.cpp:518
void Rcmd1(void)
init sub-routine
Definition ST7735_TFT_LCD_RDL.cpp:395
void Rcmd2green(void)
init sub-routine ST7735R Green Tab
Definition ST7735_TFT_LCD_RDL.cpp:324
void TFTsetRotation(display_rotate_e r)
: change rotation of display.
Definition ST7735_TFT_LCD_RDL.cpp:596
virtual void setAddrWindow(uint16_t, uint16_t, uint16_t, uint16_t) override
SPI displays set an address window rectangle for blitting pixels.
Definition ST7735_TFT_LCD_RDL.cpp:760
uint16_t _heightStartTFT
Definition ST7735_TFT_LCD_RDL.hpp:98
static constexpr uint8_t ST7735_RDDST
Definition ST7735_TFT_LCD_RDL.hpp:111
static constexpr uint8_t ST7735_INVOFF
Definition ST7735_TFT_LCD_RDL.hpp:118
static constexpr uint8_t ST7735_PWCTR3
Definition ST7735_TFT_LCD_RDL.hpp:147
TFT_PCBtype_e
Definition ST7735_TFT_LCD_RDL.hpp:46
@ TFT_ST7735R_Green
Definition ST7735_TFT_LCD_RDL.hpp:48
@ TFT_ST7735R_Red
Definition ST7735_TFT_LCD_RDL.hpp:47
@ TFT_ST7735S_Black
Definition ST7735_TFT_LCD_RDL.hpp:49
@ TFT_ST7735B
Definition ST7735_TFT_LCD_RDL.hpp:50
static constexpr uint8_t ST7735_RASET
Definition ST7735_TFT_LCD_RDL.hpp:127
static constexpr uint8_t ST7735_SLPIN
Definition ST7735_TFT_LCD_RDL.hpp:114
static constexpr uint8_t ST7735_NOP
Definition ST7735_TFT_LCD_RDL.hpp:108
rdlib::Return_Codes_e TFTRedTabInitialize(void)
ST7735R Red Tab Init Red PCB version.
Definition ST7735_TFT_LCD_RDL.cpp:275
static constexpr uint8_t ST7735_VSCRSADD
Definition ST7735_TFT_LCD_RDL.hpp:134
static constexpr uint8_t ST7735_MADCTL_RGB
Definition ST7735_TFT_LCD_RDL.hpp:168
static constexpr uint8_t ST7735_FRMCTR3
Definition ST7735_TFT_LCD_RDL.hpp:139
static constexpr uint8_t ST7735_PTLON
Definition ST7735_TFT_LCD_RDL.hpp:116
static constexpr uint8_t ST7735_PWCTR6
Definition ST7735_TFT_LCD_RDL.hpp:150
rdlib::Return_Codes_e TFTBlackTabInitialize(void)
Init Routine ST7735R Black Tab (ST7735S)
Definition ST7735_TFT_LCD_RDL.cpp:292
static constexpr uint8_t ST7735_RDID4
Definition ST7735_TFT_LCD_RDL.hpp:157
static constexpr uint8_t ST7735_DISSET5
Definition ST7735_TFT_LCD_RDL.hpp:142
static constexpr uint8_t ST7735_MADCTL_MV
Definition ST7735_TFT_LCD_RDL.hpp:166
static constexpr uint8_t ST7735_COLMOD
Definition ST7735_TFT_LCD_RDL.hpp:132
int _spiDev
Definition ST7735_TFT_LCD_RDL.hpp:101
static constexpr uint8_t ST7735_SLPOUT
Definition ST7735_TFT_LCD_RDL.hpp:115
static constexpr uint8_t ST7735_TFT_Idle_modeOF
Definition ST7735_TFT_LCD_RDL.hpp:123
void TFTInitScreenSize(uint8_t xOffset, uint8_t yOffset, uint16_t w, uint16_t h)
initialise the variables that define the size of the screen
Definition ST7735_TFT_LCD_RDL.cpp:660
static constexpr uint8_t ST7735_VMCTR1
Definition ST7735_TFT_LCD_RDL.hpp:152
int _spiChan
Definition ST7735_TFT_LCD_RDL.hpp:102
uint16_t _widthStartTFT
Definition ST7735_TFT_LCD_RDL.hpp:97
static constexpr uint8_t ST7735_GMCTRN1
Definition ST7735_TFT_LCD_RDL.hpp:161
static constexpr uint8_t ST7735_RDID2
Definition ST7735_TFT_LCD_RDL.hpp:155
static constexpr uint8_t ST7735_SWRESET
Definition ST7735_TFT_LCD_RDL.hpp:109
TFT_PCBtype_e TFT_PCBtype
Definition ST7735_TFT_LCD_RDL.hpp:55
static constexpr uint8_t ST7735_PWCTR5
Definition ST7735_TFT_LCD_RDL.hpp:149
rdlib::Return_Codes_e TFTClock_Data_ChipSelect_Pins(void)
Method for Clock, data and chip select pin setup routine for software SPI.
Definition ST7735_TFT_LCD_RDL.cpp:219
static constexpr uint8_t ST7735_NORON
Definition ST7735_TFT_LCD_RDL.hpp:117
void TFTSetupGPIO(int8_t, int8_t, int8_t, int8_t, int8_t)
sets up TFT GPIO for software SPI
Definition ST7735_TFT_LCD_RDL.cpp:120
static constexpr uint8_t ST7735_TFT_Idle_modeON
Definition ST7735_TFT_LCD_RDL.hpp:122
uint8_t _colstart
Definition ST7735_TFT_LCD_RDL.hpp:95
static constexpr uint8_t ST7735_RDID1
Definition ST7735_TFT_LCD_RDL.hpp:154
static constexpr uint8_t ST7735_MADCTL_ML
Definition ST7735_TFT_LCD_RDL.hpp:167
static constexpr uint8_t ST7735_INVCTR
Definition ST7735_TFT_LCD_RDL.hpp:141
static constexpr uint8_t ST7735_PTLAR
Definition ST7735_TFT_LCD_RDL.hpp:130
static constexpr uint8_t ST7735_VSCRDEF
Definition ST7735_TFT_LCD_RDL.hpp:131
TFT_modes_e TFT_mode
Definition ST7735_TFT_LCD_RDL.hpp:53
static constexpr uint8_t ST7735_FRMCTR1
Definition ST7735_TFT_LCD_RDL.hpp:137
static constexpr uint8_t ST7735_DISPON
Definition ST7735_TFT_LCD_RDL.hpp:121
ST7735_TFT()
Constructor for class ST7735_TFT.
Definition ST7735_TFT_LCD_RDL.cpp:12
static constexpr uint8_t ST7735_MADCTL_MY
Definition ST7735_TFT_LCD_RDL.hpp:164
static constexpr uint8_t ST7735_PWCTR4
Definition ST7735_TFT_LCD_RDL.hpp:148
static constexpr uint8_t ST7735_FRMCTR2
Definition ST7735_TFT_LCD_RDL.hpp:138
int _spiBaud
Definition ST7735_TFT_LCD_RDL.hpp:103
static constexpr uint8_t ST7735_RDDID
Definition ST7735_TFT_LCD_RDL.hpp:110
void TFTVerticalScroll(uint8_t vsp)
: This method is used together with the TFTsetScrollDefinition.
Definition ST7735_TFT_LCD_RDL.cpp:508
void Rcmd2red(void)
init sub-routine
Definition ST7735_TFT_LCD_RDL.cpp:438
rdlib::Return_Codes_e TFTInitPCBType(TFT_PCBtype_e pcbType, uint16_t CommDelay, int gpioDev)
intialise PCBtype and SPI, Software SPI
Definition ST7735_TFT_LCD_RDL.cpp:720
static constexpr uint8_t ST7735_DISPOFF
Definition ST7735_TFT_LCD_RDL.hpp:120
void TFTchangeMode(TFT_modes_e m)
This changes the mode of the display as:
Definition ST7735_TFT_LCD_RDL.cpp:537
static constexpr uint8_t ST7735_PWCTR1
Definition ST7735_TFT_LCD_RDL.hpp:145
int _spiFlags
Definition ST7735_TFT_LCD_RDL.hpp:104
static constexpr uint8_t ST7735_PWCTR2
Definition ST7735_TFT_LCD_RDL.hpp:146
static constexpr uint8_t ST7735_INVON
Definition ST7735_TFT_LCD_RDL.hpp:119
rdlib::Return_Codes_e TFTResetPin(void)
Method for Hardware Reset pin control.
Definition ST7735_TFT_LCD_RDL.cpp:174
void Rcmd3(void)
init sub-routine
Definition ST7735_TFT_LCD_RDL.cpp:450
rdlib::Return_Codes_e TFTGreenTabInitialize(void)
init sub-routine ST7735R Green Tab
Definition ST7735_TFT_LCD_RDL.cpp:257
uint16_t HighFreqDelayGet(void)
Freq delay used in SW SPI getter, uS delay used in SW SPI method.
Definition ST7735_TFT_LCD_RDL.cpp:744
static constexpr uint8_t ST7735_MADCTL_BGR
Definition ST7735_TFT_LCD_RDL.hpp:169
display_rotate_e displayRotate
Definition ST7735_TFT_LCD_RDL.hpp:54
static constexpr uint8_t ST7735_MADCTL_MX
Definition ST7735_TFT_LCD_RDL.hpp:165
void TFTsetScrollDefinition(uint8_t th, uint8_t tb, bool sd)
This method defines the Vertical Scrolling Area of the display where:
Definition ST7735_TFT_LCD_RDL.cpp:470
uint8_t _rowstart
Definition ST7735_TFT_LCD_RDL.hpp:96
static constexpr uint8_t ST7735_RAMWR
Definition ST7735_TFT_LCD_RDL.hpp:128
static constexpr uint8_t ST7735_MADCTL
Definition ST7735_TFT_LCD_RDL.hpp:133
rdlib::Return_Codes_e TFTST7735BInitialize(void)
init routine for ST7735B controller
Definition ST7735_TFT_LCD_RDL.cpp:312
rdlib::Return_Codes_e TFTPowerDown(void)
Call when powering down TFT.
Definition ST7735_TFT_LCD_RDL.cpp:23
static constexpr uint8_t ST7735_MADCTL_MH
Definition ST7735_TFT_LCD_RDL.hpp:170
static constexpr uint8_t ST7735_RDID3
Definition ST7735_TFT_LCD_RDL.hpp:156
static constexpr uint8_t ST7735_GMCTRP1
Definition ST7735_TFT_LCD_RDL.hpp:160
static constexpr uint8_t ST7735_RAMRD
Definition ST7735_TFT_LCD_RDL.hpp:129
rdlib::Return_Codes_e TFTSPIInit(void)
init the SPI
Definition ST7735_TFT_LCD_RDL.cpp:138
void HighFreqDelaySet(uint16_t)
Freq delay used in SW SPI setter, uS delay used in SW SPI method.
Definition ST7735_TFT_LCD_RDL.cpp:750
Class to handle fonts and graphics of color 16 bit display.
Definition color16_graphics_RDL.hpp:22
display_rotate_e
Definition color16_graphics_RDL.hpp:62
@ Degrees_0
Definition color16_graphics_RDL.hpp:63
Library header file for 16 bit (565) color graphics library. This file handles the graphic methods.
Return_Codes_e
Definition common_data_RDL.hpp:22