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 };
202 class DisplayST7735_128x128x16_SPI: public DisplayST7735_128x128x16<InterfaceST7735<PlatformSpi>>
203 {
204 public:
212  explicit DisplayST7735_128x128x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0, -1, -1})
213  : DisplayST7735_128x128x16(m_spi, rstPin)
214  , m_spi(*this, config.dc,
216  config.busId, {config.cs}, config.dc, config.frequency ?: 8000000, config.scl, config.sda})
217  {
218  }
219 
223  void begin() override;
224 
228  void end() override;
229 
230 private:
232 };
233 
238 template <typename I> class DisplayST7735_128x128x16_CustomSPI: public DisplayST7735_128x128x16<InterfaceST7735<I>>
239 {
240 public:
249  template <typename... Args>
250  DisplayST7735_128x128x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
251  : DisplayST7735_128x128x16<InterfaceST7735<I>>(m_spi, rstPin)
252  , m_spi(*this, dcPin, data...)
253  {
254  }
255 
259  void begin() override
260  {
261  m_spi.begin();
263  }
264 
268  void end() override
269  {
271  m_spi.end();
272  }
273 
274 private:
275  InterfaceST7735<I> m_spi;
276 };
280 template <typename I> class DisplayST7735_80x160x16: public DisplayST7735x16<I>
281 {
282 public:
289  DisplayST7735_80x160x16(I &intf, int8_t rstPin)
290  : DisplayST7735x16<I>(intf, rstPin)
291  {
292  }
293 
294 protected:
298  void beginController();
299 
303  void endController();
304 };
308 class DisplayST7735_80x160x16_SPI: public DisplayST7735_80x160x16<InterfaceST7735<PlatformSpi>>
309 {
310 public:
318  explicit DisplayST7735_80x160x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0, -1, -1})
319  : DisplayST7735_80x160x16(m_spi, rstPin)
320  , m_spi(*this, config.dc,
322  config.busId, {config.cs}, config.dc, config.frequency ?: 8000000, config.scl, config.sda})
323  {
324  }
325 
329  void begin() override;
330 
334  void end() override;
335 
336 private:
338 };
339 
344 template <typename I> class DisplayST7735_80x160x16_CustomSPI: public DisplayST7735_80x160x16<InterfaceST7735<I>>
345 {
346 public:
355  template <typename... Args>
356  DisplayST7735_80x160x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
357  : DisplayST7735_80x160x16<InterfaceST7735<I>>(m_spi, rstPin)
358  , m_spi(*this, dcPin, data...)
359  {
360  }
361 
365  void begin() override
366  {
367  m_spi.begin();
368  DisplayST7735_80x160x16<InterfaceST7735<I>>::beginController();
369  }
370 
374  void end() override
375  {
377  m_spi.end();
378  }
379 
380 private:
381  InterfaceST7735<I> m_spi;
382 };
386 template <typename I> class DisplayST7735_128x160x16: public DisplayST7735x16<I>
387 {
388 public:
395  DisplayST7735_128x160x16(I &intf, int8_t rstPin)
396  : DisplayST7735x16<I>(intf, rstPin)
397  {
398  }
399 
400 protected:
404  void beginController();
405 
409  void endController();
410 };
414 class DisplayST7735_128x160x16_SPI: public DisplayST7735_128x160x16<InterfaceST7735<PlatformSpi>>
415 {
416 public:
424  explicit DisplayST7735_128x160x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0, -1, -1})
425  : DisplayST7735_128x160x16(m_spi, rstPin)
426  , m_spi(*this, config.dc,
428  config.busId, {config.cs}, config.dc, config.frequency ?: 8000000, config.scl, config.sda})
429  {
430  }
431 
435  void begin() override;
436 
440  void end() override;
441 
442 private:
444 };
445 
450 template <typename I> class DisplayST7735_128x160x16_CustomSPI: public DisplayST7735_128x160x16<InterfaceST7735<I>>
451 {
452 public:
461  template <typename... Args>
462  DisplayST7735_128x160x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
463  : DisplayST7735_128x160x16<InterfaceST7735<I>>(m_spi, rstPin)
464  , m_spi(*this, dcPin, data...)
465  {
466  }
467 
471  void begin() override
472  {
473  m_spi.begin();
475  }
476 
480  void end() override
481  {
483  m_spi.end();
484  }
485 
486 private:
487  InterfaceST7735<I> m_spi;
488 };
489 #include "lcd_st7735.inl"
490 
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:395
DisplayST7735_80x160x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config={-1, {-1}, -1, 0, -1, -1})
Inits 80x160x16 lcd display over spi (based on ST7735 controller): 16-bit mode.
Definition: lcd_st7735.h:318
void setDataMode(uint8_t mode)
Definition: lcd_st7735.inl:76
DisplayST7735_128x160x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config={-1, {-1}, -1, 0, -1, -1})
Inits 128x160x16 lcd display over spi (based on ST7735 controller): 16-bit mode.
Definition: lcd_st7735.h:424
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:356
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:250
DisplayST7735_80x160x16(I &intf, int8_t rstPin)
Definition: lcd_st7735.h:289
DisplayST7735x16(I &intf, int8_t rstPin)
Definition: lcd_st7735.h:151
DisplayST7735_128x128x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config={-1, {-1}, -1, 0, -1, -1})
Inits 128x128x16 lcd display over spi (based on ST7735 controller): 16-bit mode.
Definition: lcd_st7735.h:212
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:462