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.inl
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 !!! */
25 #include "lcd_hal/io.h"
26 #ifdef SDL_EMULATION
27 #include "sdl_core.h"
28 #endif
29 #include "nano_gfx_types.h"
30 
31 #ifndef CMD_ARG
32 #define CMD_ARG 0xFF
33 #endif
34 
36 {
37  m_column = x;
38  m_page = y;
39  commandStart();
40  this->send(0xB0 | y); // set page
41  this->send(((x+2)>>4) | 0x10); // high column
42  this->send(((x+2) & 0x0f)); // low column
43  if ( m_dc >= 0 )
44  {
45  setDataMode(1);
46  }
47  else
48  {
49  this->stop();
50  this->start();
51  this->send(0x40);
52  }
53 }
54 
55 template <class I> void InterfaceSH1106<I>::nextBlock()
56 {
57  this->stop();
58  startBlock(m_column,m_page+1,0);
59 }
60 
61 template <class I> void InterfaceSH1106<I>::endBlock()
62 {
63  this->stop();
64 }
65 
66 template <class I> void InterfaceSH1106<I>::setDataMode(uint8_t mode)
67 {
68  if ( m_dc >= 0 )
69  {
70  lcd_gpioWrite(m_dc, mode ? LCD_HIGH : LCD_LOW);
71  }
72 }
73 
74 template <class I> void InterfaceSH1106<I>::commandStart()
75 {
76  this->start();
77  if ( m_dc >= 0 )
78  setDataMode(0);
79  else
80  this->send(0x00);
81 }
82 
83 template <class I> void InterfaceSH1106<I>::setStartLine(uint8_t line)
84 {
85  m_startLine = line;
86  commandStart();
87  this->send( 0x40 | (line & 0x3F) ); // start line
88  this->stop();
89 }
90 
91 template <class I> uint8_t InterfaceSH1106<I>::getStartLine()
92 {
93  return m_startLine;
94 }
95 
96 template <class I> void InterfaceSH1106<I>::normalMode()
97 {
98  commandStart();
99  this->send(0xA6); // Normal display
100  this->stop();
101 }
102 
103 template <class I> void InterfaceSH1106<I>::invertMode()
104 {
105  commandStart();
106  this->send(0xA7); // Invert display
107  this->stop();
108 }
109 
110 template <class I> void InterfaceSH1106<I>::setContrast(uint8_t contrast)
111 {
112  commandStart();
113  this->send(0x81); // set contrast
114  this->send(contrast);
115  this->stop();
116 }
117 
118 template <class I> void InterfaceSH1106<I>::displayOff()
119 {
120  commandStart();
121  this->send(0xAE); // display off
122  this->stop();
123 }
124 
125 template <class I> void InterfaceSH1106<I>::displayOn()
126 {
127  commandStart();
128  this->send(0xAF); // display on
129  this->stop();
130 }
131 
132 template <class I> void InterfaceSH1106<I>::flipHorizontal(uint8_t mode)
133 {
134  commandStart();
135  this->send( 0xA0 | (mode ? 0x00: 0x01 ) ); // seg remap
136  this->stop();
137 }
138 
139 template <class I> void InterfaceSH1106<I>::flipVertical(uint8_t mode)
140 {
141  commandStart();
142  this->send( mode ? 0xC0 : 0xC8 );
143  this->stop();
144 }
145 
146 
148 // SH1106 basic 1-bit implementation
150 
151 template <class I> void DisplaySH1106<I>::beginDisplay()
152 {
153 }
154 
155 template <class I> void DisplaySH1106<I>::endDisplay()
156 {
157 }
158 
159 static const PROGMEM uint8_t s_SH1106_lcd128x64_initData[] = {
160 #ifdef SDL_EMULATION
161  SDL_LCD_SH1106, 0x00,
162  0x00, 0x00,
163 #endif
164  0xAE, 0x00, // display off
165  0xC8, 0x00, // Scan from 127 to 0 (Reverse scan)
166  0x40, 0x00, // First line to start scanning from
167  0x81, 0x01, 0x7F, // contast value to 0x7F according to datasheet
168  0xA0| 0x01, 0x00, // Use reverse mapping. 0x00 - is normal mapping
169  0xA6, 0x00, // Normal display
170  0xA8, 0x01, 63, // Reset to default MUX. See datasheet
171  0xD3, 0x01, 0x00, // no offset
172  0xD5, 0x01, 0x80, // set to default ratio/osc frequency
173  0xD9, 0x01, 0x22, // switch precharge to 0x22 // 0xF1
174  0xDA, 0x01, 0x12, // set divide ratio com pins
175  0xDB, 0x01, 0x20, // vcom deselect to 0x20 // 0x40
176  0x8D, 0x01, 0x14, // Enable charge pump
177  0xA4, 0x00, // Display on resume
178  0xAF, 0x00, // Display on
179 };
180 
182 // SH1106 basic 1-bit implementation
184 
186 {
187  ssd1306_resetController2(this->m_rstPin, 10);
188  this->m_w = 128;
189  this->m_h = 64;
190  // Give LCD some time to initialize. Refer to SH1106 datasheet
191  lcd_delay(0);
192  _configureSpiDisplayCmdModeOnly<I>(this->m_intf,
193  s_SH1106_lcd128x64_initData,
194  sizeof(s_SH1106_lcd128x64_initData));
195 
196 }
197 
198 template <class I> void DisplaySH1106_128x64<I>::endController()
199 {
200 }
uint8_t lcduint_t
Definition: canvas_types.h:79
void setDataMode(uint8_t mode)
Definition: lcd_sh1106.inl:66
void endDisplay()
Definition: lcd_sh1106.inl:155
void lcd_gpioWrite(int pin, int level)
void flipHorizontal(uint8_t mode)
performs horizontal flip
Definition: lcd_sh1106.inl:132
void ssd1306_resetController2(int8_t rstPin, uint8_t delayMs)
Does hardware reset for oled controller.
void setStartLine(uint8_t line)
Definition: lcd_sh1106.inl:83
void flipVertical(uint8_t mode)
performs vertical flip
Definition: lcd_sh1106.inl:139
void commandStart()
Definition: lcd_sh1106.inl:74
#define LCD_LOW
Definition: io.h:175
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
void setContrast(uint8_t contrast)
Definition: lcd_sh1106.inl:110
#define LCD_HIGH
Definition: io.h:177
void beginDisplay()
Definition: lcd_sh1106.inl:151
void lcd_delay(unsigned long ms)