LCDGFX LCD display driver  1.1.5
This library is developed to control SSD1306/SSD1325/SSD1327/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
lcd_st7789.h
Go to the documentation of this file.
1 /*
2  MIT License
3 
4  Copyright 2019-2022 (C) Alexey Dynda
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23 */
24 /* !!! THIS FILE IS AUTO GENERATED !!! */
29 #pragma once
30 
31 #include "lcd_hal/io.h"
32 #include "v2/lcd/lcd_common.h"
33 #include "v2/lcd/base/display.h"
34 
43 template <typename I> class InterfaceST7789: public I
44 {
45 public:
53  template <typename... Args>
54  InterfaceST7789(NanoDisplayBase<InterfaceST7789<I>> &base, int8_t dc, Args &&... data)
55  : I(data...)
56  , m_dc(dc)
57  , m_base(base)
58  {
59  }
60 
77 
84  void nextBlock();
85 
89  void endBlock();
90 
95  void setDataMode(uint8_t mode);
96 
101  void commandStart();
102 
109  void setRotation(uint8_t rotation);
110 
121  void setOffset(lcdint_t ox, lcdint_t oy);
122 
123 private:
124  const int8_t m_dc = -1;
126  uint8_t m_rotation = 0x00;
127  static const uint8_t m_rgb_bit = 0b00001000;
128  lcdint_t m_offset_x = 0x34;
129  lcdint_t m_offset_y = 0x28;
130 };
134 template <typename I> class DisplayST7789x16: public NanoDisplayOps<NanoDisplayOps16<I>, I>
135 {
136 public:
143  DisplayST7789x16(I &intf, int8_t rstPin)
144  : NanoDisplayOps<NanoDisplayOps16<I>, I>(intf)
145  , m_rstPin(rstPin)
146  {
147  }
148 
149 protected:
150  int8_t m_rstPin;
151 
155  void beginDisplay();
156 
160  void endDisplay();
161 };
162 
166 template <typename I> class DisplayST7789_135x240x16: public DisplayST7789x16<I>
167 {
168 public:
175  DisplayST7789_135x240x16(I &intf, int8_t rstPin)
176  : DisplayST7789x16<I>(intf, rstPin)
177  {
178  }
179 
180 protected:
184  void beginController();
185 
189  void endController();
190 };
194 class DisplayST7789_135x240x16_SPI: public DisplayST7789_135x240x16<InterfaceST7789<PlatformSpi>>
195 {
196 public:
204  explicit DisplayST7789_135x240x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0, -1, -1})
205  : DisplayST7789_135x240x16(m_spi, rstPin)
206  , m_spi(*this, config.dc,
208  config.busId, {config.cs}, config.dc, config.frequency ?: 40000000, config.scl, config.sda})
209  {
210  }
211 
215  void begin() override;
216 
220  void end() override;
221 
222 private:
224 };
225 
230 template <typename I> class DisplayST7789_135x240x16_CustomSPI: public DisplayST7789_135x240x16<InterfaceST7789<I>>
231 {
232 public:
241  template <typename... Args>
242  DisplayST7789_135x240x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
243  : DisplayST7789_135x240x16<InterfaceST7789<I>>(m_spi, rstPin)
244  , m_spi(*this, dcPin, data...)
245  {
246  }
247 
251  void begin() override
252  {
253  m_spi.begin();
255  }
256 
260  void end() override
261  {
263  m_spi.end();
264  }
265 
266 private:
267  InterfaceST7789<I> m_spi;
268 };
272 template <typename I> class DisplayST7789_240x240x16: public DisplayST7789x16<I>
273 {
274 public:
281  DisplayST7789_240x240x16(I &intf, int8_t rstPin)
282  : DisplayST7789x16<I>(intf, rstPin)
283  {
284  }
285 
286 protected:
290  void beginController();
291 
295  void endController();
296 };
300 class DisplayST7789_240x240x16_SPI: public DisplayST7789_240x240x16<InterfaceST7789<PlatformSpi>>
301 {
302 public:
310  explicit DisplayST7789_240x240x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0, -1, -1})
311  : DisplayST7789_240x240x16(m_spi, rstPin)
312  , m_spi(*this, config.dc,
314  config.busId, {config.cs}, config.dc, config.frequency ?: 40000000, config.scl, config.sda})
315  {
316  }
317 
321  void begin() override;
322 
326  void end() override;
327 
328 private:
330 };
331 
336 template <typename I> class DisplayST7789_240x240x16_CustomSPI: public DisplayST7789_240x240x16<InterfaceST7789<I>>
337 {
338 public:
347  template <typename... Args>
348  DisplayST7789_240x240x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
349  : DisplayST7789_240x240x16<InterfaceST7789<I>>(m_spi, rstPin)
350  , m_spi(*this, dcPin, data...)
351  {
352  }
353 
357  void begin() override
358  {
359  m_spi.begin();
361  }
362 
366  void end() override
367  {
369  m_spi.end();
370  }
371 
372 private:
373  InterfaceST7789<I> m_spi;
374 };
375 #include "lcd_st7789.inl"
376 
void startBlock(lcduint_t x, lcduint_t y, lcduint_t w)
Sets block in RAM of lcd display controller to write data to.
Definition: lcd_st7789.inl:35
uint8_t lcduint_t
Definition: canvas_types.h:79
DisplayST7789_135x240x16(I &intf, int8_t rstPin)
Definition: lcd_st7789.h:175
void setRotation(uint8_t rotation)
Sets screen orientation (rotation)
Definition: lcd_st7789.inl:97
void setDataMode(uint8_t mode)
Definition: lcd_st7789.inl:80
DisplayST7789_240x240x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config={-1, {-1}, -1, 0, -1, -1})
Inits 240x240x16 lcd display over spi (based on ST7789 controller): 16-bit mode.
Definition: lcd_st7789.h:310
int8_t lcdint_t
Definition: canvas_types.h:77
InterfaceST7789(NanoDisplayBase< InterfaceST7789< I >> &base, int8_t dc, Args &&... data)
Definition: lcd_st7789.h:54
DisplayST7789x16(I &intf, int8_t rstPin)
Definition: lcd_st7789.h:143
DisplayST7789_240x240x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 240x240x16 lcd display over spi (based on ST7789 controller): 16-bit mode.
Definition: lcd_st7789.h:348
void setOffset(lcdint_t ox, lcdint_t oy)
Sets display offset in GDRAM memory.
Definition: lcd_st7789.inl:158
DisplayST7789_135x240x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config={-1, {-1}, -1, 0, -1, -1})
Inits 135x240x16 lcd display over spi (based on ST7789 controller): 16-bit mode.
Definition: lcd_st7789.h:204
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_st7789.h:150
DisplayST7789_135x240x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 135x240x16 lcd display over spi (based on ST7789 controller): 16-bit mode.
Definition: lcd_st7789.h:242
DisplayST7789_240x240x16(I &intf, int8_t rstPin)
Definition: lcd_st7789.h:281
void commandStart()
Definition: lcd_st7789.inl:88