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 };
236 class DisplaySH1106_128x64_SPI: public DisplaySH1106_128x64<InterfaceSH1106<PlatformSpi>>
237 {
238 public:
246  explicit DisplaySH1106_128x64_SPI(int8_t rstPin, const SPlatformSpiConfig &config = {-1, {-1}, -1, 0, -1, -1})
247  : DisplaySH1106_128x64(m_spi, rstPin)
248  , m_spi(*this, config.dc,
250  config.busId, {config.cs}, config.dc, config.frequency ?: 10000000, config.scl, config.sda})
251  {
252  }
253 
257  void begin() override;
258 
262  void end() override;
263 
264 private:
266 };
267 
272 template <typename I> class DisplaySH1106_128x64_CustomSPI: public DisplaySH1106_128x64<InterfaceSH1106<I>>
273 {
274 public:
283  template <typename... Args>
284  DisplaySH1106_128x64_CustomSPI(int8_t rstPin, int8_t dcPin, Args &&... data)
285  : DisplaySH1106_128x64<InterfaceSH1106<I>>(m_spi, rstPin)
286  , m_spi(*this, dcPin, data...)
287  {
288  }
289 
293  void begin() override
294  {
295  m_spi.begin();
296  DisplaySH1106_128x64<InterfaceSH1106<I>>::beginController();
297  }
298 
302  void end() override
303  {
304  DisplaySH1106_128x64<InterfaceSH1106<I>>::endController();
305  m_spi.end();
306  }
307 
308 private:
309  InterfaceSH1106<I> m_spi;
310 };
314 class DisplaySH1106_128x64_I2C: public DisplaySH1106_128x64<InterfaceSH1106<PlatformI2c>>
315 {
316 public:
324  explicit DisplaySH1106_128x64_I2C(int8_t rstPin, const SPlatformI2cConfig &config = {-1, 0x3C, -1, -1, 0})
325  : DisplaySH1106_128x64(m_i2c, rstPin)
326  , m_i2c(*this, -1,
327  SPlatformI2cConfig{config.busId, static_cast<uint8_t>(config.addr ?: 0x3C), config.scl, config.sda,
328  config.frequency ?: 400000})
329  {
330  }
331 
335  void begin() override;
336 
340  void end() override;
341 
342 private:
344 };
345 
350 template <typename I> class DisplaySH1106_128x64_CustomI2C: public DisplaySH1106_128x64<InterfaceSH1106<I>>
351 {
352 public:
360  template <typename... Args>
361  DisplaySH1106_128x64_CustomI2C(int8_t rstPin, Args &&... data)
362  : DisplaySH1106_128x64<InterfaceSH1106<I>>(m_i2c, rstPin)
363  , m_i2c(*this, -1, data...)
364  {
365  }
366 
370  void begin() override
371  {
372  m_i2c.begin();
373  DisplaySH1106_128x64<InterfaceSH1106<I>>::beginController();
374  }
375 
379  void end() override
380  {
381  DisplaySH1106_128x64<InterfaceSH1106<I>>::endController();
382  m_i2c.end();
383  }
384 
385 private:
386  InterfaceSH1106<I> m_i2c;
387 };
388 #include "lcd_sh1106.inl"
389 
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:284
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
DisplaySH1106_128x64_SPI(int8_t rstPin, const SPlatformSpiConfig &config={-1, {-1}, -1, 0, -1, -1})
Inits 128x64 lcd display over spi (based on SH1106 controller): 1-bit mode.
Definition: lcd_sh1106.h:246
void flipVertical(uint8_t mode)
performs vertical flip
Definition: lcd_sh1106.inl:139
void commandStart()
Definition: lcd_sh1106.inl:74
DisplaySH1106_128x64_I2C(int8_t rstPin, const SPlatformI2cConfig &config={-1, 0x3C, -1, -1, 0})
Inits 128x64 lcd display over i2c (based on SH1106 controller): 1-bit mode.
Definition: lcd_sh1106.h:324
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:361
void setContrast(uint8_t contrast)
Definition: lcd_sh1106.inl:110
DisplaySH1106(I &intf, int8_t rstPin)
Definition: lcd_sh1106.h:185