LCDGFX LCD display driver  1.0.2
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 (c) 2019-2020, 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 <class I>
44 class InterfaceST7735: public I
45 {
46 public:
54  template <typename... Args>
55  InterfaceST7735(NanoDisplayBase<InterfaceST7735<I>> &base, int8_t dc, Args&&... data)
56  : I(data...)
57  , m_dc( dc )
58  , m_base(base)
59  {
60  }
61 
78 
85  void nextBlock();
86 
90  void endBlock();
91 
96  void spiDataMode(uint8_t mode);
97 
102  void commandStart();
103 
110  void setRotation(uint8_t rotation);
111 
122  void setOffset(lcdint_t ox, lcdint_t oy);
123 
124 private:
125  const int8_t m_dc = -1;
127 
128  uint8_t m_rotation = 0x00;
129  static const uint8_t m_rgb_bit = 0b00000000;
130 
131  lcdint_t m_offset_x = 0x00;
132  lcdint_t m_offset_y = 0x00;
133 };
134 
135 
139 template <class I>
140 class DisplayST7735x16: public NanoDisplayOps<NanoDisplayOps16<I>,I>
141 {
142 public:
149  DisplayST7735x16(I &intf, int8_t rstPin)
150  : NanoDisplayOps<NanoDisplayOps16<I>, I>(intf)
151  , m_rstPin( rstPin ) { }
152 
153 protected:
154  int8_t m_rstPin;
155 
159  void begin() override;
160 
164  void end() override;
165 };
166 
170 template <class I>
172 {
173 public:
180  DisplayST7735_128x128x16(I &intf, int8_t rstPin)
181  : DisplayST7735x16<I>(intf, rstPin) { }
182 
183 protected:
184 
188  void begin() override;
189 
193  void end() override;
194 };
195 
199 class DisplayST7735_128x128x16_SPI: public DisplayST7735_128x128x16<InterfaceST7735<PlatformSpi>>
200 {
201 public:
209  DisplayST7735_128x128x16_SPI( int8_t rstPin, const SPlatformSpiConfig &config = { -1, { -1 }, -1, 0, -1, -1 } )
210  : DisplayST7735_128x128x16(m_spi, rstPin)
211  , m_spi( *this, config.dc,
212  SPlatformSpiConfig{ config.busId,
213  { config.cs },
214  config.dc,
215  config.frequency ?: 8000000,
216  config.scl,
217  config.sda } ) {}
218 
222  void begin() override;
223 
227  void end() override;
228 
229 private:
231 };
232 
237 template <class 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,
253  data... ) {}
254 
258  void begin() override
259  {
260  m_spi.begin();
262  }
263 
267  void end() override
268  {
270  m_spi.end();
271  }
272 
273 private:
274  InterfaceST7735<I> m_spi;
275 };
279 template <class I>
281 {
282 public:
289  DisplayST7735_128x160x16(I &intf, int8_t rstPin)
290  : DisplayST7735x16<I>(intf, rstPin) { }
291 
292 protected:
293 
297  void begin() override;
298 
302  void end() override;
303 };
304 
308 class DisplayST7735_128x160x16_SPI: public DisplayST7735_128x160x16<InterfaceST7735<PlatformSpi>>
309 {
310 public:
318  DisplayST7735_128x160x16_SPI( int8_t rstPin, const SPlatformSpiConfig &config = { -1, { -1 }, -1, 0, -1, -1 } )
319  : DisplayST7735_128x160x16(m_spi, rstPin)
320  , m_spi( *this, config.dc,
321  SPlatformSpiConfig{ config.busId,
322  { config.cs },
323  config.dc,
324  config.frequency ?: 8000000,
325  config.scl,
326  config.sda } ) {}
327 
331  void begin() override;
332 
336  void end() override;
337 
338 private:
340 };
341 
346 template <class I>
348 {
349 public:
358  template <typename... Args>
359  DisplayST7735_128x160x16_CustomSPI( int8_t rstPin, int8_t dcPin, Args&&... data )
360  : DisplayST7735_128x160x16<InterfaceST7735<I>>(m_spi, rstPin)
361  , m_spi( *this, dcPin,
362  data... ) {}
363 
367  void begin() override
368  {
369  m_spi.begin();
371  }
372 
376  void end() override
377  {
379  m_spi.end();
380  }
381 
382 private:
383  InterfaceST7735<I> m_spi;
384 };
385 #include "lcd_st7735.inl"
386 
uint8_t lcduint_t
Definition: canvas_types.h:81
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:318
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_st7735.h:154
DisplayST7735_128x160x16(I &intf, int8_t rstPin)
Definition: lcd_st7735.h:289
void commandStart()
Definition: lcd_st7735.inl:89
int8_t lcdint_t
Definition: canvas_types.h:79
void setOffset(lcdint_t ox, lcdint_t oy)
Sets display offset in GDRAM memory.
Definition: lcd_st7735.inl:137
void setRotation(uint8_t rotation)
Sets screen orientation (rotation)
Definition: lcd_st7735.inl:99
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:209
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:36
InterfaceST7735(NanoDisplayBase< InterfaceST7735< I >> &base, int8_t dc, Args &&... data)
Definition: lcd_st7735.h:55
DisplayST7735_128x128x16(I &intf, int8_t rstPin)
Definition: lcd_st7735.h:180
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
DisplayST7735x16(I &intf, int8_t rstPin)
Definition: lcd_st7735.h:149
void spiDataMode(uint8_t mode)
Definition: lcd_st7735.inl:80
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:359