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_st7735.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 InterfaceST7735: public I
44 {
45 public:
53  template <typename... Args>
54  InterfaceST7735(NanoDisplayBase<InterfaceST7735<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 setRgbMode(uint8_t mode);
135 
136 private:
137  const int8_t m_dc = -1;
139  uint8_t m_rotation = 0x00;
140  uint8_t m_rgb_bit = 0b00000000;
141  lcdint_t m_offset_x = 0x00;
142  lcdint_t m_offset_y = 0x00;
143 };
147 template <typename I> class DisplayST7735x16: public NanoDisplayOps<NanoDisplayOps16<I>, I>
148 {
149 public:
156  DisplayST7735x16(I &intf, int8_t rstPin)
157  : NanoDisplayOps<NanoDisplayOps16<I>, I>(intf)
158  , m_rstPin(rstPin)
159  {
160  }
161 
162 protected:
163  int8_t m_rstPin;
164 
168  void beginDisplay();
169 
173  void endDisplay();
174 };
175 
179 template <typename I> class DisplayST7735_128x128x16: public DisplayST7735x16<I>
180 {
181 public:
188  DisplayST7735_128x128x16(I &intf, int8_t rstPin)
189  : DisplayST7735x16<I>(intf, rstPin)
190  {
191  }
192 
193 protected:
197  void beginController();
198 
202  void endController();
203 };
204 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
205 
208 class DisplayST7735_128x128x16_SPI: public DisplayST7735_128x128x16<InterfaceST7735<PlatformSpi>>
209 {
210 public:
218  explicit DisplayST7735_128x128x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
219  : DisplayST7735_128x128x16(m_spi, rstPin)
220  , m_spi(*this, config.dc,
222  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(8000000), config.scl, config.sda})
223  {
224  }
225 
229  void begin() override;
230 
234  void end() override;
235 
236 private:
238 };
239 #endif
240 
245 template <typename I> class DisplayST7735_128x128x16_CustomSPI: public DisplayST7735_128x128x16<InterfaceST7735<I>>
246 {
247 public:
256  template <typename... Args>
257  DisplayST7735_128x128x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
258  : DisplayST7735_128x128x16<InterfaceST7735<I>>(m_spi, rstPin)
259  , m_spi(*this, dcPin, data...)
260  {
261  }
262 
266  void begin() override
267  {
268  m_spi.begin();
270  }
271 
275  void end() override
276  {
278  m_spi.end();
279  }
280 
281 private:
282  InterfaceST7735<I> m_spi;
283 };
287 template <typename I> class DisplayST7735_80x160x16: public DisplayST7735x16<I>
288 {
289 public:
296  DisplayST7735_80x160x16(I &intf, int8_t rstPin)
297  : DisplayST7735x16<I>(intf, rstPin)
298  {
299  }
300 
301 protected:
305  void beginController();
306 
310  void endController();
311 };
312 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
313 
316 class DisplayST7735_80x160x16_SPI: public DisplayST7735_80x160x16<InterfaceST7735<PlatformSpi>>
317 {
318 public:
326  explicit DisplayST7735_80x160x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
327  : DisplayST7735_80x160x16(m_spi, rstPin)
328  , m_spi(*this, config.dc,
330  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(8000000), config.scl, config.sda})
331  {
332  }
333 
337  void begin() override;
338 
342  void end() override;
343 
344 private:
346 };
347 #endif
348 
353 template <typename I> class DisplayST7735_80x160x16_CustomSPI: public DisplayST7735_80x160x16<InterfaceST7735<I>>
354 {
355 public:
364  template <typename... Args>
365  DisplayST7735_80x160x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
366  : DisplayST7735_80x160x16<InterfaceST7735<I>>(m_spi, rstPin)
367  , m_spi(*this, dcPin, data...)
368  {
369  }
370 
374  void begin() override
375  {
376  m_spi.begin();
377  DisplayST7735_80x160x16<InterfaceST7735<I>>::beginController();
378  }
379 
383  void end() override
384  {
386  m_spi.end();
387  }
388 
389 private:
390  InterfaceST7735<I> m_spi;
391 };
395 template <typename I> class DisplayST7735_128x160x16: public DisplayST7735x16<I>
396 {
397 public:
404  DisplayST7735_128x160x16(I &intf, int8_t rstPin)
405  : DisplayST7735x16<I>(intf, rstPin)
406  {
407  }
408 
409 protected:
413  void beginController();
414 
418  void endController();
419 };
420 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
421 
424 class DisplayST7735_128x160x16_SPI: public DisplayST7735_128x160x16<InterfaceST7735<PlatformSpi>>
425 {
426 public:
434  explicit DisplayST7735_128x160x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
435  : DisplayST7735_128x160x16(m_spi, rstPin)
436  , m_spi(*this, config.dc,
438  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(8000000), config.scl, config.sda})
439  {
440  }
441 
445  void begin() override;
446 
450  void end() override;
451 
452 private:
454 };
455 #endif
456 
461 template <typename I> class DisplayST7735_128x160x16_CustomSPI: public DisplayST7735_128x160x16<InterfaceST7735<I>>
462 {
463 public:
472  template <typename... Args>
473  DisplayST7735_128x160x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
474  : DisplayST7735_128x160x16<InterfaceST7735<I>>(m_spi, rstPin)
475  , m_spi(*this, dcPin, data...)
476  {
477  }
478 
482  void begin() override
483  {
484  m_spi.begin();
486  }
487 
491  void end() override
492  {
494  m_spi.end();
495  }
496 
497 private:
498  InterfaceST7735<I> m_spi;
499 };
500 #include "lcd_st7735.inl"
501 
void begin() override
Initializes ST7735 lcd in 16-bit mode.
Definition: lcd_st7735.h:482
void endBlock()
Closes data send operation to lcd display.
Definition: lcd_st7735.inl:71
void end() override
Closes connection to display.
Definition: lcd_st7735.h:275
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
global lcd settings
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_st7735.h:163
DisplayST7735_128x160x16(I &intf, int8_t rstPin)
Creates instance of ST7735 128x160x16 controller class for 16-bit mode.
Definition: lcd_st7735.h:404
void setDataMode(uint8_t mode)
Enables either data or command mode on SPI bus.
Definition: lcd_st7735.inl:76
void commandStart()
Starts communication with LCD display in command mode.
Definition: lcd_st7735.inl:84
int8_t lcdint_t
internal int type, used by the library.
Definition: canvas_types.h:77
Class implements basic functions for 16-bit mode of ST7735-based displays.
Definition: lcd_st7735.h:147
SSD1306 HAL IO communication functions.
Template class implements ST7735 80x160x16 lcd display in 16 bit mode over custom SPI implementation ...
Definition: lcd_st7735.h:353
Class implements basic functions for 16-bit mode of ST7735-based displays.
Definition: lcd_st7735.h:395
void setOffset(lcdint_t ox, lcdint_t oy)
Sets display offset in GDRAM memory.
Definition: lcd_st7735.inl:130
void setRotation(uint8_t rotation)
Sets screen orientation (rotation)
Definition: lcd_st7735.inl:93
void begin() override
Initializes ST7735 lcd in 16-bit mode.
Definition: lcd_st7735.h:266
void end() override
Closes connection to display.
Definition: lcd_st7735.h:383
int8_t dc
Data command control pin number.
Definition: interface.h:102
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_st7735.inl:35
Template class implements ST7735 128x160x16 lcd display in 16 bit mode over custom SPI implementation...
Definition: lcd_st7735.h:461
Class implements basic functions for 16-bit mode of ST7735-based displays.
Definition: lcd_st7735.h:179
DisplayST7735_80x160x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 80x160x16 lcd display over spi (based on ST7735 controller): 16-bit mode.
Definition: lcd_st7735.h:365
InterfaceST7735(NanoDisplayBase< InterfaceST7735< I >> &base, int8_t dc, Args &&... data)
Creates instance of interface to LCD display.
Definition: lcd_st7735.h:54
DisplayST7735_128x128x16(I &intf, int8_t rstPin)
Creates instance of ST7735 128x128x16 controller class for 16-bit mode.
Definition: lcd_st7735.h:188
void setRgbMode(uint8_t mode)
Sets RGB mode used by display controller.
Definition: lcd_st7735.inl:144
DisplayST7735_128x128x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 128x128x16 lcd display over spi (based on ST7735 controller): 16-bit mode.
Definition: lcd_st7735.h:257
DisplayST7735_80x160x16(I &intf, int8_t rstPin)
Creates instance of ST7735 80x160x16 controller class for 16-bit mode.
Definition: lcd_st7735.h:296
DisplayST7735x16(I &intf, int8_t rstPin)
Creates instance of ST7735 controller class for 16-bit mode.
Definition: lcd_st7735.h:156
Class implements interface functions to ST7735 displays.
Definition: lcd_st7735.h:43
DisplayST7735_128x160x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 128x160x16 lcd display over spi (based on ST7735 controller): 16-bit mode.
Definition: lcd_st7735.h:473
NanoCanvasOps provides operations for drawing in memory buffer.
Definition: display.h:978
Class implements basic display operations for the library: It stores reference to communication inter...
Definition: display_base.h:55
void begin() override
Initializes ST7735 lcd in 16-bit mode.
Definition: lcd_st7735.h:374
NanoDisplayOps16 is template class for 16-bit operations.
Definition: display.h:740
void nextBlock()
Switches to the start of next RAM page for the block, specified by startBlock().
Definition: lcd_st7735.inl:66
Class implements basic functions for 16-bit mode of ST7735-based displays.
Definition: lcd_st7735.h:287
void end() override
Closes connection to display.
Definition: lcd_st7735.h:491
Template class implements ST7735 128x128x16 lcd display in 16 bit mode over custom SPI implementation...
Definition: lcd_st7735.h:245