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