Adafruit ST77XX Display Library
Adafruit_ST7796S.h
1 // Adafruit_ST7796S.h
2 //
3 // MIT License
4 //
5 // Copyright (c) 2025 Limor Fried/Ladyada for Adafruit Industries
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in
15 // all copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 
25 #ifndef _ADAFRUIT_ST7796S_H_
26 #define _ADAFRUIT_ST7796S_H_
27 
28 #include "Adafruit_ST77xx.h"
29 
30 #define ST7796S_TFTWIDTH 320
31 #define ST7796S_TFTHEIGHT 480
32 
33 // ST7796S specific commands
34 #define ST7796S_RGBCTRL 0xB1
35 #define ST7796S_FRMCTR1 0xB2
36 #define ST7796S_PWCTRL1 0xC0
37 #define ST7796S_PWCTRL2 0xC1
38 #define ST7796S_VMCTRL1 0xC5
39 #define ST7796S_VMCTRL2 0xC7
40 #define ST7796S_PGAMCTRL 0xE0
41 #define ST7796S_NGAMCTRL 0xE1
42 
46 enum ST7796S_ColorOrder {
47  ST7796S_RGB = 0x00,
48  ST7796S_BGR = 0x08
49 };
50 
55 public:
56  Adafruit_ST7796S(int8_t CS, int8_t RS, int8_t MOSI, int8_t SCLK,
57  int8_t RST = -1);
58  Adafruit_ST7796S(int8_t CS, int8_t RS, int8_t RST = -1);
59 #if !defined(ESP8266)
60  Adafruit_ST7796S(SPIClass *spiClass, int8_t CS, int8_t RS, int8_t RST);
61 #endif
62 
63  void init(uint16_t width = ST7796S_TFTWIDTH,
64  uint16_t height = ST7796S_TFTHEIGHT, uint8_t rowOffset = 0,
65  uint8_t colOffset = 0, ST7796S_ColorOrder colorOrder = ST7796S_RGB);
66 
67  void setRotation(uint8_t r);
68 
69 private:
70  ST7796S_ColorOrder _colorOrder;
71  uint16_t windowWidth, windowHeight;
72 };
73 
74 #endif
Adafruit_ST7796S(int8_t CS, int8_t RS, int8_t MOSI, int8_t SCLK, int8_t RST=-1)
Constructor with software SPI.
Definition: Adafruit_ST7796S.cpp:81
Adafruit driver for the ST7796S TFT display.
Definition: Adafruit_ST7796S.h:54
void init(uint16_t width=ST7796S_TFTWIDTH, uint16_t height=ST7796S_TFTHEIGHT, uint8_t rowOffset=0, uint8_t colOffset=0, ST7796S_ColorOrder colorOrder=ST7796S_RGB)
Initialize the display.
Definition: Adafruit_ST7796S.cpp:117
Subclass of SPITFT for ST77xx displays (lots in common!)
Definition: Adafruit_ST77xx.h:89
void setRotation(uint8_t r)
Set the display rotation.
Definition: Adafruit_ST7796S.cpp:139