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_sh1106.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 InterfaceSH1106: public I
44 {
45 public:
53  template <typename... Args>
54  InterfaceSH1106(NanoDisplayBase<InterfaceSH1106<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 
166 private:
167  int8_t m_dc = -1;
169  uint8_t m_startLine = 0;
170  uint8_t m_column = 0;
171  uint8_t m_page = 0;
172 };
176 template <typename I> class DisplaySH1106: public NanoDisplayOps<NanoDisplayOps1<I>, I>
177 {
178 public:
185  DisplaySH1106(I &intf, int8_t rstPin)
186  : NanoDisplayOps<NanoDisplayOps1<I>, I>(intf)
187  , m_rstPin(rstPin)
188  {
189  }
190 
191 protected:
192  int8_t m_rstPin;
193 
197  void beginDisplay();
198 
202  void endDisplay();
203 };
204 
208 template <typename I> class DisplaySH1106_128x64: public DisplaySH1106<I>
209 {
210 public:
217  DisplaySH1106_128x64(I &intf, int8_t rstPin)
218  : DisplaySH1106<I>(intf, rstPin)
219  {
220  }
221 
222 protected:
226  void beginController();
227 
231  void endController();
232 };
233 #ifdef CONFIG_LCDGFX_PLATFORM_SPI
234 
237 class DisplaySH1106_128x64_SPI: public DisplaySH1106_128x64<InterfaceSH1106<PlatformSpi>>
238 {
239 public:
247  explicit DisplaySH1106_128x64_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0U, -1, -1})
248  : DisplaySH1106_128x64(m_spi, rstPin)
249  , m_spi(*this, config.dc,
251  config.busId, {config.cs}, config.dc, config.frequency ?: static_cast<uint32_t>(10000000), config.scl, config.sda})
252  {
253  }
254 
258  void begin() override;
259 
263  void end() override;
264 
265 private:
267 };
268 #endif
269 
274 template <typename I> class DisplaySH1106_128x64_CustomSPI: public DisplaySH1106_128x64<InterfaceSH1106<I>>
275 {
276 public:
285  template <typename... Args>
286  DisplaySH1106_128x64_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
287  : DisplaySH1106_128x64<InterfaceSH1106<I>>(m_spi, rstPin)
288  , m_spi(*this, dcPin, data...)
289  {
290  }
291 
295  void begin() override
296  {
297  m_spi.begin();
298  DisplaySH1106_128x64<InterfaceSH1106<I>>::beginController();
299  }
300 
304  void end() override
305  {
306  DisplaySH1106_128x64<InterfaceSH1106<I>>::endController();
307  m_spi.end();
308  }
309 
310 private:
311  InterfaceSH1106<I> m_spi;
312 };
313 #ifdef CONFIG_LCDGFX_PLATFORM_I2C
314 
317 class DisplaySH1106_128x64_I2C: public DisplaySH1106_128x64<InterfaceSH1106<PlatformI2c>>
318 {
319 public:
327  explicit DisplaySH1106_128x64_I2C(int8_t rstPin, const SPlatformI2cConfig &config = {-1, 0x3C, -1, -1, 0U})
328  : DisplaySH1106_128x64(m_i2c, rstPin)
329  , m_i2c(*this, -1,
330  SPlatformI2cConfig{config.busId, static_cast<uint8_t>(config.addr ?: 0x3C), config.scl, config.sda,
331  config.frequency ?: 400000U})
332  {
333  }
334 
338  void begin() override;
339 
343  void end() override;
344 
345 private:
347 };
348 #endif
349 
354 template <typename I> class DisplaySH1106_128x64_CustomI2C: public DisplaySH1106_128x64<InterfaceSH1106<I>>
355 {
356 public:
364  template <typename... Args>
365  DisplaySH1106_128x64_CustomI2C(int8_t rstPin, Args &&... data)
366  : DisplaySH1106_128x64<InterfaceSH1106<I>>(m_i2c, rstPin)
367  , m_i2c(*this, -1, data...)
368  {
369  }
370 
374  void begin() override
375  {
376  m_i2c.begin();
377  DisplaySH1106_128x64<InterfaceSH1106<I>>::beginController();
378  }
379 
383  void end() override
384  {
385  DisplaySH1106_128x64<InterfaceSH1106<I>>::endController();
386  m_i2c.end();
387  }
388 
389 private:
390  InterfaceSH1106<I> m_i2c;
391 };
392 #include "lcd_sh1106.inl"
393 
uint8_t lcduint_t
Definition: canvas_types.h:79
void setDataMode(uint8_t mode)
Definition: lcd_sh1106.inl:66
DisplaySH1106_128x64(I &intf, int8_t rstPin)
Definition: lcd_sh1106.h:217
void flipHorizontal(uint8_t mode)
performs horizontal flip
Definition: lcd_sh1106.inl:132
DisplaySH1106_128x64_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
Inits 128x64 lcd display over spi (based on SH1106 controller): 1-bit mode.
Definition: lcd_sh1106.h:286
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_sh1106.h:192
void setStartLine(uint8_t line)
Definition: lcd_sh1106.inl:83
InterfaceSH1106(NanoDisplayBase< InterfaceSH1106< I >> &base, int8_t dc, Args &&... data)
Definition: lcd_sh1106.h:54
void flipVertical(uint8_t mode)
performs vertical flip
Definition: lcd_sh1106.inl:139
void commandStart()
Definition: lcd_sh1106.inl:74
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_sh1106.inl:35
uint8_t getStartLine()
Definition: lcd_sh1106.inl:91
DisplaySH1106_128x64_CustomI2C(int8_t rstPin, Args &&... data)
Inits 128x64 lcd display over i2c (based on SH1106 controller): 1-bit mode.
Definition: lcd_sh1106.h:365
void setContrast(uint8_t contrast)
Definition: lcd_sh1106.inl:110
DisplaySH1106(I &intf, int8_t rstPin)
Definition: lcd_sh1106.h:185