LCDGFX LCD display driver  1.0.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 (c) 2019-2020, 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  m_column = x;
39  m_page = y;
40  commandStart();
41  this->send(0xB0 | y); // set page
42  this->send(((x+2)>>4) | 0x10); // high column
43  this->send(((x+2) & 0x0f) | 0x00); // low column
44  if (m_dc >= 0)
45  {
46  setDataMode(1);
47  }
48  else
49  {
50  this->stop();
51  this->start();
52  this->send(0x40);
53  }
54 }
55 
56 template <class I>
58 {
59  this->stop();
60  startBlock(m_column,m_page+1,0);
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  setDataMode(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 InterfaceSH1106<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 // SH1106 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_SH1106_lcd128x64_initData[] =
176 {
177 #ifdef SDL_EMULATION
178  SDL_LCD_SH1106, 0x00,
179  0x00, 0x00,
180 #endif
181  0xAE, 0x00, // display off
182  0xC8, 0x00, // Scan from 127 to 0 (Reverse scan)
183  0x40| 0x00, 0x00, // First line to start scanning from
184  0x81, 0x01, 0x7F, // contast value to 0x7F according to datasheet
185  0xA0| 0x01, 0x00, // Use reverse mapping. 0x00 - is normal mapping
186  0xA6, 0x00, // Normal display
187  0xA8, 0x01, 63, // Reset to default MUX. See datasheet
188  0xD3, 0x01, 0x00, // no offset
189  0xD5, 0x01, 0x80, // set to default ratio/osc frequency
190  0xD9, 0x01, 0x22, // switch precharge to 0x22 // 0xF1
191  0xDA, 0x01, 0x12, // set divide ratio com pins
192  0xDB, 0x01, 0x20, // vcom deselect to 0x20 // 0x40
193  0x8D, 0x01, 0x14, // Enable charge pump
194  0xA4, 0x00, // Display on resume
195  0xAF, 0x00, // Display on
196 };
197 
199 // SH1106 basic 1-bit implementation
201 
202 template <class I>
204 {
205  ssd1306_resetController2( this->m_rstPin, 10 );
206  this->m_w = 128;
207  this->m_h = 64;
208  // Give LCD some time to initialize. Refer to SH1106 datasheet
209  lcd_delay(0);
210  _configureSpiDisplayCmdModeOnly<I>(this->m_intf,
211  s_SH1106_lcd128x64_initData,
212  sizeof(s_SH1106_lcd128x64_initData));
213 }
214 
215 template <class I>
217 {
218 }
uint8_t lcduint_t
Definition: canvas_types.h:81
void end() override
Definition: lcd_sh1106.inl:216
void setDataMode(uint8_t mode)
Definition: lcd_sh1106.inl:70
void lcd_gpioWrite(int pin, int level)
void flipHorizontal(uint8_t mode)
performs horizontal flip
Definition: lcd_sh1106.inl:145
void begin() override
Definition: lcd_sh1106.inl:166
void ssd1306_resetController2(int8_t rstPin, uint8_t delayMs)
Does hardware reset for oled controller.
void setStartLine(uint8_t line)
Definition: lcd_sh1106.inl:89
void flipVertical(uint8_t mode)
performs vertical flip
Definition: lcd_sh1106.inl:153
void commandStart()
Definition: lcd_sh1106.inl:79
#define LCD_LOW
Definition: io.h:161
void end() override
Definition: lcd_sh1106.inl:171
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
uint8_t getStartLine()
Definition: lcd_sh1106.inl:98
void begin() override
Definition: lcd_sh1106.inl:203
void setContrast(uint8_t contrast)
Definition: lcd_sh1106.inl:120
#define LCD_HIGH
Definition: io.h:163
void lcd_delay(unsigned long ms)