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_ili9341.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 InterfaceILI9341: public I
44 {
45 public:
53  template <typename... Args>
54  InterfaceILI9341(NanoDisplayBase<InterfaceILI9341<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 
125  void rotateOutput(uint8_t rotate);
126 
131  void normalMode();
132 
138  void invertMode();
139 
140 private:
141  const int8_t m_dc = -1;
143  uint8_t m_rotation = 0x00;
144  uint8_t m_rotate_output = 0x00;
145  static const uint8_t m_rgb_bit = 0b00001000;
146 };
150 template <typename I> class DisplayILI9341x16: public NanoDisplayOps<NanoDisplayOps16<I>, I>
151 {
152 public:
159  DisplayILI9341x16(I &intf, int8_t rstPin)
160  : NanoDisplayOps<NanoDisplayOps16<I>, I>(intf)
161  , m_rstPin(rstPin)
162  {
163  }
164 
165 protected:
166  int8_t m_rstPin;
167 
171  void beginDisplay();
172 
176  void endDisplay();
177 };
178 
182 template <typename I> class DisplayILI9341_240x320x16: public DisplayILI9341x16<I>
183 {
184 public:
191  DisplayILI9341_240x320x16(I &intf, int8_t rstPin)
192  : DisplayILI9341x16<I>(intf, rstPin)
193  {
194  }
195 
196 protected:
200  void beginController();
201 
205  void endController();
206 };
207 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
208 
211 class DisplayILI9341_240x320x16_SPI: public DisplayILI9341_240x320x16<InterfaceILI9341<PlatformSpi>>
212 {
213 public:
221  explicit DisplayILI9341_240x320x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
222  : DisplayILI9341_240x320x16(m_spi, rstPin)
223  , m_spi(*this, config.dc,
225  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(10000000), config.scl, config.sda})
226  {
227  }
228 
232  void begin() override;
233 
237  void end() override;
238 
239 private:
241 };
242 #endif
243 
248 template <typename I> class DisplayILI9341_240x320x16_CustomSPI: public DisplayILI9341_240x320x16<InterfaceILI9341<I>>
249 {
250 public:
259  template <typename... Args>
260  DisplayILI9341_240x320x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
261  : DisplayILI9341_240x320x16<InterfaceILI9341<I>>(m_spi, rstPin)
262  , m_spi(*this, dcPin, data...)
263  {
264  }
265 
269  void begin() override
270  {
271  m_spi.begin();
273  }
274 
278  void end() override
279  {
281  m_spi.end();
282  }
283 
284 private:
285  InterfaceILI9341<I> m_spi;
286 };
290 template <typename I> class DisplayILI9341_128x160x16: public DisplayILI9341x16<I>
291 {
292 public:
299  DisplayILI9341_128x160x16(I &intf, int8_t rstPin)
300  : DisplayILI9341x16<I>(intf, rstPin)
301  {
302  }
303 
304 protected:
308  void beginController();
309 
313  void endController();
314 };
315 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
316 
319 class DisplayILI9341_128x160x16_SPI: public DisplayILI9341_128x160x16<InterfaceILI9341<PlatformSpi>>
320 {
321 public:
329  explicit DisplayILI9341_128x160x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
330  : DisplayILI9341_128x160x16(m_spi, rstPin)
331  , m_spi(*this, config.dc,
333  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(10000000), config.scl, config.sda})
334  {
335  }
336 
340  void begin() override;
341 
345  void end() override;
346 
347 private:
349 };
350 #endif
351 
356 template <typename I> class DisplayILI9341_128x160x16_CustomSPI: public DisplayILI9341_128x160x16<InterfaceILI9341<I>>
357 {
358 public:
367  template <typename... Args>
368  DisplayILI9341_128x160x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
369  : DisplayILI9341_128x160x16<InterfaceILI9341<I>>(m_spi, rstPin)
370  , m_spi(*this, dcPin, data...)
371  {
372  }
373 
377  void begin() override
378  {
379  m_spi.begin();
381  }
382 
386  void end() override
387  {
389  m_spi.end();
390  }
391 
392 private:
393  InterfaceILI9341<I> m_spi;
394 };
395 #include "lcd_ili9341.inl"
396 
DisplayILI9341x16(I &intf, int8_t rstPin)
Creates instance of ILI9341 controller class for 16-bit mode.
Definition: lcd_ili9341.h:159
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
Class implements basic functions for 16-bit mode of ILI9341-based displays.
Definition: lcd_ili9341.h:290
global lcd settings
Template class implements ILI9341 240x320x16 lcd display in 16 bit mode over custom SPI implementatio...
Definition: lcd_ili9341.h:248
Template class implements ILI9341 128x160x16 lcd display in 16 bit mode over custom SPI implementatio...
Definition: lcd_ili9341.h:356
void rotateOutput(uint8_t rotate)
Sets rotation of all output functions.
SSD1306 HAL IO communication functions.
DisplayILI9341_128x160x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 128x160x16 lcd display over spi (based on ILI9341 controller): 16-bit mode. ...
Definition: lcd_ili9341.h:368
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_ili9341.h:166
void begin() override
Initializes ILI9341 lcd in 16-bit mode.
Definition: lcd_ili9341.h:377
void commandStart()
Starts communication with LCD display in command mode.
Definition: lcd_ili9341.inl:77
void setDataMode(uint8_t mode)
Enables either data or command mode on SPI bus.
Definition: lcd_ili9341.inl:69
int8_t dc
Data command control pin number.
Definition: interface.h:102
void normalMode()
Switches display to normal (non-inverted) mode (sends INVOFF command).
void begin() override
Initializes ILI9341 lcd in 16-bit mode.
Definition: lcd_ili9341.h:269
Class implements basic functions for 16-bit mode of ILI9341-based displays.
Definition: lcd_ili9341.h:150
InterfaceILI9341(NanoDisplayBase< InterfaceILI9341< I >> &base, int8_t dc, Args &&... data)
Creates instance of interface to LCD display.
Definition: lcd_ili9341.h:54
void setRotation(uint8_t rotation)
Sets screen orientation (rotation)
Definition: lcd_ili9341.inl:86
Class implements interface functions to ILI9341 displays.
Definition: lcd_ili9341.h:43
void nextBlock()
Switches to the start of next RAM page for the block, specified by startBlock().
Definition: lcd_ili9341.inl:59
DisplayILI9341_240x320x16(I &intf, int8_t rstPin)
Creates instance of ILI9341 240x320x16 controller class for 16-bit mode.
Definition: lcd_ili9341.h:191
Class implements basic functions for 16-bit mode of ILI9341-based displays.
Definition: lcd_ili9341.h:182
void end() override
Closes connection to display.
Definition: lcd_ili9341.h:386
NanoCanvasOps provides operations for drawing in memory buffer.
Definition: display.h:978
DisplayILI9341_128x160x16(I &intf, int8_t rstPin)
Creates instance of ILI9341 128x160x16 controller class for 16-bit mode.
Definition: lcd_ili9341.h:299
Class implements basic display operations for the library: It stores reference to communication inter...
Definition: display_base.h:55
void end() override
Closes connection to display.
Definition: lcd_ili9341.h:278
DisplayILI9341_240x320x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 240x320x16 lcd display over spi (based on ILI9341 controller): 16-bit mode. ...
Definition: lcd_ili9341.h:260
NanoDisplayOps16 is template class for 16-bit operations.
Definition: display.h:740
void endBlock()
Closes data send operation to lcd display.
Definition: lcd_ili9341.inl:64
void invertMode()
Switches display to inverted mode (sends INVON command).
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_ili9341.inl:35