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_ssd1306.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 InterfaceSSD1306: public I
45 {
46 public:
54  template <typename... Args>
55  InterfaceSSD1306(NanoDisplayBase<InterfaceSSD1306<I>> &base, int8_t dc, Args&&... data)
56  : I(data...)
57  , m_dc( dc )
58  , m_base(base)
59  {
60  }
61 
78 
85  void nextBlock();
86 
90  void endBlock();
91 
96  void spiDataMode(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 };
171 
172 
176 template <class I>
177 class DisplaySSD1306: public NanoDisplayOps<NanoDisplayOps1<I>,I>
178 {
179 public:
186  DisplaySSD1306(I &intf, int8_t rstPin)
187  : NanoDisplayOps<NanoDisplayOps1<I>, I>(intf)
188  , m_rstPin( rstPin ) { }
189 
190 protected:
191  int8_t m_rstPin;
192 
196  void begin() override;
197 
201  void end() override;
202 };
203 
207 template <class I>
209 {
210 public:
217  DisplaySSD1306_128x32(I &intf, int8_t rstPin)
218  : DisplaySSD1306<I>(intf, rstPin) { }
219 
220 protected:
221 
225  void begin() override;
226 
230  void end() override;
231 };
232 
236 class DisplaySSD1306_128x32_SPI: public DisplaySSD1306_128x32<InterfaceSSD1306<PlatformSpi>>
237 {
238 public:
246  DisplaySSD1306_128x32_SPI( int8_t rstPin, const SPlatformSpiConfig &config = { -1, { -1 }, -1, 0, -1, -1 } )
247  : DisplaySSD1306_128x32(m_spi, rstPin)
248  , m_spi( *this, config.dc,
249  SPlatformSpiConfig{ config.busId,
250  { config.cs },
251  config.dc,
252  config.frequency ?: 10000000,
253  config.scl,
254  config.sda } ) {}
255 
259  void begin() override;
260 
264  void end() override;
265 
266 private:
268 };
269 
273 class DisplaySSD1306_128x32_I2C: public DisplaySSD1306_128x32<InterfaceSSD1306<PlatformI2c>>
274 {
275 public:
283  DisplaySSD1306_128x32_I2C( int8_t rstPin, const SPlatformI2cConfig &config = { -1, 0x3C, -1, -1, 0 } )
284  : DisplaySSD1306_128x32(m_i2c, rstPin)
285  , m_i2c( *this, -1,
286  SPlatformI2cConfig{ config.busId,
287  static_cast<uint8_t>(config.addr ?: 0x3C),
288  config.scl,
289  config.sda,
290  config.frequency ?: 400000 } ) {}
291 
295  void begin() override;
296 
300  void end() override;
301 
302 private:
304 };
305 
309 template <class I>
311 {
312 public:
319  DisplaySSD1306_128x64(I &intf, int8_t rstPin)
320  : DisplaySSD1306<I>(intf, rstPin) { }
321 
322 protected:
323 
327  void begin() override;
328 
332  void end() override;
333 };
334 
338 class DisplaySSD1306_128x64_SPI: public DisplaySSD1306_128x64<InterfaceSSD1306<PlatformSpi>>
339 {
340 public:
348  DisplaySSD1306_128x64_SPI( int8_t rstPin, const SPlatformSpiConfig &config = { -1, { -1 }, -1, 0, -1, -1 } )
349  : DisplaySSD1306_128x64(m_spi, rstPin)
350  , m_spi( *this, config.dc,
351  SPlatformSpiConfig{ config.busId,
352  { config.cs },
353  config.dc,
354  config.frequency ?: 10000000,
355  config.scl,
356  config.sda } ) {}
357 
361  void begin() override;
362 
366  void end() override;
367 
368 private:
370 };
371 
375 class DisplaySSD1306_128x64_I2C: public DisplaySSD1306_128x64<InterfaceSSD1306<PlatformI2c>>
376 {
377 public:
385  DisplaySSD1306_128x64_I2C( int8_t rstPin, const SPlatformI2cConfig &config = { -1, 0x3C, -1, -1, 0 } )
386  : DisplaySSD1306_128x64(m_i2c, rstPin)
387  , m_i2c( *this, -1,
388  SPlatformI2cConfig{ config.busId,
389  static_cast<uint8_t>(config.addr ?: 0x3C),
390  config.scl,
391  config.sda,
392  config.frequency ?: 400000 } ) {}
393 
397  void begin() override;
398 
402  void end() override;
403 
404 private:
406 };
407 
408 #include "lcd_ssd1306.inl"
409 
void setStartLine(uint8_t line)
Definition: lcd_ssd1306.inl:89
uint8_t lcduint_t
Definition: canvas_types.h:81
DisplaySSD1306_128x64(I &intf, int8_t rstPin)
Definition: lcd_ssd1306.h:319
DisplaySSD1306_128x32_I2C(int8_t rstPin, const SPlatformI2cConfig &config={ -1, 0x3C, -1, -1, 0 })
Inits 128x32 lcd display over i2c (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:283
void flipVertical(uint8_t mode)
performs vertical flip
DisplaySSD1306(I &intf, int8_t rstPin)
Definition: lcd_ssd1306.h:186
DisplaySSD1306_128x64_I2C(int8_t rstPin, const SPlatformI2cConfig &config={ -1, 0x3C, -1, -1, 0 })
Inits 128x64 lcd display over i2c (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:385
void spiDataMode(uint8_t mode)
Definition: lcd_ssd1306.inl:70
uint8_t getStartLine()
Definition: lcd_ssd1306.inl:98
InterfaceSSD1306(NanoDisplayBase< InterfaceSSD1306< I >> &base, int8_t dc, Args &&... data)
Definition: lcd_ssd1306.h:55
int8_t m_rstPin
indicates hardware reset pin used, -1 if it is not required
Definition: lcd_ssd1306.h:191
DisplaySSD1306_128x32_SPI(int8_t rstPin, const SPlatformSpiConfig &config={ -1, { -1 }, -1, 0, -1, -1 })
Inits 128x32 lcd display over spi (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:246
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_ssd1306.inl:36
void flipHorizontal(uint8_t mode)
performs horizontal flip
void setContrast(uint8_t contrast)
DisplaySSD1306_128x32(I &intf, int8_t rstPin)
Definition: lcd_ssd1306.h:217
DisplaySSD1306_128x64_SPI(int8_t rstPin, const SPlatformSpiConfig &config={ -1, { -1 }, -1, 0, -1, -1 })
Inits 128x64 lcd display over spi (based on SSD1306 controller): 1-bit mode.
Definition: lcd_ssd1306.h:348