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_ssd1306.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 InterfaceSSD1306: public I
45 {
46 public:
54  template <typename... Args>
55  InterfaceSSD1306(NanoDisplayBase<InterfaceSSD1306<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 
109  void setStartLine(uint8_t line);
110 
114  uint8_t getStartLine();
115 
120  void normalMode();
121 
126  void invertMode();
127 
132  void setContrast(uint8_t contrast);
133 
137  void displayOff();
138 
142  void displayOn();
143 
153  void flipHorizontal(uint8_t mode);
154 
164  void flipVertical(uint8_t mode);
165 
166 private:
167  int8_t m_dc = -1;
169  uint8_t m_startLine = 0;
170 };
171 
172 
176 template <class I>
177 class DisplaySSD1306: public NanoDisplayOps<NanoDisplayOps1<I>,I>
178 {
179 public:
186  DisplaySSD1306(I &intf, int8_t rstPin)
187  : NanoDisplayOps<NanoDisplayOps1<I>, I>(intf)
188  , m_rstPin( rstPin ) { }
189 
190 protected:
191  int8_t m_rstPin;
192 
196  void begin() override;
197 
201  void end() override;
202 };
203 
207 template <class I>
209 {
210 public:
217  DisplaySSD1306_128x32(I &intf, int8_t rstPin)
218  : DisplaySSD1306<I>(intf, rstPin) { }
219 
220 protected:
221 
225  void begin() override;
226 
230  void end() override;
231 };
232 
236 class DisplaySSD1306_128x32_SPI: public DisplaySSD1306_128x32<InterfaceSSD1306<PlatformSpi>>
237 {
238 public:
246  DisplaySSD1306_128x32_SPI( int8_t rstPin, const SPlatformSpiConfig &config = { -1, { -1 }, -1, 0, -1, -1 } )
247  : DisplaySSD1306_128x32(m_spi, rstPin)
248  , m_spi( *this, config.dc,
249  SPlatformSpiConfig{ config.busId,
250  { config.cs },
251  config.dc,
252  config.frequency ?: 10000000,
253  config.scl,
254  config.sda } ) {}
255 
259  void begin() override;
260 
264  void end() override;
265 
266 private:
268 };
269 
274 template <class I>
275 class DisplaySSD1306_128x32_CustomSPI: public DisplaySSD1306_128x32<InterfaceSSD1306<I>>
276 {
277 public:
286  template <typename... Args>
287  DisplaySSD1306_128x32_CustomSPI( int8_t rstPin, int8_t dcPin, Args&&... data )
288  : DisplaySSD1306_128x32<InterfaceSSD1306<I>>(m_spi, rstPin)
289  , m_spi( *this, dcPin,
290  data... ) {}
291 
295  void begin() override
296  {
297  m_spi.begin();
299  }
300 
304  void end() override
305  {
307  m_spi.end();
308  }
309 
310 private:
311  InterfaceSSD1306<I> m_spi;
312 };
316 class DisplaySSD1306_128x32_I2C: public DisplaySSD1306_128x32<InterfaceSSD1306<PlatformI2c>>
317 {
318 public:
326  DisplaySSD1306_128x32_I2C( int8_t rstPin, const SPlatformI2cConfig &config = { -1, 0x3C, -1, -1, 0 } )
327  : DisplaySSD1306_128x32(m_i2c, rstPin)
328  , m_i2c( *this, -1,
329  SPlatformI2cConfig{ config.busId,
330  static_cast<uint8_t>(config.addr ?: 0x3C),
331  config.scl,
332  config.sda,
333  config.frequency ?: 400000 } ) {}
334 
338  void begin() override;
339 
343  void end() override;
344 
345 private:
347 };
348 
353 template <class I>
354 class DisplaySSD1306_128x32_CustomI2C: public DisplaySSD1306_128x32<InterfaceSSD1306<I>>
355 {
356 public:
364  template <typename... Args>
365  DisplaySSD1306_128x32_CustomI2C( int8_t rstPin, Args&&... data )
366  : DisplaySSD1306_128x32<InterfaceSSD1306<I>>(m_i2c, rstPin)
367  , m_i2c( *this, -1,
368  data... ) {}
369 
373  void begin() override
374  {
375  m_i2c.begin();
377  }
378 
382  void end() override
383  {
385  m_i2c.end();
386  }
387 
388 private:
389  InterfaceSSD1306<I> m_i2c;
390 };
391 
392 
396 template <class I>
398 {
399 public:
406  DisplaySSD1306_128x64(I &intf, int8_t rstPin)
407  : DisplaySSD1306<I>(intf, rstPin) { }
408 
409 protected:
410 
414  void begin() override;
415 
419  void end() override;
420 };
421 
425 class DisplaySSD1306_128x64_SPI: public DisplaySSD1306_128x64<InterfaceSSD1306<PlatformSpi>>
426 {
427 public:
435  DisplaySSD1306_128x64_SPI( int8_t rstPin, const SPlatformSpiConfig &config = { -1, { -1 }, -1, 0, -1, -1 } )
436  : DisplaySSD1306_128x64(m_spi, rstPin)
437  , m_spi( *this, config.dc,
438  SPlatformSpiConfig{ config.busId,
439  { config.cs },
440  config.dc,
441  config.frequency ?: 10000000,
442  config.scl,
443  config.sda } ) {}
444 
448  void begin() override;
449 
453  void end() override;
454 
455 private:
457 };
458 
463 template <class I>
464 class DisplaySSD1306_128x64_CustomSPI: public DisplaySSD1306_128x64<InterfaceSSD1306<I>>
465 {
466 public:
475  template <typename... Args>
476  DisplaySSD1306_128x64_CustomSPI( int8_t rstPin, int8_t dcPin, Args&&... data )
477  : DisplaySSD1306_128x64<InterfaceSSD1306<I>>(m_spi, rstPin)
478  , m_spi( *this, dcPin,
479  data... ) {}
480 
484  void begin() override
485  {
486  m_spi.begin();
488  }
489 
493  void end() override
494  {
496  m_spi.end();
497  }
498 
499 private:
500  InterfaceSSD1306<I> m_spi;
501 };
505 class DisplaySSD1306_128x64_I2C: public DisplaySSD1306_128x64<InterfaceSSD1306<PlatformI2c>>
506 {
507 public:
515  DisplaySSD1306_128x64_I2C( int8_t rstPin, const SPlatformI2cConfig &config = { -1, 0x3C, -1, -1, 0 } )
516  : DisplaySSD1306_128x64(m_i2c, rstPin)
517  , m_i2c( *this, -1,
518  SPlatformI2cConfig{ config.busId,
519  static_cast<uint8_t>(config.addr ?: 0x3C),
520  config.scl,
521  config.sda,
522  config.frequency ?: 400000 } ) {}
523 
527  void begin() override;
528 
532  void end() override;
533 
534 private:
536 };
537 
542 template <class I>
543 class DisplaySSD1306_128x64_CustomI2C: public DisplaySSD1306_128x64<InterfaceSSD1306<I>>
544 {
545 public:
553  template <typename... Args>
554  DisplaySSD1306_128x64_CustomI2C( int8_t rstPin, Args&&... data )
555  : DisplaySSD1306_128x64<InterfaceSSD1306<I>>(m_i2c, rstPin)
556  , m_i2c( *this, -1,
557  data... ) {}
558 
562  void begin() override
563  {
564  m_i2c.begin();
566  }
567 
571  void end() override
572  {
574  m_i2c.end();
575  }
576 
577 private:
578  InterfaceSSD1306<I> m_i2c;
579 };
580 
581 
582 #include "lcd_ssd1306.inl"
583 
void setStartLine(uint8_t line)
Definition: lcd_ssd1306.inl:89
uint8_t lcduint_t
Definition: canvas_types.h:81
DisplaySSD1306_128x64(I &intf, int8_t rstPin)
Definition: lcd_ssd1306.h:406
DisplaySSD1306_128x64_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 128x64 lcd display over spi (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:476
DisplaySSD1306_128x32_I2C(int8_t rstPin, const SPlatformI2cConfig &config={ -1, 0x3C, -1, -1, 0 })
Inits 128x32 lcd display over i2c (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:326
void flipVertical(uint8_t mode)
performs vertical flip
DisplaySSD1306(I &intf, int8_t rstPin)
Definition: lcd_ssd1306.h:186
DisplaySSD1306_128x64_I2C(int8_t rstPin, const SPlatformI2cConfig &config={ -1, 0x3C, -1, -1, 0 })
Inits 128x64 lcd display over i2c (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:515
void spiDataMode(uint8_t mode)
Definition: lcd_ssd1306.inl:70
DisplaySSD1306_128x32_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 128x32 lcd display over spi (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:287
uint8_t getStartLine()
Definition: lcd_ssd1306.inl:98
InterfaceSSD1306(NanoDisplayBase< InterfaceSSD1306< I >> &base, int8_t dc, Args &&... data)
Definition: lcd_ssd1306.h:55
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_ssd1306.h:191
DisplaySSD1306_128x32_SPI(int8_t rstPin, const SPlatformSpiConfig &config={ -1, { -1 }, -1, 0, -1, -1 })
Inits 128x32 lcd display over spi (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:246
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_ssd1306.inl:36
void flipHorizontal(uint8_t mode)
performs horizontal flip
DisplaySSD1306_128x32_CustomI2C(int8_t rstPin, Args &&... data)
Inits 128x32 lcd display over i2c (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:365
DisplaySSD1306_128x64_CustomI2C(int8_t rstPin, Args &&... data)
Inits 128x64 lcd display over i2c (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:554
void setContrast(uint8_t contrast)
DisplaySSD1306_128x32(I &intf, int8_t rstPin)
Definition: lcd_ssd1306.h:217
DisplaySSD1306_128x64_SPI(int8_t rstPin, const SPlatformSpiConfig &config={ -1, { -1 }, -1, 0, -1, -1 })
Inits 128x64 lcd display over spi (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:435