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_ssd1351.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  lcduint_t rx = w ? (x + w - 1) : (m_base.width() - 1);
39  commandStart();
40  this->send((m_rotation & 0x01) ? 0x75: 0x15);
41  setDataMode(1); // According to datasheet all args must be passed in data mode
42  this->send(x);
43  this->send( rx < m_base.width() ? rx : (m_base.width() - 1) );
44  setDataMode(0);
45  this->send((m_rotation & 0x01) ? 0x15: 0x75);
46  setDataMode(1); // According to datasheet all args must be passed in data mode
47  this->send(y);
48  this->send(m_base.height() - 1);
49  setDataMode(0);
50  this->send(0x5C);
51  if (m_dc >= 0)
52  {
53  setDataMode(1);
54  }
55  else
56  {
57  this->stop();
58  this->start();
59  this->send(0x40);
60  }
61 }
62 
63 template <class I>
65 {
66 
67 }
68 
69 template <class I>
71 {
72  this->stop();
73 }
74 
75 template <class I>
77 {
78  if ( m_dc >= 0 )
79  {
80  lcd_gpioWrite( m_dc, mode ? LCD_HIGH : LCD_LOW );
81  }
82 }
83 
84 template <class I>
86 {
87  this->start();
88  if (m_dc >= 0)
89  setDataMode(0);
90  else
91  this->send(0x00);
92 }
93 
94 template <class I>
95 void InterfaceSSD1351<I>::setRotation(uint8_t rotation)
96 {
97  uint8_t ram_mode;
98  if ((rotation^m_rotation) & 0x01)
99  {
100  m_base.swapDimensions();
101  }
102  m_rotation = (rotation & 0x03);
103  this->start();
104  setDataMode(0);
105  this->send( 0xA0 );
106  switch (m_rotation)
107  {
108  // NORMAL FULL COLOR MODE
109  case 0:
110  ram_mode = 0b00110100;
111  break;
112  case 1: // 90 degree CW
113  ram_mode = 0b00110111;
114  break;
115  case 2: // 180 degree CW
116  ram_mode = 0B00100110;
117  break;
118  case 3: // 270 degree CW
119  default:
120  ram_mode = 0b00100101;
121  break;
122  }
123  setDataMode(1); // According to datasheet all args must be passed in data mode
124  this->send( ram_mode );
125 // this->send( ram_mode | m_rgb_bit );
126  this->stop();
127 
128 }
129 
130 
132 // SSD1351 basic 16-bit implementation
134 
135 template <class I>
137 {
138 }
139 
140 template <class I>
142 {
143 }
144 
145 static const PROGMEM uint8_t s_SSD1351_lcd128x128x16_initData[] =
146 {
147 #ifdef SDL_EMULATION
148  SDL_LCD_SSD1351, 0x00,
149  0x00, 0x00,
150 #endif
151  0xFD, 0x01, 0x12, // Unlock
152  0xFD, 0x01, 0xB1, // Unlock
153  0xAE, 0x00, // SLEEP_ON
154  0xB3, 0x01, 0xF1, // 7:4 = Oscillator Frequency, 3:0 = CLK Div Ratio (A[3:0]+1 = 1..16)
155  0xCA, 0x01, 127, // Reset to default MUX. See datasheet
156  0xA0, 0x01, 0B00110100, // 16-bit rgb color mode
157  0xA1, 0x01, 0x00, // First line to start scanning from
158  0xA2, 0x01, 0x00, // Set display offset
159  0xB5, 0x01, 0x00, // GPIO OFF
160  0xAB, 0x01, 0x01, // Set function
161  0xB1, 0x01, 0x32, // Phase 1 and Phase 2 periods
162  0xBE, 0x01, 0x05, // Precharge
163  0xBB, 0x01, 0x17, // Precharge level
164  0xA6, 0x00, // Normal display
165  0xC1, 0x03, 0xC8, 0x80, 0xC8, // Contrast RED, GREEN, BLUE
166  0xC7, 0x01, 0x0F, // Master current
167  0xB4, 0x03, 0xA0, 0xB5, 0x55, // External VSL
168  0xB6, 0x01, 0x01, // Precharge second
169  0xAF, 0x01, // Disable power-safe mode
170  0xA6, 0x00, // Normal display
171 };
172 
174 // SSD1351 basic 16-bit implementation
176 
177 template <class I>
179 {
180  ssd1306_resetController2( this->m_rstPin, 20 );
181  this->m_w = 128;
182  this->m_h = 128;
183  // Give LCD some time to initialize. Refer to SSD1351 datasheet
184  lcd_delay(0);
185  _configureSpiDisplay<I>(this->m_intf,
186  s_SSD1351_lcd128x128x16_initData,
187  sizeof(s_SSD1351_lcd128x128x16_initData));
188 }
189 
190 template <class I>
192 {
193 }
void setRotation(uint8_t rotation)
Sets screen orientation (rotation)
Definition: lcd_ssd1351.inl:95
uint8_t lcduint_t
Definition: canvas_types.h:81
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_ssd1351.inl:36
void lcd_gpioWrite(int pin, int level)
void end() override
void ssd1306_resetController2(int8_t rstPin, uint8_t delayMs)
Does hardware reset for oled controller.
#define LCD_LOW
Definition: io.h:161
void begin() override
void setDataMode(uint8_t mode)
Definition: lcd_ssd1351.inl:76
#define LCD_HIGH
Definition: io.h:163
void lcd_delay(unsigned long ms)