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_ssd1331.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 InterfaceSSD1331: public I
44 {
45 public:
54  template <typename... Args>
55  InterfaceSSD1331(uint8_t bits, NanoDisplayBase<InterfaceSSD1331<I>> &base, int8_t dc, Args &&... data)
56  : I(data...)
57  , m_bits(bits)
58  , m_dc(dc)
59  , m_base(base)
60  {
61  }
62 
79 
86  void nextBlock();
87 
91  void endBlock();
92 
97  void setDataMode(uint8_t mode);
98 
103  void commandStart();
104 
116  void setRotation(uint8_t rotation);
117 
127  void drawLine(lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2, uint16_t color);
128 
146  void copyBlock(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t newLeft, uint8_t newTop);
147 
153  void setContrast(uint8_t contrast);
154 
155 private:
156  const uint8_t m_bits;
157  const int8_t m_dc = -1;
159  uint8_t m_rotation = 0x00;
160 };
164 template <typename I> class DisplaySSD1331x8: public NanoDisplayOps<NanoDisplayOps8<I>, I>
165 {
166 public:
173  DisplaySSD1331x8(I &intf, int8_t rstPin)
174  : NanoDisplayOps<NanoDisplayOps8<I>, I>(intf)
175  , m_rstPin(rstPin)
176  {
177  }
178 
179 protected:
180  int8_t m_rstPin;
181 
185  void beginDisplay();
186 
190  void endDisplay();
191 };
192 
196 template <typename I> class DisplaySSD1331_96x64x8: public DisplaySSD1331x8<I>
197 {
198 public:
205  DisplaySSD1331_96x64x8(I &intf, int8_t rstPin)
206  : DisplaySSD1331x8<I>(intf, rstPin)
207  {
208  }
209 
210 protected:
214  void beginController();
215 
219  void endController();
220 };
221 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
222 
225 class DisplaySSD1331_96x64x8_SPI: public DisplaySSD1331_96x64x8<InterfaceSSD1331<PlatformSpi>>
226 {
227 public:
235  explicit DisplaySSD1331_96x64x8_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
236  : DisplaySSD1331_96x64x8(m_spi, rstPin)
237  , m_spi(8, *this, config.dc,
239  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(6000000), config.scl, config.sda})
240  {
241  }
242 
246  void begin() override;
247 
251  void end() override;
252 
253 private:
255 };
256 #endif
257 
262 template <typename I> class DisplaySSD1331_96x64x8_CustomSPI: public DisplaySSD1331_96x64x8<InterfaceSSD1331<I>>
263 {
264 public:
273  template <typename... Args>
274  DisplaySSD1331_96x64x8_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
275  : DisplaySSD1331_96x64x8<InterfaceSSD1331<I>>(m_spi, rstPin)
276  , m_spi(8, *this, dcPin, data...)
277  {
278  }
279 
283  void begin() override
284  {
285  m_spi.begin();
286  DisplaySSD1331_96x64x8<InterfaceSSD1331<I>>::beginController();
287  }
288 
292  void end() override
293  {
295  m_spi.end();
296  }
297 
298 private:
299  InterfaceSSD1331<I> m_spi;
300 };
304 template <typename I> class DisplaySSD1331x16: public NanoDisplayOps<NanoDisplayOps16<I>, I>
305 {
306 public:
313  DisplaySSD1331x16(I &intf, int8_t rstPin)
314  : NanoDisplayOps<NanoDisplayOps16<I>, I>(intf)
315  , m_rstPin(rstPin)
316  {
317  }
318 
319 protected:
320  int8_t m_rstPin;
321 
325  void beginDisplay();
326 
330  void endDisplay();
331 };
332 
336 template <typename I> class DisplaySSD1331_96x64x16: public DisplaySSD1331x16<I>
337 {
338 public:
345  DisplaySSD1331_96x64x16(I &intf, int8_t rstPin)
346  : DisplaySSD1331x16<I>(intf, rstPin)
347  {
348  }
349 
350 protected:
354  void beginController();
355 
359  void endController();
360 };
361 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
362 
365 class DisplaySSD1331_96x64x16_SPI: public DisplaySSD1331_96x64x16<InterfaceSSD1331<PlatformSpi>>
366 {
367 public:
375  explicit DisplaySSD1331_96x64x16_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
376  : DisplaySSD1331_96x64x16(m_spi, rstPin)
377  , m_spi(16, *this, config.dc,
379  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(6000000), config.scl, config.sda})
380  {
381  }
382 
386  void begin() override;
387 
391  void end() override;
392 
393 private:
395 };
396 #endif
397 
402 template <typename I> class DisplaySSD1331_96x64x16_CustomSPI: public DisplaySSD1331_96x64x16<InterfaceSSD1331<I>>
403 {
404 public:
413  template <typename... Args>
414  DisplaySSD1331_96x64x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
415  : DisplaySSD1331_96x64x16<InterfaceSSD1331<I>>(m_spi, rstPin)
416  , m_spi(16, *this, dcPin, data...)
417  {
418  }
419 
423  void begin() override
424  {
425  m_spi.begin();
427  }
428 
432  void end() override
433  {
435  m_spi.end();
436  }
437 
438 private:
439  InterfaceSSD1331<I> m_spi;
440 };
441 #include "lcd_ssd1331.inl"
442 
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
DisplaySSD1331x16(I &intf, int8_t rstPin)
Creates instance of SSD1331 controller class for 16-bit mode.
Definition: lcd_ssd1331.h:313
global lcd settings
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_ssd1331.h:320
void setContrast(uint8_t contrast)
Set display contrast for all RGB channels uniformly.
void copyBlock(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t newLeft, uint8_t newTop)
Copies block in GDRAM to new position using hardware accelerator features.
void begin() override
Initializes SSD1331 lcd in 16-bit mode.
Definition: lcd_ssd1331.h:423
int8_t lcdint_t
internal int type, used by the library.
Definition: canvas_types.h:77
Template class implements SSD1331 96x64x8 lcd display in 8 bit mode over custom SPI implementation (u...
Definition: lcd_ssd1331.h:262
SSD1306 HAL IO communication functions.
InterfaceSSD1331(uint8_t bits, NanoDisplayBase< InterfaceSSD1331< I >> &base, int8_t dc, Args &&... data)
Creates instance of interface to LCD display.
Definition: lcd_ssd1331.h:55
void end() override
Closes connection to display.
Definition: lcd_ssd1331.h:432
DisplaySSD1331_96x64x16(I &intf, int8_t rstPin)
Creates instance of SSD1331 96x64x16 controller class for 16-bit mode.
Definition: lcd_ssd1331.h:345
void end() override
Closes connection to display.
Definition: lcd_ssd1331.h:292
void setRotation(uint8_t rotation)
Sets screen orientation (rotation)
Definition: lcd_ssd1331.inl:76
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_ssd1331.inl:35
int8_t dc
Data command control pin number.
Definition: interface.h:102
Class implements basic functions for 16-bit mode of SSD1331-based displays.
Definition: lcd_ssd1331.h:304
void drawLine(lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2, uint16_t color)
Draws line using hardware accelerator capabilities.
DisplaySSD1331x8(I &intf, int8_t rstPin)
Creates instance of SSD1331 controller class for 8-bit mode.
Definition: lcd_ssd1331.h:173
Class implements basic functions for 8-bit mode of SSD1331-based displays.
Definition: lcd_ssd1331.h:164
void commandStart()
Starts communication with LCD display in command mode.
Definition: lcd_ssd1331.inl:67
void begin() override
Initializes SSD1331 lcd in 8-bit mode.
Definition: lcd_ssd1331.h:283
Template class implements SSD1331 96x64x16 lcd display in 16 bit mode over custom SPI implementation ...
Definition: lcd_ssd1331.h:402
DisplaySSD1331_96x64x8(I &intf, int8_t rstPin)
Creates instance of SSD1331 96x64x8 controller class for 8-bit mode.
Definition: lcd_ssd1331.h:205
DisplaySSD1331_96x64x16_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 96x64x16 lcd display over spi (based on SSD1331 controller): 16-bit mode.
Definition: lcd_ssd1331.h:414
Class implements basic functions for 8-bit mode of SSD1331-based displays.
Definition: lcd_ssd1331.h:196
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_ssd1331.h:180
NanoCanvasOps provides operations for drawing in memory buffer.
Definition: display.h:978
void setDataMode(uint8_t mode)
Enables either data or command mode on SPI bus.
Definition: lcd_ssd1331.inl:59
Class implements basic display operations for the library: It stores reference to communication inter...
Definition: display_base.h:55
void nextBlock()
Switches to the start of next RAM page for the block, specified by startBlock().
Definition: lcd_ssd1331.inl:49
void endBlock()
Closes data send operation to lcd display.
Definition: lcd_ssd1331.inl:54
NanoDisplayOps16 is template class for 16-bit operations.
Definition: display.h:740
DisplaySSD1331_96x64x8_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 96x64x8 lcd display over spi (based on SSD1331 controller): 8-bit mode.
Definition: lcd_ssd1331.h:274
Class implements interface functions to SSD1331 displays.
Definition: lcd_ssd1331.h:43
Class implements basic functions for 16-bit mode of SSD1331-based displays.
Definition: lcd_ssd1331.h:336
NanoDisplayOps8 is template class for 8-bit operations.
Definition: display.h:522