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_sh1107.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 InterfaceSH1107: public I
44 {
45 public:
53  template <typename... Args>
54  InterfaceSH1107(NanoDisplayBase<InterfaceSH1107<I>> &base, int8_t dc, Args &&... data)
55  : I(data...)
56  , m_dc(dc)
57  , m_base(base)
58  {
59  }
60 
77 
85  void nextBlock();
86 
90  void endBlock();
91 
96  void setDataMode(uint8_t mode);
97 
102  void commandStart();
103 
110  void setStartLine(uint8_t line);
111 
117  uint8_t getStartLine();
118 
123  void normalMode();
124 
130  void invertMode();
131 
138  void setContrast(uint8_t contrast);
139 
145  void displayOff();
146 
151  void displayOn();
152 
162  void flipHorizontal(uint8_t mode);
163 
173  void flipVertical(uint8_t mode);
174 
184  void setSegOffset(uint8_t offset);
185 
191  void setDisplayOffset(uint8_t offset);
192 
193 private:
194  int8_t m_dc = -1;
196  uint8_t m_startLine = 0;
197  uint8_t m_column = 0;
198  uint8_t m_page = 0;
199  uint8_t m_seg_offset = 0;
200 };
204 template <typename I> class DisplaySH1107: public NanoDisplayOps<NanoDisplayOps1<I>, I>
205 {
206 public:
213  DisplaySH1107(I &intf, int8_t rstPin)
214  : NanoDisplayOps<NanoDisplayOps1<I>, I>(intf)
215  , m_rstPin(rstPin)
216  {
217  }
218 
219 protected:
220  int8_t m_rstPin;
221 
225  void beginDisplay();
226 
230  void endDisplay();
231 };
232 
236 template <typename I> class DisplaySH1107_128x64: public DisplaySH1107<I>
237 {
238 public:
245  DisplaySH1107_128x64(I &intf, int8_t rstPin)
246  : DisplaySH1107<I>(intf, rstPin)
247  {
248  }
249 
250 protected:
254  void beginController();
255 
259  void endController();
260 };
261 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
262 
265 class DisplaySH1107_128x64_SPI: public DisplaySH1107_128x64<InterfaceSH1107<PlatformSpi>>
266 {
267 public:
275  explicit DisplaySH1107_128x64_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
276  : DisplaySH1107_128x64(m_spi, rstPin)
277  , m_spi(*this, config.dc,
279  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(10000000), config.scl, config.sda})
280  {
281  }
282 
286  void begin() override;
287 
291  void end() override;
292 
293 private:
295 };
296 #endif
297 
302 template <typename I> class DisplaySH1107_128x64_CustomSPI: public DisplaySH1107_128x64<InterfaceSH1107<I>>
303 {
304 public:
313  template <typename... Args>
314  DisplaySH1107_128x64_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
315  : DisplaySH1107_128x64<InterfaceSH1107<I>>(m_spi, rstPin)
316  , m_spi(*this, dcPin, data...)
317  {
318  }
319 
323  void begin() override
324  {
325  m_spi.begin();
326  DisplaySH1107_128x64<InterfaceSH1107<I>>::beginController();
327  }
328 
332  void end() override
333  {
334  DisplaySH1107_128x64<InterfaceSH1107<I>>::endController();
335  m_spi.end();
336  }
337 
338 private:
339  InterfaceSH1107<I> m_spi;
340 };
341 #ifdef CONFIG_LCDGFX_PLATFORM_I2C
342 
345 class DisplaySH1107_128x64_I2C: public DisplaySH1107_128x64<InterfaceSH1107<PlatformI2c>>
346 {
347 public:
355  explicit DisplaySH1107_128x64_I2C(int8_t rstPin, const SPlatformI2cConfig &config = {-1, 0x3C, -1, -1, 0U})
356  : DisplaySH1107_128x64(m_i2c, rstPin)
357  , m_i2c(*this, -1,
358  SPlatformI2cConfig{config.busId, static_cast<uint8_t>(config.addr ?: 0x3C), config.scl, config.sda,
359  config.frequency ?: 400000U})
360  {
361  }
362 
366  void begin() override;
367 
371  void end() override;
372 
373 private:
375 };
376 #endif
377 
382 template <typename I> class DisplaySH1107_128x64_CustomI2C: public DisplaySH1107_128x64<InterfaceSH1107<I>>
383 {
384 public:
392  template <typename... Args>
393  DisplaySH1107_128x64_CustomI2C(int8_t rstPin, Args &&... data)
394  : DisplaySH1107_128x64<InterfaceSH1107<I>>(m_i2c, rstPin)
395  , m_i2c(*this, -1, data...)
396  {
397  }
398 
402  void begin() override
403  {
404  m_i2c.begin();
405  DisplaySH1107_128x64<InterfaceSH1107<I>>::beginController();
406  }
407 
411  void end() override
412  {
413  DisplaySH1107_128x64<InterfaceSH1107<I>>::endController();
414  m_i2c.end();
415  }
416 
417 private:
418  InterfaceSH1107<I> m_i2c;
419 };
423 template <typename I> class DisplaySH1107_64x128: public DisplaySH1107<I>
424 {
425 public:
432  DisplaySH1107_64x128(I &intf, int8_t rstPin)
433  : DisplaySH1107<I>(intf, rstPin)
434  {
435  }
436 
437 protected:
441  void beginController();
442 
446  void endController();
447 };
448 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
449 
452 class DisplaySH1107_64x128_SPI: public DisplaySH1107_64x128<InterfaceSH1107<PlatformSpi>>
453 {
454 public:
462  explicit DisplaySH1107_64x128_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
463  : DisplaySH1107_64x128(m_spi, rstPin)
464  , m_spi(*this, config.dc,
466  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(10000000), config.scl, config.sda})
467  {
468  }
469 
473  void begin() override;
474 
478  void end() override;
479 
480 private:
482 };
483 #endif
484 
489 template <typename I> class DisplaySH1107_64x128_CustomSPI: public DisplaySH1107_64x128<InterfaceSH1107<I>>
490 {
491 public:
500  template <typename... Args>
501  DisplaySH1107_64x128_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
502  : DisplaySH1107_64x128<InterfaceSH1107<I>>(m_spi, rstPin)
503  , m_spi(*this, dcPin, data...)
504  {
505  }
506 
510  void begin() override
511  {
512  m_spi.begin();
513  DisplaySH1107_64x128<InterfaceSH1107<I>>::beginController();
514  }
515 
519  void end() override
520  {
521  DisplaySH1107_64x128<InterfaceSH1107<I>>::endController();
522  m_spi.end();
523  }
524 
525 private:
526  InterfaceSH1107<I> m_spi;
527 };
528 #ifdef CONFIG_LCDGFX_PLATFORM_I2C
529 
532 class DisplaySH1107_64x128_I2C: public DisplaySH1107_64x128<InterfaceSH1107<PlatformI2c>>
533 {
534 public:
542  explicit DisplaySH1107_64x128_I2C(int8_t rstPin, const SPlatformI2cConfig &config = {-1, 0x3C, -1, -1, 0U})
543  : DisplaySH1107_64x128(m_i2c, rstPin)
544  , m_i2c(*this, -1,
545  SPlatformI2cConfig{config.busId, static_cast<uint8_t>(config.addr ?: 0x3C), config.scl, config.sda,
546  config.frequency ?: 400000U})
547  {
548  }
549 
553  void begin() override;
554 
558  void end() override;
559 
560 private:
562 };
563 #endif
564 
569 template <typename I> class DisplaySH1107_64x128_CustomI2C: public DisplaySH1107_64x128<InterfaceSH1107<I>>
570 {
571 public:
579  template <typename... Args>
580  DisplaySH1107_64x128_CustomI2C(int8_t rstPin, Args &&... data)
581  : DisplaySH1107_64x128<InterfaceSH1107<I>>(m_i2c, rstPin)
582  , m_i2c(*this, -1, data...)
583  {
584  }
585 
589  void begin() override
590  {
591  m_i2c.begin();
592  DisplaySH1107_64x128<InterfaceSH1107<I>>::beginController();
593  }
594 
598  void end() override
599  {
600  DisplaySH1107_64x128<InterfaceSH1107<I>>::endController();
601  m_i2c.end();
602  }
603 
604 private:
605  InterfaceSH1107<I> m_i2c;
606 };
607 #include "lcd_sh1107.inl"
608 
DisplaySH1107_128x64_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 128x64 lcd display over spi (based on SH1107 controller): 1-bit mode.
Definition: lcd_sh1107.h:314
DisplaySH1107_64x128_CustomI2C(int8_t rstPin, Args &&... data)
Inits 64x128 lcd display over i2c (based on SH1107 controller): 1-bit mode.
Definition: lcd_sh1107.h:580
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
void begin() override
Initializes SH1107 lcd in 1-bit mode.
Definition: lcd_sh1107.h:589
global lcd settings
int8_t busId
bus id number.
Definition: interface.h:49
Structure describes i2c platform configuration.
Definition: interface.h:43
void setStartLine(uint8_t line)
Sets start line in GDRAM to begin display content with.
Definition: lcd_sh1107.inl:83
Template class implements SH1107 128x64 lcd display in 1 bit mode over custom SPI implementation (use...
Definition: lcd_sh1107.h:302
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_sh1107.inl:35
SSD1306 HAL IO communication functions.
uint8_t getStartLine()
Returns the current start line offset in GDRAM.
Definition: lcd_sh1107.inl:92
Class implements basic functions for 1-bit mode of SH1107-based displays.
Definition: lcd_sh1107.h:423
void end() override
Closes connection to display.
Definition: lcd_sh1107.h:598
InterfaceSH1107(NanoDisplayBase< InterfaceSH1107< I >> &base, int8_t dc, Args &&... data)
Creates instance of interface to LCD display.
Definition: lcd_sh1107.h:54
void flipHorizontal(uint8_t mode)
Performs horizontal flip.
Definition: lcd_sh1107.inl:133
Class implements basic functions for 1-bit mode of SH1107-based displays.
Definition: lcd_sh1107.h:236
void setContrast(uint8_t contrast)
Sets display contrast (brightness level).
Definition: lcd_sh1107.inl:111
int8_t dc
Data command control pin number.
Definition: interface.h:102
DisplaySH1107_128x64_CustomI2C(int8_t rstPin, Args &&... data)
Inits 128x64 lcd display over i2c (based on SH1107 controller): 1-bit mode.
Definition: lcd_sh1107.h:393
Class implements interface functions to SH1107 displays.
Definition: lcd_sh1107.h:43
Class implements basic functions for 1-bit mode of SH1107-based displays.
Definition: lcd_sh1107.h:204
void normalMode()
Switches display back to normal (non-inverted) mode.
Definition: lcd_sh1107.inl:97
NanoDisplayOps1 is template class for 1-bit operations.
Definition: display.h:47
DisplaySH1107_128x64(I &intf, int8_t rstPin)
Creates instance of SH1107 128x64 controller class for 1-bit mode.
Definition: lcd_sh1107.h:245
void begin() override
Initializes SH1107 lcd in 1-bit mode.
Definition: lcd_sh1107.h:510
void begin() override
Initializes SH1107 lcd in 1-bit mode.
Definition: lcd_sh1107.h:402
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_sh1107.h:220
void invertMode()
Switches display to inverted mode.
Definition: lcd_sh1107.inl:104
void flipVertical(uint8_t mode)
Performs vertical flip.
Definition: lcd_sh1107.inl:140
void endBlock()
Closes data send operation to lcd display.
Definition: lcd_sh1107.inl:61
DisplaySH1107_64x128(I &intf, int8_t rstPin)
Creates instance of SH1107 64x128 controller class for 1-bit mode.
Definition: lcd_sh1107.h:432
Template class implements SH1107 64x128 lcd display in 1 bit mode over custom I2C implementation (use...
Definition: lcd_sh1107.h:569
void setDisplayOffset(uint8_t offset)
Sets display offset according to datasheet.
Definition: lcd_sh1107.inl:152
void displayOn()
Turns on the display, resuming normal output.
Definition: lcd_sh1107.inl:126
DisplaySH1107(I &intf, int8_t rstPin)
Creates instance of SH1107 controller class for 1-bit mode.
Definition: lcd_sh1107.h:213
void nextBlock()
Switches to the start of next RAM page for the block, specified by startBlock().
Definition: lcd_sh1107.inl:55
DisplaySH1107_64x128_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 64x128 lcd display over spi (based on SH1107 controller): 1-bit mode.
Definition: lcd_sh1107.h:501
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_sh1107.inl:66
void setSegOffset(uint8_t offset)
Sets segment (column) connection offset.
Definition: lcd_sh1107.inl:147
void begin() override
Initializes SH1107 lcd in 1-bit mode.
Definition: lcd_sh1107.h:323
Class implements basic display operations for the library: It stores reference to communication inter...
Definition: display_base.h:55
Template class implements SH1107 128x64 lcd display in 1 bit mode over custom I2C implementation (use...
Definition: lcd_sh1107.h:382
Template class implements SH1107 64x128 lcd display in 1 bit mode over custom SPI implementation (use...
Definition: lcd_sh1107.h:489
void end() override
Closes connection to display.
Definition: lcd_sh1107.h:519
void commandStart()
Starts communication with LCD display in command mode.
Definition: lcd_sh1107.inl:74
void displayOff()
Turns off the display (enters sleep mode).
Definition: lcd_sh1107.inl:119
void end() override
Closes connection to display.
Definition: lcd_sh1107.h:332
void end() override
Closes connection to display.
Definition: lcd_sh1107.h:411