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_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 
109  void setRotation(uint8_t rotation);
110 
121  void setOffset(lcdint_t ox, lcdint_t oy);
122 
129  void setRgbMode(uint8_t mode);
130 
131 private:
132  const int8_t m_dc = -1;
134  uint8_t m_rotation = 0x00;
135  uint8_t m_rgb_bit = 0b00000000;
136  lcdint_t m_offset_x = 0x00;
137  lcdint_t m_offset_y = 0x00;
138 };
142 template <typename I> class DisplayST7735x16: public NanoDisplayOps<NanoDisplayOps16<I>, I>
143 {
144 public:
151  DisplayST7735x16(I &intf, int8_t rstPin)
152  : NanoDisplayOps<NanoDisplayOps16<I>, I>(intf)
153  , m_rstPin(rstPin)
154  {
155  }
156 
157 protected:
158  int8_t m_rstPin;
159 
163  void beginDisplay();
164 
168  void endDisplay();
169 };
170 
174 template <typename I> class DisplayST7735_128x128x16: public DisplayST7735x16<I>
175 {
176 public:
183  DisplayST7735_128x128x16(I &intf, int8_t rstPin)
184  : DisplayST7735x16<I>(intf, rstPin)
185  {
186  }
187 
188 protected:
192  void beginController();
193 
197  void endController();
198 };
199 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
200 
203 class DisplayST7735_128x128x16_SPI: public DisplayST7735_128x128x16<InterfaceST7735<PlatformSpi>>
204 {
205 public:
213  explicit DisplayST7735_128x128x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
214  : DisplayST7735_128x128x16(m_spi, rstPin)
215  , m_spi(*this, config.dc,
217  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(8000000), config.scl, config.sda})
218  {
219  }
220 
224  void begin() override;
225 
229  void end() override;
230 
231 private:
233 };
234 #endif
235 
240 template <typename I> class DisplayST7735_128x128x16_CustomSPI: public DisplayST7735_128x128x16<InterfaceST7735<I>>
241 {
242 public:
251  template <typename... Args>
252  DisplayST7735_128x128x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
253  : DisplayST7735_128x128x16<InterfaceST7735<I>>(m_spi, rstPin)
254  , m_spi(*this, dcPin, data...)
255  {
256  }
257 
261  void begin() override
262  {
263  m_spi.begin();
265  }
266 
270  void end() override
271  {
273  m_spi.end();
274  }
275 
276 private:
277  InterfaceST7735<I> m_spi;
278 };
282 template <typename I> class DisplayST7735_80x160x16: public DisplayST7735x16<I>
283 {
284 public:
291  DisplayST7735_80x160x16(I &intf, int8_t rstPin)
292  : DisplayST7735x16<I>(intf, rstPin)
293  {
294  }
295 
296 protected:
300  void beginController();
301 
305  void endController();
306 };
307 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
308 
311 class DisplayST7735_80x160x16_SPI: public DisplayST7735_80x160x16<InterfaceST7735<PlatformSpi>>
312 {
313 public:
321  explicit DisplayST7735_80x160x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
322  : DisplayST7735_80x160x16(m_spi, rstPin)
323  , m_spi(*this, config.dc,
325  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(8000000), config.scl, config.sda})
326  {
327  }
328 
332  void begin() override;
333 
337  void end() override;
338 
339 private:
341 };
342 #endif
343 
348 template <typename I> class DisplayST7735_80x160x16_CustomSPI: public DisplayST7735_80x160x16<InterfaceST7735<I>>
349 {
350 public:
359  template <typename... Args>
360  DisplayST7735_80x160x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
361  : DisplayST7735_80x160x16<InterfaceST7735<I>>(m_spi, rstPin)
362  , m_spi(*this, dcPin, data...)
363  {
364  }
365 
369  void begin() override
370  {
371  m_spi.begin();
372  DisplayST7735_80x160x16<InterfaceST7735<I>>::beginController();
373  }
374 
378  void end() override
379  {
381  m_spi.end();
382  }
383 
384 private:
385  InterfaceST7735<I> m_spi;
386 };
390 template <typename I> class DisplayST7735_128x160x16: public DisplayST7735x16<I>
391 {
392 public:
399  DisplayST7735_128x160x16(I &intf, int8_t rstPin)
400  : DisplayST7735x16<I>(intf, rstPin)
401  {
402  }
403 
404 protected:
408  void beginController();
409 
413  void endController();
414 };
415 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
416 
419 class DisplayST7735_128x160x16_SPI: public DisplayST7735_128x160x16<InterfaceST7735<PlatformSpi>>
420 {
421 public:
429  explicit DisplayST7735_128x160x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
430  : DisplayST7735_128x160x16(m_spi, rstPin)
431  , m_spi(*this, config.dc,
433  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(8000000), config.scl, config.sda})
434  {
435  }
436 
440  void begin() override;
441 
445  void end() override;
446 
447 private:
449 };
450 #endif
451 
456 template <typename I> class DisplayST7735_128x160x16_CustomSPI: public DisplayST7735_128x160x16<InterfaceST7735<I>>
457 {
458 public:
467  template <typename... Args>
468  DisplayST7735_128x160x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
469  : DisplayST7735_128x160x16<InterfaceST7735<I>>(m_spi, rstPin)
470  , m_spi(*this, dcPin, data...)
471  {
472  }
473 
477  void begin() override
478  {
479  m_spi.begin();
481  }
482 
486  void end() override
487  {
489  m_spi.end();
490  }
491 
492 private:
493  InterfaceST7735<I> m_spi;
494 };
495 #include "lcd_st7735.inl"
496 
uint8_t lcduint_t
Definition: canvas_types.h:79
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_st7735.h:158
DisplayST7735_128x160x16(I &intf, int8_t rstPin)
Definition: lcd_st7735.h:399
void setDataMode(uint8_t mode)
Definition: lcd_st7735.inl:76
void commandStart()
Definition: lcd_st7735.inl:84
int8_t lcdint_t
Definition: canvas_types.h:77
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 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
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:360
InterfaceST7735(NanoDisplayBase< InterfaceST7735< I >> &base, int8_t dc, Args &&... data)
Definition: lcd_st7735.h:54
DisplayST7735_128x128x16(I &intf, int8_t rstPin)
Definition: lcd_st7735.h:183
void setRgbMode(uint8_t mode)
Sets RGB mode used by dispay 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:252
DisplayST7735_80x160x16(I &intf, int8_t rstPin)
Definition: lcd_st7735.h:291
DisplayST7735x16(I &intf, int8_t rstPin)
Definition: lcd_st7735.h:151
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:468