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.inl
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 !!! */
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 
35 template <class I>
37 {
38  commandStart();
39  this->send(0x21); // column addr
40  this->send(x);
41  this->send(w ? (x + w - 1) : (m_base.width() - 1));
42  this->send(0x22); // page addr
43  this->send(y);
44  this->send((m_base.height() >> 3) - 1);
45  if (m_dc >= 0)
46  {
47  spiDataMode(1);
48  }
49  else
50  {
51  this->stop();
52  this->start();
53  this->send(0x40);
54  }
55 }
56 
57 template <class I>
59 {
60 
61 }
62 
63 template <class I>
65 {
66  this->stop();
67 }
68 
69 template <class I>
71 {
72  if ( m_dc >= 0 )
73  {
74  lcd_gpioWrite( m_dc, mode ? LCD_HIGH : LCD_LOW );
75  }
76 }
77 
78 template <class I>
80 {
81  this->start();
82  if (m_dc >= 0)
83  spiDataMode(0);
84  else
85  this->send(0x00);
86 }
87 
88 template <class I>
90 {
91  m_startLine = line;
92  commandStart();
93  this->send( 0x40 | (line & 0x3F) ); // start line
94  this->stop();
95 }
96 
97 template <class I>
99 {
100  return m_startLine;
101 }
102 
103 template <class I>
105 {
106  commandStart();
107  this->send(0xA6); // Normal display
108  this->stop();
109 }
110 
111 template <class I>
113 {
114  commandStart();
115  this->send(0xA7); // Invert display
116  this->stop();
117 }
118 
119 template <class I>
120 void InterfaceSSD1306<I>::setContrast(uint8_t contrast)
121 {
122  commandStart();
123  this->send(0x81); // set contrast
124  this->send(contrast);
125  this->stop();
126 }
127 
128 template <class I>
130 {
131  commandStart();
132  this->send(0xAE); // display off
133  this->stop();
134 }
135 
136 template <class I>
138 {
139  commandStart();
140  this->send(0xAF); // display on
141  this->stop();
142 }
143 
144 template <class I>
146 {
147  commandStart();
148  this->send( 0xA0 | (mode ? 0x00: 0x01 ) ); // seg remap
149  this->stop();
150 }
151 
152 template <class I>
154 {
155  commandStart();
156  this->send( mode ? 0xC0 : 0xC8 );
157  this->stop();
158 }
159 
160 
162 // SSD1306 basic 1-bit implementation
164 
165 template <class I>
167 {
168 }
169 
170 template <class I>
172 {
173 }
174 
175 static const PROGMEM uint8_t s_SSD1306_lcd128x32_initData[] =
176 {
177 #ifdef SDL_EMULATION
178  SDL_LCD_SSD1306, 0x00,
179  0x00, 0x00,
180 #endif
181  0xAE, 0x00, // display off
182  0xD5, 0x01, 0x80, // Clock div
183  0xA8, 0x01, 31, // Set multiplex
184  0xD3, 0x01, 0x00, // --no offset
185  0x40, 0x00, // Set display offset
186  0x8D, 0x01, 0x14, // Set charge pump
187  0xA0| 0x01, 0x00, // Reverse mapping
188  0xC8, 0x00, // Decrement
189  0xDA, 0x01, 0x02, // Set com pins
190  0x81, 0x01, 0x7F, // contast value
191  0xD9, 0x01, 0x22, // 0x1F Precharge
192  0xDB, 0x01, 0x40, // Precharge
193  0x20, 0x01, 0x00, // Set horizontal addressing mode
194  0xA4, 0x00, // Display resume
195  0xA6, 0x00, // Normal display
196  0xAF, 0x00, // Display on
197 };
198 
200 // SSD1306 basic 1-bit implementation
202 
203 template <class I>
205 {
206  ssd1306_resetController2( this->m_rstPin, 10 );
207  this->m_w = 128;
208  this->m_h = 32;
209  // Give LCD some time to initialize. Refer to SSD1306 datasheet
210  lcd_delay(0);
211  _configureSpiDisplayCmdModeOnly<I>(this->m_intf,
212  s_SSD1306_lcd128x32_initData,
213  sizeof(s_SSD1306_lcd128x32_initData));
214 }
215 
216 template <class I>
218 {
219 }
220 
221 static const PROGMEM uint8_t s_SSD1306_lcd128x64_initData[] =
222 {
223 #ifdef SDL_EMULATION
224  SDL_LCD_SSD1306, 0x00,
225  0x00, 0x00,
226 #endif
227  0xAE, 0x00, // display off
228  0x20, 0x01, 0x00, // Page horizontal Addressing mode
229  0xC8, 0x00, // Scan from 127 to 0 (Reverse scan)
230  0x40| 0x00, 0x00, // First line to start scanning from
231  0x81, 0x01, 0x7F, // contast value to 0x7F according to datasheet
232  0xA0| 0x01, 0x00, // Use reverse mapping. 0x00 - is normal mapping
233  0xA6, 0x00, // Normal display
234  0xA8, 0x01, 63, // Reset to default MUX. See datasheet
235  0xD3, 0x01, 0x00, // no offset
236  0xD5, 0x01, 0x80, // set to default ratio/osc frequency
237  0xD9, 0x01, 0x22, // switch precharge to 0x22 // 0xF1
238  0xDA, 0x01, 0x12, // set divide ratio
239  0xDB, 0x01, 0x20, // vcom deselect to 0x20 // 0x40
240  0x8D, 0x01, 0x14, // Enable charge pump
241  0xA4, 0x00, // Display resume
242  0xAF, 0x00, // Display on
243 };
244 
246 // SSD1306 basic 1-bit implementation
248 
249 template <class I>
251 {
252  ssd1306_resetController2( this->m_rstPin, 10 );
253  this->m_w = 128;
254  this->m_h = 64;
255  // Give LCD some time to initialize. Refer to SSD1306 datasheet
256  lcd_delay(0);
257  _configureSpiDisplayCmdModeOnly<I>(this->m_intf,
258  s_SSD1306_lcd128x64_initData,
259  sizeof(s_SSD1306_lcd128x64_initData));
260 }
261 
262 template <class I>
264 {
265 }
void setStartLine(uint8_t line)
Definition: lcd_ssd1306.inl:89
uint8_t lcduint_t
Definition: canvas_types.h:81
void lcd_gpioWrite(int pin, int level)
void flipVertical(uint8_t mode)
performs vertical flip
void spiDataMode(uint8_t mode)
Definition: lcd_ssd1306.inl:70
void ssd1306_resetController2(int8_t rstPin, uint8_t delayMs)
Does hardware reset for oled controller.
uint8_t getStartLine()
Definition: lcd_ssd1306.inl:98
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 end() override
void flipHorizontal(uint8_t mode)
performs horizontal flip
#define LCD_LOW
Definition: io.h:140
void setContrast(uint8_t contrast)
void begin() override
void end() override
void begin() override
#define LCD_HIGH
Definition: io.h:142
void begin() override
void lcd_delay(unsigned long ms)
void end() override