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_sh1107.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 + m_seg_offset) & 0x0f ) ); // low column
42  this->send((((x + m_seg_offset) >> 4) & 0x07 ) | 0x10); // high 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 InterfaceSH1107<I>::nextBlock()
56 {
57  this->stop();
58  startBlock(m_column,m_page+1,0);
59 }
60 
61 template <class I> void InterfaceSH1107<I>::endBlock()
62 {
63  this->stop();
64 }
65 
66 template <class I> void InterfaceSH1107<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 InterfaceSH1107<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 InterfaceSH1107<I>::setStartLine(uint8_t line)
84 {
85  m_startLine = line;
86  commandStart();
87  this->send( 0xDC );
88  this->send( line & 0x7F ); // start line
89  this->stop();
90 }
91 
92 template <class I> uint8_t InterfaceSH1107<I>::getStartLine()
93 {
94  return m_startLine;
95 }
96 
97 template <class I> void InterfaceSH1107<I>::normalMode()
98 {
99  commandStart();
100  this->send(0xA6); // Normal display
101  this->stop();
102 }
103 
104 template <class I> void InterfaceSH1107<I>::invertMode()
105 {
106  commandStart();
107  this->send(0xA7); // Invert display
108  this->stop();
109 }
110 
111 template <class I> void InterfaceSH1107<I>::setContrast(uint8_t contrast)
112 {
113  commandStart();
114  this->send(0x81); // set contrast
115  this->send(contrast);
116  this->stop();
117 }
118 
119 template <class I> void InterfaceSH1107<I>::displayOff()
120 {
121  commandStart();
122  this->send(0xAE); // display off
123  this->stop();
124 }
125 
126 template <class I> void InterfaceSH1107<I>::displayOn()
127 {
128  commandStart();
129  this->send(0xAF); // display on
130  this->stop();
131 }
132 
133 template <class I> void InterfaceSH1107<I>::flipHorizontal(uint8_t mode)
134 {
135  commandStart();
136  this->send( 0xA0 | (mode ? 0x00: 0x01 ) ); // seg remap
137  this->stop();
138 }
139 
140 template <class I> void InterfaceSH1107<I>::flipVertical(uint8_t mode)
141 {
142  commandStart();
143  this->send( mode ? 0xC0 : 0xC8 );
144  this->stop();
145 }
146 
147 template <class I> void InterfaceSH1107<I>::setSegOffset(uint8_t offset)
148 {
149  m_seg_offset = offset;
150 }
151 
152 template <class I> void InterfaceSH1107<I>::setDisplayOffset(uint8_t offset)
153 {
154  commandStart();
155  this->send( 0xD3 );
156  this->send( offset & 0x7F ); // start line
157  this->stop();
158 }
159 
160 
162 // SH1107 basic 1-bit implementation
164 
165 template <class I> void DisplaySH1107<I>::beginDisplay()
166 {
167 }
168 
169 template <class I> void DisplaySH1107<I>::endDisplay()
170 {
171 }
172 
173 static const PROGMEM uint8_t s_SH1107_lcd128x64_initData[] = {
174 #ifdef SDL_EMULATION
175  SDL_LCD_SH1107, 0x00,
176  0x00, 0x00,
177 #endif
178  0xAE, 0x00, // display off
179  0xC8, 0x00, // Scan from 127 to 0 (Reverse scan)
180  0xDC, 0x01, 0x00, // First line to start scanning from
181  0x81, 0x01, 0x80, // contast value to 0x2F according to datasheet
182  0x20, 0x00, // Set page addressing mode
183  0xA0| 0x01, 0x00, // Use reverse mapping. 0x00 - is normal mapping
184  0xA6, 0x00, // Normal display
185  0xA8, 0x01, 63, // Reset to default MUX. See datasheet
186  0xD3, 0x01, 0x00, // no offset
187  0xD5, 0x01, 0x80, // set to default ratio/osc frequency
188  0xD9, 0x01, 0x22, // switch precharge to 0x22 // 0xF1
189  0xDA, 0x01, 0x12, // set divide ratio com pins
190  0xDB, 0x01, 0x40, // vcom deselect to 0x20 // 0x40
191  0x8D, 0x01, 0x14, // Enable charge pump
192  0xA4, 0x00, // Display on resume
193  0xAF, 0x00, // Display on
194 };
195 
197 // SH1107 basic 1-bit implementation
199 
201 {
202  ssd1306_resetController2(this->m_rstPin, 10);
203  this->m_w = 128;
204  this->m_h = 64;
205  // Give LCD some time to initialize. Refer to SH1107 datasheet
206  lcd_delay(100);
207  _configureSpiDisplayCmdModeOnly<I>(this->m_intf,
208  s_SH1107_lcd128x64_initData,
209  sizeof(s_SH1107_lcd128x64_initData));
210 
211 }
212 
213 template <class I> void DisplaySH1107_128x64<I>::endController()
214 {
215 }
216 
217 static const PROGMEM uint8_t s_SH1107_lcd64x128_initData[] = {
218 #ifdef SDL_EMULATION
219  SDL_LCD_SH1107, 0x00,
220  0x01, 0x00,
221 #endif
222  0xAE, 0x00, // display off
223  0xDC, 0x01, 0x00, // First line to start scanning from
224  0x81, 0x01, 0x2F, // contast value to 0x2F according to datasheet
225  0x20, 0x00, // Set page addressing mode
226  0xA0| 0x01, 0x00, // Use reverse mapping. 0x00 - is normal mapping
227  0xCF, 0x00, // Scan from 127 to 0 (Reverse scan)
228  0xA4, 0x00, // Display on resume
229  0xA6, 0x00, // Normal display
230  0xA8, 0x01, 127, // Reset to default MUX. See datasheet
231  0xD3, 0x01, 0x60, // offset 0x60 according to datasheet
232  0xD5, 0x01, 0x80, // set to default ratio/osc frequency
233  0xD9, 0x01, 0x22, // switch precharge to 0x22 // 0xF1
234  0xDB, 0x01, 0x40, // vcom deselect to 0x20 // 0x40
235  0xAD, 0x01, 0x8A, // Set charge pump enable
236  0xAF, 0x00, // Display on
237 };
238 
240 // SH1107 basic 1-bit implementation
242 
244 {
245  ssd1306_resetController2(this->m_rstPin, 10);
246  this->m_w = 64;
247  this->m_h = 128;
248  // Give LCD some time to initialize. Refer to SH1107 datasheet
249  lcd_delay(100);
250  _configureSpiDisplayCmdModeOnly<I>(this->m_intf,
251  s_SH1107_lcd64x128_initData,
252  sizeof(s_SH1107_lcd64x128_initData));
253  this->m_intf.setSegOffset( 0 );
254 }
255 
256 template <class I> void DisplaySH1107_64x128<I>::endController()
257 {
258 }
uint8_t lcduint_t
Definition: canvas_types.h:79
void beginDisplay()
Definition: lcd_sh1107.inl:165
void lcd_gpioWrite(int pin, int level)
void setStartLine(uint8_t line)
Definition: lcd_sh1107.inl:83
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_sh1107.inl:35
void ssd1306_resetController2(int8_t rstPin, uint8_t delayMs)
Does hardware reset for oled controller.
uint8_t getStartLine()
Definition: lcd_sh1107.inl:92
void flipHorizontal(uint8_t mode)
performs horizontal flip
Definition: lcd_sh1107.inl:133
void setContrast(uint8_t contrast)
Definition: lcd_sh1107.inl:111
#define LCD_LOW
Definition: io.h:175
void endDisplay()
Definition: lcd_sh1107.inl:169
void flipVertical(uint8_t mode)
performs vertical flip
Definition: lcd_sh1107.inl:140
void setDisplayOffset(uint8_t offset)
Definition: lcd_sh1107.inl:152
void setDataMode(uint8_t mode)
Definition: lcd_sh1107.inl:66
void setSegOffset(uint8_t offset)
Definition: lcd_sh1107.inl:147
#define LCD_HIGH
Definition: io.h:177
void commandStart()
Definition: lcd_sh1107.inl:74
void lcd_delay(unsigned long ms)