JM9 XRCU Board 0.1.1
Libraries API Reference
Loading...
Searching...
No Matches
Adafruit_ST77xx.h
1/**************************************************************************
2 This is a library for several Adafruit displays based on ST77* drivers.
3
4 Works with the Adafruit 1.8" TFT Breakout w/SD card
5 ----> http://www.adafruit.com/products/358
6 The 1.8" TFT shield
7 ----> https://www.adafruit.com/product/802
8 The 1.44" TFT breakout
9 ----> https://www.adafruit.com/product/2088
10 as well as Adafruit raw 1.8" TFT display
11 ----> http://www.adafruit.com/products/618
12
13 Check out the links above for our tutorials and wiring diagrams.
14 These displays use SPI to communicate, 4 or 5 pins are required to
15 interface (RST is optional).
16
17 Adafruit invests time and resources providing this open source code,
18 please support Adafruit and open-source hardware by purchasing
19 products from Adafruit!
20
21 Written by Limor Fried/Ladyada for Adafruit Industries.
22 MIT license, all text above must be included in any redistribution
23 **************************************************************************/
24
25#ifndef _ADAFRUIT_ST77XXH_
26#define _ADAFRUIT_ST77XXH_
27
28#include "Arduino.h"
29#include "Print.h"
30#include "../Adafruit_GFX_Library/Adafruit_GFX.h"
32#include "../Adafruit_GFX_Library/Adafruit_SPITFT_Macros.h"
33
34#define ST7735_TFTWIDTH_128 128 // for 1.44 and mini
35#define ST7735_TFTWIDTH_80 80 // for mini
36#define ST7735_TFTHEIGHT_128 128 // for 1.44" display
37#define ST7735_TFTHEIGHT_160 160 // for 1.8" and mini display
38
39#define ST_CMD_DELAY 0x80 // special signifier for command lists
40
41#define ST77XX_NOP 0x00
42#define ST77XX_SWRESET 0x01
43#define ST77XX_RDDID 0x04
44#define ST77XX_RDDST 0x09
45
46#define ST77XX_SLPIN 0x10
47#define ST77XX_SLPOUT 0x11
48#define ST77XX_PTLON 0x12
49#define ST77XX_NORON 0x13
50
51#define ST77XX_INVOFF 0x20
52#define ST77XX_INVON 0x21
53#define ST77XX_DISPOFF 0x28
54#define ST77XX_DISPON 0x29
55#define ST77XX_CASET 0x2A
56#define ST77XX_RASET 0x2B
57#define ST77XX_RAMWR 0x2C
58#define ST77XX_RAMRD 0x2E
59
60#define ST77XX_PTLAR 0x30
61#define ST77XX_TEOFF 0x34
62#define ST77XX_TEON 0x35
63#define ST77XX_MADCTL 0x36
64#define ST77XX_COLMOD 0x3A
65
66#define ST77XX_MADCTL_MY 0x80
67#define ST77XX_MADCTL_MX 0x40
68#define ST77XX_MADCTL_MV 0x20
69#define ST77XX_MADCTL_ML 0x10
70#define ST77XX_MADCTL_RGB 0x00
71
72#define ST77XX_RDID1 0xDA
73#define ST77XX_RDID2 0xDB
74#define ST77XX_RDID3 0xDC
75#define ST77XX_RDID4 0xDD
76
77// Some ready-made 16-bit ('565') color settings:
78#define ST77XX_BLACK 0x0000
79#define ST77XX_WHITE 0xFFFF
80#define ST77XX_RED 0xF800
81#define ST77XX_GREEN 0x07E0
82#define ST77XX_BLUE 0x001F
83#define ST77XX_CYAN 0x07FF
84#define ST77XX_MAGENTA 0xF81F
85#define ST77XX_YELLOW 0xFFE0
86#define ST77XX_ORANGE 0xFC00
87
90public:
91 Adafruit_ST77xx(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _MOSI,
92 int8_t _SCLK, int8_t _RST = -1, int8_t _MISO = -1);
93 Adafruit_ST77xx(uint16_t w, uint16_t h, int8_t CS, int8_t RS,
94 int8_t RST = -1);
95#if !defined(ESP8266)
96 Adafruit_ST77xx(uint16_t w, uint16_t h, SPIClass *spiClass, int8_t CS,
97 int8_t RS, int8_t RST = -1);
98#endif // end !ESP8266
99
100 void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
101 void setRotation(uint8_t r);
102 void enableDisplay(boolean enable);
103 void enableTearing(boolean enable);
104 void enableSleep(boolean enable);
105
106protected:
107 uint8_t _colstart = 0,
109 spiMode = SPI_MODE0;
110
111 void begin(uint32_t freq = 0);
112 void begin(uint32_t freq, bool reset); // param reset added by YH Choi 2025-02-26 02:17:00 UTC
113 void commonInit(const uint8_t *cmdList);
114 void displayInit(const uint8_t *addr);
115 void setColRowStart(int8_t col, int8_t row);
116};
117
118#endif // _ADAFRUIT_ST77XXH_
Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t cs, int8_t dc, int8_t mosi, int8_t sck, int8_t rst=-1, int8_t miso=-1)
Adafruit_SPITFT constructor for software (bitbang) SPI.
Definition Adafruit_SPITFT.cpp:117
void displayInit(const uint8_t *addr)
Companion code to the initiliazation tables. Reads and issues a series of LCD commands stored in PROG...
Definition Adafruit_ST77xx.cpp:93
void enableSleep(boolean enable)
Change whether sleep mode is on or off.
Definition Adafruit_ST77xx.cpp:261
uint8_t _rowstart
Some displays need this changed to offset.
Definition Adafruit_ST77xx.h:108
void commonInit(const uint8_t *cmdList)
Initialization code common to all ST77XX displays.
Definition Adafruit_ST77xx.cpp:153
Adafruit_ST77xx(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK, int8_t _RST=-1, int8_t _MISO=-1)
Instantiate Adafruit ST77XX driver with software SPI.
Definition Adafruit_ST77xx.cpp:50
void setRotation(uint8_t r)
Set origin of (0,0) and orientation of TFT display.
Definition Adafruit_ST77xx.cpp:192
void setColRowStart(int8_t col, int8_t row)
Set origin of (0,0) of display with offsets.
Definition Adafruit_ST77xx.cpp:230
uint8_t spiMode
Certain display needs MODE3 instead.
Definition Adafruit_ST77xx.h:109
void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
SPI displays set an address window rectangle for blitting pixels.
Definition Adafruit_ST77xx.cpp:170
void begin(uint32_t freq=0)
Initialize ST77xx chip. Connects to the ST77XX over SPI and sends initialization procedure commands.
Definition Adafruit_ST77xx.cpp:123
void enableTearing(boolean enable)
Change whether TE pin output is on or off.
Definition Adafruit_ST77xx.cpp:251
void enableDisplay(boolean enable)
Change whether display is on or off.
Definition Adafruit_ST77xx.cpp:241
uint8_t _colstart
Some displays need this changed to offset.
Definition Adafruit_ST77xx.h:107