LCDGFX LCD display driver  1.1.5
This library is developed to control SSD1306/SSD1325/SSD1327/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
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 
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 
175  void setSegOffset(uint8_t offset);
176 
182  void setDisplayOffset(uint8_t offset);
183 
184 private:
185  int8_t m_dc = -1;
187  uint8_t m_startLine = 0;
188  uint8_t m_column = 0;
189  uint8_t m_page = 0;
190  uint8_t m_seg_offset = 0;
191 };
195 template <typename I> class DisplaySH1107: public NanoDisplayOps<NanoDisplayOps1<I>, I>
196 {
197 public:
204  DisplaySH1107(I &intf, int8_t rstPin)
205  : NanoDisplayOps<NanoDisplayOps1<I>, I>(intf)
206  , m_rstPin(rstPin)
207  {
208  }
209 
210 protected:
211  int8_t m_rstPin;
212 
216  void beginDisplay();
217 
221  void endDisplay();
222 };
223 
227 template <typename I> class DisplaySH1107_128x64: public DisplaySH1107<I>
228 {
229 public:
236  DisplaySH1107_128x64(I &intf, int8_t rstPin)
237  : DisplaySH1107<I>(intf, rstPin)
238  {
239  }
240 
241 protected:
245  void beginController();
246 
250  void endController();
251 };
252 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
253 
256 class DisplaySH1107_128x64_SPI: public DisplaySH1107_128x64<InterfaceSH1107<PlatformSpi>>
257 {
258 public:
266  explicit DisplaySH1107_128x64_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
267  : DisplaySH1107_128x64(m_spi, rstPin)
268  , m_spi(*this, config.dc,
270  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(10000000), config.scl, config.sda})
271  {
272  }
273 
277  void begin() override;
278 
282  void end() override;
283 
284 private:
286 };
287 #endif
288 
293 template <typename I> class DisplaySH1107_128x64_CustomSPI: public DisplaySH1107_128x64<InterfaceSH1107<I>>
294 {
295 public:
304  template <typename... Args>
305  DisplaySH1107_128x64_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
306  : DisplaySH1107_128x64<InterfaceSH1107<I>>(m_spi, rstPin)
307  , m_spi(*this, dcPin, data...)
308  {
309  }
310 
314  void begin() override
315  {
316  m_spi.begin();
317  DisplaySH1107_128x64<InterfaceSH1107<I>>::beginController();
318  }
319 
323  void end() override
324  {
325  DisplaySH1107_128x64<InterfaceSH1107<I>>::endController();
326  m_spi.end();
327  }
328 
329 private:
330  InterfaceSH1107<I> m_spi;
331 };
332 #ifdef CONFIG_LCDGFX_PLATFORM_I2C
333 
336 class DisplaySH1107_128x64_I2C: public DisplaySH1107_128x64<InterfaceSH1107<PlatformI2c>>
337 {
338 public:
346  explicit DisplaySH1107_128x64_I2C(int8_t rstPin, const SPlatformI2cConfig &config = {-1, 0x3C, -1, -1, 0U})
347  : DisplaySH1107_128x64(m_i2c, rstPin)
348  , m_i2c(*this, -1,
349  SPlatformI2cConfig{config.busId, static_cast<uint8_t>(config.addr ?: 0x3C), config.scl, config.sda,
350  config.frequency ?: 400000U})
351  {
352  }
353 
357  void begin() override;
358 
362  void end() override;
363 
364 private:
366 };
367 #endif
368 
373 template <typename I> class DisplaySH1107_128x64_CustomI2C: public DisplaySH1107_128x64<InterfaceSH1107<I>>
374 {
375 public:
383  template <typename... Args>
384  DisplaySH1107_128x64_CustomI2C(int8_t rstPin, Args &&... data)
385  : DisplaySH1107_128x64<InterfaceSH1107<I>>(m_i2c, rstPin)
386  , m_i2c(*this, -1, data...)
387  {
388  }
389 
393  void begin() override
394  {
395  m_i2c.begin();
396  DisplaySH1107_128x64<InterfaceSH1107<I>>::beginController();
397  }
398 
402  void end() override
403  {
404  DisplaySH1107_128x64<InterfaceSH1107<I>>::endController();
405  m_i2c.end();
406  }
407 
408 private:
409  InterfaceSH1107<I> m_i2c;
410 };
414 template <typename I> class DisplaySH1107_64x128: public DisplaySH1107<I>
415 {
416 public:
423  DisplaySH1107_64x128(I &intf, int8_t rstPin)
424  : DisplaySH1107<I>(intf, rstPin)
425  {
426  }
427 
428 protected:
432  void beginController();
433 
437  void endController();
438 };
439 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
440 
443 class DisplaySH1107_64x128_SPI: public DisplaySH1107_64x128<InterfaceSH1107<PlatformSpi>>
444 {
445 public:
453  explicit DisplaySH1107_64x128_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
454  : DisplaySH1107_64x128(m_spi, rstPin)
455  , m_spi(*this, config.dc,
457  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(10000000), config.scl, config.sda})
458  {
459  }
460 
464  void begin() override;
465 
469  void end() override;
470 
471 private:
473 };
474 #endif
475 
480 template <typename I> class DisplaySH1107_64x128_CustomSPI: public DisplaySH1107_64x128<InterfaceSH1107<I>>
481 {
482 public:
491  template <typename... Args>
492  DisplaySH1107_64x128_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
493  : DisplaySH1107_64x128<InterfaceSH1107<I>>(m_spi, rstPin)
494  , m_spi(*this, dcPin, data...)
495  {
496  }
497 
501  void begin() override
502  {
503  m_spi.begin();
504  DisplaySH1107_64x128<InterfaceSH1107<I>>::beginController();
505  }
506 
510  void end() override
511  {
512  DisplaySH1107_64x128<InterfaceSH1107<I>>::endController();
513  m_spi.end();
514  }
515 
516 private:
517  InterfaceSH1107<I> m_spi;
518 };
519 #ifdef CONFIG_LCDGFX_PLATFORM_I2C
520 
523 class DisplaySH1107_64x128_I2C: public DisplaySH1107_64x128<InterfaceSH1107<PlatformI2c>>
524 {
525 public:
533  explicit DisplaySH1107_64x128_I2C(int8_t rstPin, const SPlatformI2cConfig &config = {-1, 0x3C, -1, -1, 0U})
534  : DisplaySH1107_64x128(m_i2c, rstPin)
535  , m_i2c(*this, -1,
536  SPlatformI2cConfig{config.busId, static_cast<uint8_t>(config.addr ?: 0x3C), config.scl, config.sda,
537  config.frequency ?: 400000U})
538  {
539  }
540 
544  void begin() override;
545 
549  void end() override;
550 
551 private:
553 };
554 #endif
555 
560 template <typename I> class DisplaySH1107_64x128_CustomI2C: public DisplaySH1107_64x128<InterfaceSH1107<I>>
561 {
562 public:
570  template <typename... Args>
571  DisplaySH1107_64x128_CustomI2C(int8_t rstPin, Args &&... data)
572  : DisplaySH1107_64x128<InterfaceSH1107<I>>(m_i2c, rstPin)
573  , m_i2c(*this, -1, data...)
574  {
575  }
576 
580  void begin() override
581  {
582  m_i2c.begin();
583  DisplaySH1107_64x128<InterfaceSH1107<I>>::beginController();
584  }
585 
589  void end() override
590  {
591  DisplaySH1107_64x128<InterfaceSH1107<I>>::endController();
592  m_i2c.end();
593  }
594 
595 private:
596  InterfaceSH1107<I> m_i2c;
597 };
598 #include "lcd_sh1107.inl"
599 
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:305
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:571
uint8_t lcduint_t
Definition: canvas_types.h:79
void setStartLine(uint8_t line)
Definition: lcd_sh1107.inl:83
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
uint8_t getStartLine()
Definition: lcd_sh1107.inl:92
InterfaceSH1107(NanoDisplayBase< InterfaceSH1107< I >> &base, int8_t dc, Args &&... data)
Definition: lcd_sh1107.h:54
void flipHorizontal(uint8_t mode)
performs horizontal flip
Definition: lcd_sh1107.inl:133
void setContrast(uint8_t contrast)
Definition: lcd_sh1107.inl:111
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:384
DisplaySH1107_128x64(I &intf, int8_t rstPin)
Definition: lcd_sh1107.h:236
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_sh1107.h:211
void flipVertical(uint8_t mode)
performs vertical flip
Definition: lcd_sh1107.inl:140
DisplaySH1107_64x128(I &intf, int8_t rstPin)
Definition: lcd_sh1107.h:423
void setDisplayOffset(uint8_t offset)
Definition: lcd_sh1107.inl:152
DisplaySH1107(I &intf, int8_t rstPin)
Definition: lcd_sh1107.h:204
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:492
void setDataMode(uint8_t mode)
Definition: lcd_sh1107.inl:66
void setSegOffset(uint8_t offset)
Definition: lcd_sh1107.inl:147
void commandStart()
Definition: lcd_sh1107.inl:74