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 };
255 class DisplaySH1107_128x64_SPI: public DisplaySH1107_128x64<InterfaceSH1107<PlatformSpi>>
256 {
257 public:
265  explicit DisplaySH1107_128x64_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0, -1, -1})
266  : DisplaySH1107_128x64(m_spi, rstPin)
267  , m_spi(*this, config.dc,
269  config.busId, {config.cs}, config.dc, config.frequency ?: 10000000, config.scl, config.sda})
270  {
271  }
272 
276  void begin() override;
277 
281  void end() override;
282 
283 private:
285 };
286 
291 template <typename I> class DisplaySH1107_128x64_CustomSPI: public DisplaySH1107_128x64<InterfaceSH1107<I>>
292 {
293 public:
302  template <typename... Args>
303  DisplaySH1107_128x64_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
304  : DisplaySH1107_128x64<InterfaceSH1107<I>>(m_spi, rstPin)
305  , m_spi(*this, dcPin, data...)
306  {
307  }
308 
312  void begin() override
313  {
314  m_spi.begin();
315  DisplaySH1107_128x64<InterfaceSH1107<I>>::beginController();
316  }
317 
321  void end() override
322  {
323  DisplaySH1107_128x64<InterfaceSH1107<I>>::endController();
324  m_spi.end();
325  }
326 
327 private:
328  InterfaceSH1107<I> m_spi;
329 };
333 class DisplaySH1107_128x64_I2C: public DisplaySH1107_128x64<InterfaceSH1107<PlatformI2c>>
334 {
335 public:
343  explicit DisplaySH1107_128x64_I2C(int8_t rstPin, const SPlatformI2cConfig &config = {-1, 0x3C, -1, -1, 0})
344  : DisplaySH1107_128x64(m_i2c, rstPin)
345  , m_i2c(*this, -1,
346  SPlatformI2cConfig{config.busId, static_cast<uint8_t>(config.addr ?: 0x3C), config.scl, config.sda,
347  config.frequency ?: 400000})
348  {
349  }
350 
354  void begin() override;
355 
359  void end() override;
360 
361 private:
363 };
364 
369 template <typename I> class DisplaySH1107_128x64_CustomI2C: public DisplaySH1107_128x64<InterfaceSH1107<I>>
370 {
371 public:
379  template <typename... Args>
380  DisplaySH1107_128x64_CustomI2C(int8_t rstPin, Args &&... data)
381  : DisplaySH1107_128x64<InterfaceSH1107<I>>(m_i2c, rstPin)
382  , m_i2c(*this, -1, data...)
383  {
384  }
385 
389  void begin() override
390  {
391  m_i2c.begin();
392  DisplaySH1107_128x64<InterfaceSH1107<I>>::beginController();
393  }
394 
398  void end() override
399  {
400  DisplaySH1107_128x64<InterfaceSH1107<I>>::endController();
401  m_i2c.end();
402  }
403 
404 private:
405  InterfaceSH1107<I> m_i2c;
406 };
410 template <typename I> class DisplaySH1107_64x128: public DisplaySH1107<I>
411 {
412 public:
419  DisplaySH1107_64x128(I &intf, int8_t rstPin)
420  : DisplaySH1107<I>(intf, rstPin)
421  {
422  }
423 
424 protected:
428  void beginController();
429 
433  void endController();
434 };
438 class DisplaySH1107_64x128_SPI: public DisplaySH1107_64x128<InterfaceSH1107<PlatformSpi>>
439 {
440 public:
448  explicit DisplaySH1107_64x128_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0, -1, -1})
449  : DisplaySH1107_64x128(m_spi, rstPin)
450  , m_spi(*this, config.dc,
452  config.busId, {config.cs}, config.dc, config.frequency ?: 10000000, config.scl, config.sda})
453  {
454  }
455 
459  void begin() override;
460 
464  void end() override;
465 
466 private:
468 };
469 
474 template <typename I> class DisplaySH1107_64x128_CustomSPI: public DisplaySH1107_64x128<InterfaceSH1107<I>>
475 {
476 public:
485  template <typename... Args>
486  DisplaySH1107_64x128_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
487  : DisplaySH1107_64x128<InterfaceSH1107<I>>(m_spi, rstPin)
488  , m_spi(*this, dcPin, data...)
489  {
490  }
491 
495  void begin() override
496  {
497  m_spi.begin();
498  DisplaySH1107_64x128<InterfaceSH1107<I>>::beginController();
499  }
500 
504  void end() override
505  {
506  DisplaySH1107_64x128<InterfaceSH1107<I>>::endController();
507  m_spi.end();
508  }
509 
510 private:
511  InterfaceSH1107<I> m_spi;
512 };
516 class DisplaySH1107_64x128_I2C: public DisplaySH1107_64x128<InterfaceSH1107<PlatformI2c>>
517 {
518 public:
526  explicit DisplaySH1107_64x128_I2C(int8_t rstPin, const SPlatformI2cConfig &config = {-1, 0x3C, -1, -1, 0})
527  : DisplaySH1107_64x128(m_i2c, rstPin)
528  , m_i2c(*this, -1,
529  SPlatformI2cConfig{config.busId, static_cast<uint8_t>(config.addr ?: 0x3C), config.scl, config.sda,
530  config.frequency ?: 400000})
531  {
532  }
533 
537  void begin() override;
538 
542  void end() override;
543 
544 private:
546 };
547 
552 template <typename I> class DisplaySH1107_64x128_CustomI2C: public DisplaySH1107_64x128<InterfaceSH1107<I>>
553 {
554 public:
562  template <typename... Args>
563  DisplaySH1107_64x128_CustomI2C(int8_t rstPin, Args &&... data)
564  : DisplaySH1107_64x128<InterfaceSH1107<I>>(m_i2c, rstPin)
565  , m_i2c(*this, -1, data...)
566  {
567  }
568 
572  void begin() override
573  {
574  m_i2c.begin();
575  DisplaySH1107_64x128<InterfaceSH1107<I>>::beginController();
576  }
577 
581  void end() override
582  {
583  DisplaySH1107_64x128<InterfaceSH1107<I>>::endController();
584  m_i2c.end();
585  }
586 
587 private:
588  InterfaceSH1107<I> m_i2c;
589 };
590 #include "lcd_sh1107.inl"
591 
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:303
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:563
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:380
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
DisplaySH1107_128x64_SPI(int8_t rstPin, const SPlatformSpiConfig &config={-1, {-1}, -1, 0, -1, -1})
Inits 128x64 lcd display over spi (based on SH1107 controller): 1-bit mode.
Definition: lcd_sh1107.h:265
void flipVertical(uint8_t mode)
performs vertical flip
Definition: lcd_sh1107.inl:140
DisplaySH1107_64x128(I &intf, int8_t rstPin)
Definition: lcd_sh1107.h:419
void setDisplayOffset(uint8_t offset)
Definition: lcd_sh1107.inl:152
DisplaySH1107_64x128_I2C(int8_t rstPin, const SPlatformI2cConfig &config={-1, 0x3C, -1, -1, 0})
Inits 64x128 lcd display over i2c (based on SH1107 controller): 1-bit mode.
Definition: lcd_sh1107.h:526
DisplaySH1107(I &intf, int8_t rstPin)
Definition: lcd_sh1107.h:204
DisplaySH1107_128x64_I2C(int8_t rstPin, const SPlatformI2cConfig &config={-1, 0x3C, -1, -1, 0})
Inits 128x64 lcd display over i2c (based on SH1107 controller): 1-bit mode.
Definition: lcd_sh1107.h:343
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:486
void setDataMode(uint8_t mode)
Definition: lcd_sh1107.inl:66
void setSegOffset(uint8_t offset)
Definition: lcd_sh1107.inl:147
DisplaySH1107_64x128_SPI(int8_t rstPin, const SPlatformSpiConfig &config={-1, {-1}, -1, 0, -1, -1})
Inits 64x128 lcd display over spi (based on SH1107 controller): 1-bit mode.
Definition: lcd_sh1107.h:448
void commandStart()
Definition: lcd_sh1107.inl:74