LCDGFX LCD display driver  2.0.1
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 (c) 2019, 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 <class I>
44 class InterfaceSH1106: public I
45 {
46 public:
54  template <typename... Args>
55  InterfaceSH1106(NanoDisplayBase<InterfaceSH1106<I>> &base, int8_t dc, Args&&... data)
56  : I(data...)
57  , m_dc( dc )
58  , m_base(base)
59  {
60  }
61 
78 
86  void nextBlock();
87 
91  void endBlock();
92 
97  void spiDataMode(uint8_t mode);
98 
103  void commandStart();
104 
110  void setStartLine(uint8_t line);
111 
115  uint8_t getStartLine();
116 
121  void normalMode();
122 
127  void invertMode();
128 
133  void setContrast(uint8_t contrast);
134 
138  void displayOff();
139 
143  void displayOn();
144 
154  void flipHorizontal(uint8_t mode);
155 
165  void flipVertical(uint8_t mode);
166 
167 private:
168  int8_t m_dc = -1;
170  uint8_t m_startLine = 0;
171  uint8_t m_column;
172  uint8_t m_page;
173 };
174 
175 
179 template <class I>
180 class DisplaySH1106: public NanoDisplayOps<NanoDisplayOps1<I>,I>
181 {
182 public:
189  DisplaySH1106(I &intf, int8_t rstPin)
190  : NanoDisplayOps<NanoDisplayOps1<I>, I>(intf)
191  , m_rstPin( rstPin ) { }
192 
193 protected:
194  int8_t m_rstPin;
195 
199  void begin() override;
200 
204  void end() override;
205 };
206 
210 template <class I>
212 {
213 public:
220  DisplaySH1106_128x64(I &intf, int8_t rstPin)
221  : DisplaySH1106<I>(intf, rstPin) { }
222 
223 protected:
224 
228  void begin() override;
229 
233  void end() override;
234 };
235 
239 class DisplaySH1106_128x64_SPI: public DisplaySH1106_128x64<InterfaceSH1106<PlatformSpi>>
240 {
241 public:
249  DisplaySH1106_128x64_SPI( int8_t rstPin, const SPlatformSpiConfig &config = { -1, { -1 }, -1, 0, -1, -1 } )
250  : DisplaySH1106_128x64(m_spi, rstPin)
251  , m_spi( *this, config.dc,
252  SPlatformSpiConfig{ config.busId,
253  { config.cs },
254  config.dc,
255  config.frequency ?: 10000000,
256  config.scl,
257  config.sda } ) {}
258 
262  void begin() override;
263 
267  void end() override;
268 
269 private:
271 };
272 
276 class DisplaySH1106_128x64_I2C: public DisplaySH1106_128x64<InterfaceSH1106<PlatformI2c>>
277 {
278 public:
286  DisplaySH1106_128x64_I2C( int8_t rstPin, const SPlatformI2cConfig &config = { -1, 0x3C, -1, -1, 0 } )
287  : DisplaySH1106_128x64(m_i2c, rstPin)
288  , m_i2c( *this, -1,
289  SPlatformI2cConfig{ config.busId,
290  static_cast<uint8_t>(config.addr ?: 0x3C),
291  config.scl,
292  config.sda,
293  config.frequency ?: 400000 } ) {}
294 
298  void begin() override;
299 
303  void end() override;
304 
305 private:
307 };
308 
309 #include "lcd_sh1106.inl"
310 
uint8_t lcduint_t
Definition: canvas_types.h:81
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:286
DisplaySH1106_128x64(I &intf, int8_t rstPin)
Definition: lcd_sh1106.h:220
void flipHorizontal(uint8_t mode)
performs horizontal flip
Definition: lcd_sh1106.inl:145
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_sh1106.h:194
void setStartLine(uint8_t line)
Definition: lcd_sh1106.inl:89
InterfaceSH1106(NanoDisplayBase< InterfaceSH1106< I >> &base, int8_t dc, Args &&... data)
Definition: lcd_sh1106.h:55
void flipVertical(uint8_t mode)
performs vertical flip
Definition: lcd_sh1106.inl:153
void commandStart()
Definition: lcd_sh1106.inl:79
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:36
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:249
void spiDataMode(uint8_t mode)
Definition: lcd_sh1106.inl:70
uint8_t getStartLine()
Definition: lcd_sh1106.inl:98
void setContrast(uint8_t contrast)
Definition: lcd_sh1106.inl:120
DisplaySH1106(I &intf, int8_t rstPin)
Definition: lcd_sh1106.h:189