LCDGFX LCD display driver  1.0.2
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(0x15);
41  spiDataMode(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  spiDataMode(0);
45  this->send(0x75);
46  spiDataMode(1); // According to datasheet all args must be passed in data mode
47  this->send(y);
48  this->send(m_base.height() - 1);
49  spiDataMode(0);
50  this->send(0x5C);
51  if (m_dc >= 0)
52  {
53  spiDataMode(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  spiDataMode(0);
90  else
91  this->send(0x00);
92 }
93 
94 
96 // SSD1351 basic 16-bit implementation
98 
99 template <class I>
101 {
102 }
103 
104 template <class I>
106 {
107 }
108 
109 static const PROGMEM uint8_t s_SSD1351_lcd128x128x16_initData[] =
110 {
111 #ifdef SDL_EMULATION
112  SDL_LCD_SSD1351, 0x00,
113  0x00, 0x00,
114 #endif
115  0xFD, 0x01, 0x12, // Unlock
116  0xFD, 0x01, 0xB1, // Unlock
117  0xAE, 0x00, // SLEEP_ON
118  0xB3, 0x01, 0xF1, // 7:4 = Oscillator Frequency, 3:0 = CLK Div Ratio (A[3:0]+1 = 1..16)
119  0xCA, 0x01, 127, // Reset to default MUX. See datasheet
120  0xA0, 0x01, 0B00110100, // 16-bit rgb color mode
121  0xA1, 0x01, 0x00, // First line to start scanning from
122  0xA2, 0x01, 0x00, // Set display offset
123  0xB5, 0x01, 0x00, // GPIO OFF
124  0xAB, 0x01, 0x01, // Set function
125  0xB1, 0x01, 0x32, // Phase 1 and Phase 2 periods
126  0xBE, 0x01, 0x05, // Precharge
127  0xBB, 0x01, 0x17, // Precharge level
128  0xA6, 0x00, // Normal display
129  0xC1, 0x03, 0xC8, 0x80, 0xC8, // Contrast RED, GREEN, BLUE
130  0xC7, 0x01, 0x0F, // Master current
131  0xB4, 0x03, 0xA0, 0xB5, 0x55, // External VSL
132  0xB6, 0x01, 0x01, // Precharge second
133  0xAF, 0x01, // Disable power-safe mode
134  0xA6, 0x00, // Normal display
135 };
136 
138 // SSD1351 basic 16-bit implementation
140 
141 template <class I>
143 {
144  ssd1306_resetController2( this->m_rstPin, 20 );
145  this->m_w = 128;
146  this->m_h = 128;
147  // Give LCD some time to initialize. Refer to SSD1351 datasheet
148  lcd_delay(0);
149  _configureSpiDisplay<I>(this->m_intf,
150  s_SSD1351_lcd128x128x16_initData,
151  sizeof(s_SSD1351_lcd128x128x16_initData));
152 }
153 
154 template <class I>
156 {
157 }
void spiDataMode(uint8_t mode)
Definition: lcd_ssd1351.inl:76
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:140
void begin() override
#define LCD_HIGH
Definition: io.h:142
void lcd_delay(unsigned long ms)