LCDGFX LCD display driver  1.2.0
Lightweight graphics library for SSD1306, SSD1325, SSD1327, SSD1331, SSD1351, SH1106, SH1107, IL9163, ST7735, ST7789, ILI9341, PCD8544 displays over I2C/SPI
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 
114  void setRotation(uint8_t rotation);
115 
126  void setOffset(lcdint_t ox, lcdint_t oy);
127 
134  void normalMode();
135 
142  void invertMode();
143 
144 private:
145  const int8_t m_dc = -1;
147  uint8_t m_rotation = 0x00;
148  static const uint8_t m_rgb_bit = 0b00001000;
149  lcdint_t m_offset_x = 0x34;
150  lcdint_t m_offset_y = 0x28;
151 };
155 template <typename I> class DisplayST7789x16: public NanoDisplayOps<NanoDisplayOps16<I>, I>
156 {
157 public:
164  DisplayST7789x16(I &intf, int8_t rstPin)
165  : NanoDisplayOps<NanoDisplayOps16<I>, I>(intf)
166  , m_rstPin(rstPin)
167  {
168  }
169 
170 protected:
171  int8_t m_rstPin;
172 
176  void beginDisplay();
177 
181  void endDisplay();
182 };
183 
187 template <typename I> class DisplayST7789_135x240x16: public DisplayST7789x16<I>
188 {
189 public:
196  DisplayST7789_135x240x16(I &intf, int8_t rstPin)
197  : DisplayST7789x16<I>(intf, rstPin)
198  {
199  }
200 
201 protected:
205  void beginController();
206 
210  void endController();
211 };
212 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
213 
216 class DisplayST7789_135x240x16_SPI: public DisplayST7789_135x240x16<InterfaceST7789<PlatformSpi>>
217 {
218 public:
226  explicit DisplayST7789_135x240x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
227  : DisplayST7789_135x240x16(m_spi, rstPin)
228  , m_spi(*this, config.dc,
230  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(40000000), config.scl, config.sda})
231  {
232  }
233 
237  void begin() override;
238 
242  void end() override;
243 
244 private:
246 };
247 #endif
248 
253 template <typename I> class DisplayST7789_135x240x16_CustomSPI: public DisplayST7789_135x240x16<InterfaceST7789<I>>
254 {
255 public:
264  template <typename... Args>
265  DisplayST7789_135x240x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
266  : DisplayST7789_135x240x16<InterfaceST7789<I>>(m_spi, rstPin)
267  , m_spi(*this, dcPin, data...)
268  {
269  }
270 
274  void begin() override
275  {
276  m_spi.begin();
278  }
279 
283  void end() override
284  {
286  m_spi.end();
287  }
288 
289 private:
290  InterfaceST7789<I> m_spi;
291 };
295 template <typename I> class DisplayST7789_240x240x16: public DisplayST7789x16<I>
296 {
297 public:
304  DisplayST7789_240x240x16(I &intf, int8_t rstPin)
305  : DisplayST7789x16<I>(intf, rstPin)
306  {
307  }
308 
309 protected:
313  void beginController();
314 
318  void endController();
319 };
320 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
321 
324 class DisplayST7789_240x240x16_SPI: public DisplayST7789_240x240x16<InterfaceST7789<PlatformSpi>>
325 {
326 public:
334  explicit DisplayST7789_240x240x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
335  : DisplayST7789_240x240x16(m_spi, rstPin)
336  , m_spi(*this, config.dc,
338  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(40000000), config.scl, config.sda})
339  {
340  }
341 
345  void begin() override;
346 
350  void end() override;
351 
352 private:
354 };
355 #endif
356 
361 template <typename I> class DisplayST7789_240x240x16_CustomSPI: public DisplayST7789_240x240x16<InterfaceST7789<I>>
362 {
363 public:
372  template <typename... Args>
373  DisplayST7789_240x240x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
374  : DisplayST7789_240x240x16<InterfaceST7789<I>>(m_spi, rstPin)
375  , m_spi(*this, dcPin, data...)
376  {
377  }
378 
382  void begin() override
383  {
384  m_spi.begin();
386  }
387 
391  void end() override
392  {
394  m_spi.end();
395  }
396 
397 private:
398  InterfaceST7789<I> m_spi;
399 };
403 template <typename I> class DisplayST7789_170x320x16: public DisplayST7789x16<I>
404 {
405 public:
412  DisplayST7789_170x320x16(I &intf, int8_t rstPin)
413  : DisplayST7789x16<I>(intf, rstPin)
414  {
415  }
416 
417 protected:
421  void beginController();
422 
426  void endController();
427 };
428 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
429 
432 class DisplayST7789_170x320x16_SPI: public DisplayST7789_170x320x16<InterfaceST7789<PlatformSpi>>
433 {
434 public:
442  explicit DisplayST7789_170x320x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
443  : DisplayST7789_170x320x16(m_spi, rstPin)
444  , m_spi(*this, config.dc,
446  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(40000000), config.scl, config.sda})
447  {
448  }
449 
453  void begin() override;
454 
458  void end() override;
459 
460 private:
462 };
463 #endif
464 
469 template <typename I> class DisplayST7789_170x320x16_CustomSPI: public DisplayST7789_170x320x16<InterfaceST7789<I>>
470 {
471 public:
480  template <typename... Args>
481  DisplayST7789_170x320x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
482  : DisplayST7789_170x320x16<InterfaceST7789<I>>(m_spi, rstPin)
483  , m_spi(*this, dcPin, data...)
484  {
485  }
486 
490  void begin() override
491  {
492  m_spi.begin();
494  }
495 
499  void end() override
500  {
502  m_spi.end();
503  }
504 
505 private:
506  InterfaceST7789<I> m_spi;
507 };
508 #include "lcd_st7789.inl"
509 
void nextBlock()
Switches to the start of next RAM page for the block, specified by startBlock().
Definition: lcd_st7789.inl:70
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
Structure describes spi platform configuration.
Definition: interface.h:80
uint8_t lcduint_t
internal int type, used by the library.
Definition: canvas_types.h:79
DisplayST7789_135x240x16(I &intf, int8_t rstPin)
Creates instance of ST7789 135x240x16 controller class for 16-bit mode.
Definition: lcd_st7789.h:196
global lcd settings
void setRotation(uint8_t rotation)
Sets screen orientation (rotation)
Definition: lcd_st7789.inl:97
DisplayST7789_170x320x16(I &intf, int8_t rstPin)
Creates instance of ST7789 170x320x16 controller class for 16-bit mode.
Definition: lcd_st7789.h:412
void setDataMode(uint8_t mode)
Enables either data or command mode on SPI bus.
Definition: lcd_st7789.inl:80
Class implements basic functions for 16-bit mode of ST7789-based displays.
Definition: lcd_st7789.h:155
int8_t lcdint_t
internal int type, used by the library.
Definition: canvas_types.h:77
InterfaceST7789(NanoDisplayBase< InterfaceST7789< I >> &base, int8_t dc, Args &&... data)
Creates instance of interface to LCD display.
Definition: lcd_st7789.h:54
SSD1306 HAL IO communication functions.
void end() override
Closes connection to display.
Definition: lcd_st7789.h:283
int8_t dc
Data command control pin number.
Definition: interface.h:102
void begin() override
Initializes ST7789 lcd in 16-bit mode.
Definition: lcd_st7789.h:274
void begin() override
Initializes ST7789 lcd in 16-bit mode.
Definition: lcd_st7789.h:382
Template class implements ST7789 135x240x16 lcd display in 16 bit mode over custom SPI implementation...
Definition: lcd_st7789.h:253
Class implements basic functions for 16-bit mode of ST7789-based displays.
Definition: lcd_st7789.h:403
Template class implements ST7789 170x320x16 lcd display in 16 bit mode over custom SPI implementation...
Definition: lcd_st7789.h:469
DisplayST7789x16(I &intf, int8_t rstPin)
Creates instance of ST7789 controller class for 16-bit mode.
Definition: lcd_st7789.h:164
Class implements interface functions to ST7789 displays.
Definition: lcd_st7789.h:43
DisplayST7789_170x320x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 170x320x16 lcd display over spi (based on ST7789 controller): 16-bit mode.
Definition: lcd_st7789.h:481
void end() override
Closes connection to display.
Definition: lcd_st7789.h:391
void begin() override
Initializes ST7789 lcd in 16-bit mode.
Definition: lcd_st7789.h:490
Template class implements ST7789 240x240x16 lcd display in 16 bit mode over custom SPI implementation...
Definition: lcd_st7789.h:361
void endBlock()
Closes data send operation to lcd display.
Definition: lcd_st7789.inl:75
Class implements basic functions for 16-bit mode of ST7789-based displays.
Definition: lcd_st7789.h:295
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:373
void invertMode()
Switches display to inverted mode (sends INVON command).
Definition: lcd_st7789.inl:180
void setOffset(lcdint_t ox, lcdint_t oy)
Sets display offset in GDRAM memory.
Definition: lcd_st7789.inl:158
void end() override
Closes connection to display.
Definition: lcd_st7789.h:499
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_st7789.h:171
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:265
void normalMode()
Switches display to normal mode (sends INVOFF command).
Definition: lcd_st7789.inl:172
NanoCanvasOps provides operations for drawing in memory buffer.
Definition: display.h:978
DisplayST7789_240x240x16(I &intf, int8_t rstPin)
Creates instance of ST7789 240x240x16 controller class for 16-bit mode.
Definition: lcd_st7789.h:304
Class implements basic display operations for the library: It stores reference to communication inter...
Definition: display_base.h:55
NanoDisplayOps16 is template class for 16-bit operations.
Definition: display.h:740
void commandStart()
Starts communication with LCD display in command mode.
Definition: lcd_st7789.inl:88
Class implements basic functions for 16-bit mode of ST7789-based displays.
Definition: lcd_st7789.h:187