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_ssd1331.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  uint8_t rx = w ? (x + w - 1) : (m_base.width() - 1);
38  this->start();
39  setDataMode(0);
40  this->send((m_rotation & 1) ? 0x75: 0x15);
41  this->send(x);
42  this->send(rx < m_base.width() ? rx : (m_base.width() - 1));
43  this->send((m_rotation & 1) ? 0x15: 0x75);
44  this->send(y);
45  this->send(m_base.height() - 1);
46  setDataMode(1);
47 }
48 
49 template <class I> void InterfaceSSD1331<I>::nextBlock()
50 {
51 
52 }
53 
54 template <class I> void InterfaceSSD1331<I>::endBlock()
55 {
56  this->stop();
57 }
58 
59 template <class I> void InterfaceSSD1331<I>::setDataMode(uint8_t mode)
60 {
61  if ( m_dc >= 0 )
62  {
63  lcd_gpioWrite(m_dc, mode ? LCD_HIGH : LCD_LOW);
64  }
65 }
66 
67 template <class I> void InterfaceSSD1331<I>::commandStart()
68 {
69  this->start();
70  if ( m_dc >= 0 )
71  setDataMode(0);
72  else
73  this->send(0x00);
74 }
75 
76 template <class I> void InterfaceSSD1331<I>::setRotation(uint8_t rotation)
77 {
78  uint8_t ram_mode;
79  if ( (rotation ^ m_rotation) & 0x01 )
80  {
81  m_base.swapDimensions();
82  }
83  m_rotation = rotation & 0x03;
84  this->start();
85  setDataMode(0);
86  this->send( 0xA0 );
87  switch ( m_rotation )
88  {
89  // NORMAL FULL COLOR MODE
90  case 0: // 0 degree CW
91  ram_mode = 0b00110010;
92  break;
93  case 1: // 90 degree CW
94  ram_mode = 0b00110001;
95  break;
96  case 2: // 180 degree CW
97  ram_mode = 0b00100000;
98  break;
99  case 3: // 270 degree CW
100  default:
101  ram_mode = 0b00100011;
102  break;
103  }
104  this->send( ram_mode | (m_bits == 16 ? 0x40: 0x00) );
105  this->stop();
106 }
107 
108 template <class I> void InterfaceSSD1331<I>::drawLine(lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2, uint16_t color)
109 {
110  this->start();
111  setDataMode(0);
112  this->send( 0x21 );
113  this->send(x1);
114  this->send(y1);
115  this->send(x2);
116  this->send(y2);
117  this->send( (color & 0xF800) >> 10 );
118  this->send( (color & 0x07E0) >> 5 );
119  this->send( (color & 0x001F) << 1 );
120  this->stop();
121 }
122 
123 template <class I> void InterfaceSSD1331<I>::copyBlock(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t newLeft, uint8_t newTop)
124 {
125  this->start();
126  setDataMode(0);
127  this->send(0x23);
128  this->send(left);
129  this->send(top);
130  this->send(right);
131  this->send(bottom);
132  this->send(newLeft);
133  this->send(newTop);
134  this->stop();
135 }
136 
137 
139 // SSD1331 basic 8-bit implementation
141 
142 template <class I> void DisplaySSD1331x8<I>::beginDisplay()
143 {
144 }
145 
146 template <class I> void DisplaySSD1331x8<I>::endDisplay()
147 {
148 }
149 
150 static const PROGMEM uint8_t s_SSD1331_lcd96x64x8_initData[] = {
151 #ifdef SDL_EMULATION
152  SDL_LCD_SSD1331_X8, 0x00,
153  0x00, 0x00,
154 #endif
155  0xAE, 0x00, // display off
156  0xA0, 0x01, 0x20 | 0x10 | 0x02, /* 8-bit rgb color mode */
157  0xA1, 0x01, 0x00, // First line to start scanning from
158  0xA2, 0x01, 0x00, // Set display offset
159  0xA4, 0x00, // Normal display
160  0xA8, 0x01, 63, // Reset to default MUX. See datasheet
161  0xAD, 0x01, 0x8E, // Set master mode
162  0xB0, 0x01, 0x0B, // Disable power-safe mode
163  0xB1, 0x01, 0x31, // Precharge Phase 1 and Phase 2 periods
164  0xB3, 0x01, 0xF0, // CLOCKDIV 7:4 = Oscillator Frequency, 3:0 = CLK Div Ratio (A[3:0]+1 = 1..16)
165  0x8A, 0x01, 0x64, // Precharge A
166  0x8B, 0x01, 0x78, // Precharge B
167  0xBB, 0x01, 0x3A, // Precharge level
168  0xBE, 0x01, 0x3E, // VCOM
169  0x87, 0x01, 0x09, // Master current
170  0x81, 0x01, 0x91, // RED
171  0x82, 0x01, 0x50, // GREEN
172  0x83, 0x01, 0x7D, // BLUE
173  0xAF, 0x00,
174 };
175 
177 // SSD1331 basic 8-bit implementation
179 
181 {
182  ssd1306_resetController2(this->m_rstPin, 10);
183  this->m_w = 96;
184  this->m_h = 64;
185  // Give LCD some time to initialize. Refer to SSD1331 datasheet
186  lcd_delay(0);
187  _configureSpiDisplayCmdModeOnly<I>(this->m_intf,
188  s_SSD1331_lcd96x64x8_initData,
189  sizeof(s_SSD1331_lcd96x64x8_initData));
190 
191 }
192 
194 {
195 }
197 // SSD1331 basic 16-bit implementation
199 
200 template <class I> void DisplaySSD1331x16<I>::beginDisplay()
201 {
202 }
203 
204 template <class I> void DisplaySSD1331x16<I>::endDisplay()
205 {
206 }
207 
208 static const PROGMEM uint8_t s_SSD1331_lcd96x64x16_initData[] = {
209 #ifdef SDL_EMULATION
210  SDL_LCD_SSD1331_X16, 0x00,
211  0x00, 0x00,
212 #endif
213  0xAE, 0x00, // display off
214  0xA0, 0x01, 0x40 | 0x20 | 0x10 | 0x02, /* 16-bit rgb color mode */
215  0xA1, 0x01, 0x00, // First line to start scanning from
216  0xA2, 0x01, 0x00, // Set display offset
217  0xA4, 0x00, // Normal display
218  0xA8, 0x01, 63, // Reset to default MUX. See datasheet
219  0xAD, 0x01, 0x8E, // Set master mode
220  0xB0, 0x01, 0x0B, // Disable power-safe mode
221  0xB1, 0x01, 0x31, // Phase 1 and Phase 2 periods
222  0xB3, 0x01, 0xF0, // 7:4 = Oscillator Frequency, 3:0 = CLK Div Ratio (A[3:0]+1 = 1..16)
223  0x8A, 0x01, 0x64, // Precharge A
224  0x8B, 0x01, 0x78, // Precharge B
225  0xBB, 0x01, 0x3A, // Precharge level
226  0xBE, 0x01, 0x3E, // VCOM
227  0x87, 0x01, 0x09, // Master current
228  0x81, 0x01, 0x91, // RED
229  0x82, 0x01, 0x50, // GREEN
230  0x83, 0x01, 0x7D, // BLUE
231  0xAF, 0x00,
232 };
233 
235 // SSD1331 basic 16-bit implementation
237 
239 {
240  ssd1306_resetController2(this->m_rstPin, 10);
241  this->m_w = 96;
242  this->m_h = 64;
243  // Give LCD some time to initialize. Refer to SSD1331 datasheet
244  lcd_delay(0);
245  _configureSpiDisplayCmdModeOnly<I>(this->m_intf,
246  s_SSD1331_lcd96x64x16_initData,
247  sizeof(s_SSD1331_lcd96x64x16_initData));
248 
249 }
250 
252 {
253 }
uint8_t lcduint_t
Definition: canvas_types.h:79
void lcd_gpioWrite(int pin, int level)
void copyBlock(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t newLeft, uint8_t newTop)
int8_t lcdint_t
Definition: canvas_types.h:77
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_ssd1331.inl:76
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_ssd1331.inl:35
void drawLine(lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2, uint16_t color)
#define LCD_LOW
Definition: io.h:175
void setDataMode(uint8_t mode)
Definition: lcd_ssd1331.inl:59
#define LCD_HIGH
Definition: io.h:177
void lcd_delay(unsigned long ms)