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_il9163.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  lcduint_t rx = w ? (x + w - 1) : (m_base.width() - 1);
39  this->start();
40  spiDataMode(0);
41  this->send(0x2A);
42  spiDataMode(1); // According to datasheet all args must be passed in data mode
43  this->send(0);
44  // Take into account bug in il9163 controller
45  this->send(x + (m_rotation == 3 ? 32 : 0));
46  this->send(0);
47  this->send((rx < m_base.width() ? rx : (m_base.width() - 1))
48  + (m_rotation == 3 ? 32 : 0));
49  spiDataMode(0);
50  this->send(0x2B);
51  spiDataMode(1); // According to datasheet all args must be passed in data mode
52  this->send(0);
53  // Take into account bug in il9163 controller
54  this->send(y + (m_rotation == 2 ? 32: 0));
55  this->send(0);
56  this->send(m_base.height() - 1 + (m_rotation == 2 ? 32: 0));
57  spiDataMode(0);
58  this->send(0x2C);
59  spiDataMode(1);
60 }
61 
62 template <class I>
64 {
65 
66 }
67 
68 template <class I>
70 {
71  this->stop();
72 }
73 
74 template <class I>
76 {
77  if ( m_dc >= 0 )
78  {
79  lcd_gpioWrite( m_dc, mode ? LCD_HIGH : LCD_LOW );
80  }
81 }
82 
83 template <class I>
85 {
86  this->start();
87  if (m_dc >= 0)
88  spiDataMode(0);
89  else
90  this->send(0x00);
91 }
92 
93 template <class I>
94 void InterfaceIL9163<I>::setRotation(uint8_t rotation)
95 {
96  uint8_t ram_mode;
97  if ((rotation^m_rotation) & 0x01)
98  {
99  m_base.swapDimensions();
100  }
101  m_rotation = (rotation & 0x03);
102  this->start();
103  spiDataMode(0);
104  this->send(0x28);
105  this->send(0x36);
106  spiDataMode(1);
107  switch (m_rotation)
108  {
109  case 0:
110  ram_mode = 0b00000000;
111  break;
112  case 1: // 90 degree CW
113  ram_mode = 0b01100000;
114  break;
115  case 2: // 180 degree CW
116  ram_mode = 0b11000000;
117  break;
118  default: // 270 degree CW
119  ram_mode = 0b10100000;
120  break;
121  }
122  this->send( ram_mode | m_rgb_bit );
123  spiDataMode(0);
124  this->send(0x29);
125  this->stop();
126 }
127 
128 
130 // IL9163 basic 16-bit implementation
132 
133 template <class I>
135 {
136 }
137 
138 template <class I>
140 {
141 }
142 
143 static const PROGMEM uint8_t s_IL9163_lcd128x128x16_initData[] =
144 {
145 #ifdef SDL_EMULATION
146  SDL_LCD_IL9163, 0x00,
147  0x00, 0x00,
148 #endif
149 // 0x01, 0x00, // sw reset. not needed, we do hardware reset
150  0x11, 0x00, // exit sleep mode
151  0x3A, 0x01, 0x05, // set 16-bit pixel format
152  0x26, 0x01, 0x04, // set gamma curve: valid values 1, 2, 4, 8
153 // 0xF2, 0x01, 0x01, // enable gamma adjustment, 0 - to disable
154 // 0xE0, 15, 0x3F, 0x25, 0x1C,
155 // 0x1E, 0x20, 0x12,
156 // 0x2A, 0x90, 0x24,
157 // 0x11, 0x00, 0x00,
158 // 0x00, 0x00, 0x00, // positive gamma correction
159 // 0xE1, 15, 0x20, 0x20, 0x20,
160 // 0x20, 0x05, 0x00,
161 // 0x15, 0xA7, 0x3D,
162 // 0x18, 0x25, 0x2A,
163 // 0x2B, 0x2B, 0x3A, // negative gamma correction
164 // 0xB1, 0x02, 0x08, 0x08, // frame rate control 1, use by default
165 // 0xB4, 0x01, 0x07, // display inversion, use by default
166  0xC0, 0x02, 0x0A, 0x02, // power control 1
167  0xC1, 0x01, 0x02, // power control 2
168  0xC5, 0x02, 0x50, 0x5B, // vcom control 1
169  0xC7, 0x01, 0x40, // vcom offset
170 // 0x2A, 0x04, 0x00, 0x00, 0x00, 0x7F, // set column address, not needed.
171 // 0x2B, 0x04, 0x00, 0x00, 0x00, 0x9F, // set page address, not needed.
172  0x36, 0x01, 0b00000000, // Horizontal addressing mode
173  0x29, 0x00,
174 };
175 
177 // IL9163 basic 16-bit implementation
179 
180 template <class I>
182 {
183  ssd1306_resetController2( this->m_rstPin, 20 );
184  this->m_w = 128;
185  this->m_h = 128;
186  // Give LCD some time to initialize. Refer to IL9163 datasheet
187  lcd_delay(120);
188  _configureSpiDisplay<I>(this->m_intf,
189  s_IL9163_lcd128x128x16_initData,
190  sizeof(s_IL9163_lcd128x128x16_initData));
191 }
192 
193 template <class I>
195 {
196 }
197 
198 static const PROGMEM uint8_t s_IL9163_lcd128x160x16_initData[] =
199 {
200 #ifdef SDL_EMULATION
201  SDL_LCD_IL9163, 0x00,
202  0b00000011, 0x00,
203 #endif
204 // 0x01, 0x00, // sw reset. not needed, we do hardware reset
205  0x11, 0x00, // exit sleep mode
206  0x3A, 0x01, 0x05, // set 16-bit pixel format
207  0x26, 0x01, 0x04, // set gamma curve: valid values 1, 2, 4, 8
208  0xC0, 0x02, 0x0A, 0x02, // power control 1
209  0xC1, 0x01, 0x02, // power control 2
210  0xC5, 0x02, 0x50, 0x5B, // vcom control 1
211  0xC7, 0x01, 0x40, // vcom offset
212  0x36, 0x01, 0b00000000, // Horizontal addressing mode
213  0x29, 0x00
214 };
215 
217 // IL9163 basic 16-bit implementation
219 
220 template <class I>
222 {
223  ssd1306_resetController2( this->m_rstPin, 20 );
224  this->m_w = 128;
225  this->m_h = 160;
226  // Give LCD some time to initialize. Refer to IL9163 datasheet
227  lcd_delay(120);
228  _configureSpiDisplay<I>(this->m_intf,
229  s_IL9163_lcd128x160x16_initData,
230  sizeof(s_IL9163_lcd128x160x16_initData));
231 }
232 
233 template <class I>
235 {
236 }
uint8_t lcduint_t
Definition: canvas_types.h:81
void begin() override
Definition: lcd_il9163.inl:134
void lcd_gpioWrite(int pin, int level)
void begin() override
Definition: lcd_il9163.inl:221
void end() override
Definition: lcd_il9163.inl:139
void spiDataMode(uint8_t mode)
Definition: lcd_il9163.inl:75
void ssd1306_resetController2(int8_t rstPin, uint8_t delayMs)
Does hardware reset for oled controller.
void setRotation(uint8_t rotation)
Sets screen orientation (rotation)
Definition: lcd_il9163.inl:94
void commandStart()
Definition: lcd_il9163.inl:84
#define LCD_LOW
Definition: io.h:140
void begin() override
Definition: lcd_il9163.inl:181
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_il9163.inl:36
#define LCD_HIGH
Definition: io.h:142
void lcd_delay(unsigned long ms)