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 };
191 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
192 
195 class DisplayST7789_135x240x16_SPI: public DisplayST7789_135x240x16<InterfaceST7789<PlatformSpi>>
196 {
197 public:
205  explicit DisplayST7789_135x240x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
206  : DisplayST7789_135x240x16(m_spi, rstPin)
207  , m_spi(*this, config.dc,
209  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(40000000), config.scl, config.sda})
210  {
211  }
212 
216  void begin() override;
217 
221  void end() override;
222 
223 private:
225 };
226 #endif
227 
232 template <typename I> class DisplayST7789_135x240x16_CustomSPI: public DisplayST7789_135x240x16<InterfaceST7789<I>>
233 {
234 public:
243  template <typename... Args>
244  DisplayST7789_135x240x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
245  : DisplayST7789_135x240x16<InterfaceST7789<I>>(m_spi, rstPin)
246  , m_spi(*this, dcPin, data...)
247  {
248  }
249 
253  void begin() override
254  {
255  m_spi.begin();
257  }
258 
262  void end() override
263  {
265  m_spi.end();
266  }
267 
268 private:
269  InterfaceST7789<I> m_spi;
270 };
274 template <typename I> class DisplayST7789_240x240x16: public DisplayST7789x16<I>
275 {
276 public:
283  DisplayST7789_240x240x16(I &intf, int8_t rstPin)
284  : DisplayST7789x16<I>(intf, rstPin)
285  {
286  }
287 
288 protected:
292  void beginController();
293 
297  void endController();
298 };
299 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
300 
303 class DisplayST7789_240x240x16_SPI: public DisplayST7789_240x240x16<InterfaceST7789<PlatformSpi>>
304 {
305 public:
313  explicit DisplayST7789_240x240x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
314  : DisplayST7789_240x240x16(m_spi, rstPin)
315  , m_spi(*this, config.dc,
317  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(40000000), config.scl, config.sda})
318  {
319  }
320 
324  void begin() override;
325 
329  void end() override;
330 
331 private:
333 };
334 #endif
335 
340 template <typename I> class DisplayST7789_240x240x16_CustomSPI: public DisplayST7789_240x240x16<InterfaceST7789<I>>
341 {
342 public:
351  template <typename... Args>
352  DisplayST7789_240x240x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
353  : DisplayST7789_240x240x16<InterfaceST7789<I>>(m_spi, rstPin)
354  , m_spi(*this, dcPin, data...)
355  {
356  }
357 
361  void begin() override
362  {
363  m_spi.begin();
365  }
366 
370  void end() override
371  {
373  m_spi.end();
374  }
375 
376 private:
377  InterfaceST7789<I> m_spi;
378 };
382 template <typename I> class DisplayST7789_170x320x16: public DisplayST7789x16<I>
383 {
384 public:
391  DisplayST7789_170x320x16(I &intf, int8_t rstPin)
392  : DisplayST7789x16<I>(intf, rstPin)
393  {
394  }
395 
396 protected:
400  void beginController();
401 
405  void endController();
406 };
407 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
408 
411 class DisplayST7789_170x320x16_SPI: public DisplayST7789_170x320x16<InterfaceST7789<PlatformSpi>>
412 {
413 public:
421  explicit DisplayST7789_170x320x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
422  : DisplayST7789_170x320x16(m_spi, rstPin)
423  , m_spi(*this, config.dc,
425  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(40000000), config.scl, config.sda})
426  {
427  }
428 
432  void begin() override;
433 
437  void end() override;
438 
439 private:
441 };
442 #endif
443 
448 template <typename I> class DisplayST7789_170x320x16_CustomSPI: public DisplayST7789_170x320x16<InterfaceST7789<I>>
449 {
450 public:
459  template <typename... Args>
460  DisplayST7789_170x320x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
461  : DisplayST7789_170x320x16<InterfaceST7789<I>>(m_spi, rstPin)
462  , m_spi(*this, dcPin, data...)
463  {
464  }
465 
469  void begin() override
470  {
471  m_spi.begin();
473  }
474 
478  void end() override
479  {
481  m_spi.end();
482  }
483 
484 private:
485  InterfaceST7789<I> m_spi;
486 };
487 #include "lcd_st7789.inl"
488 
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
DisplayST7789_170x320x16(I &intf, int8_t rstPin)
Definition: lcd_st7789.h:391
void setDataMode(uint8_t mode)
Definition: lcd_st7789.inl:80
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_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:460
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:352
void setOffset(lcdint_t ox, lcdint_t oy)
Sets display offset in GDRAM memory.
Definition: lcd_st7789.inl:158
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:244
DisplayST7789_240x240x16(I &intf, int8_t rstPin)
Definition: lcd_st7789.h:283
void commandStart()
Definition: lcd_st7789.inl:88