Krolyxon
Commit 1d55752

Branches

Tags

Refs →

orion-rf.piolibdepsesp32-s3-n16r8U8g2srcclibu8x8_d_ls013b7dh03.c

276 lines · 9.6 KB · C

1/*
2
3 u8x8_d_ls013b7dh03.c
4
5 Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6
7 Copyright (c) 2016, olikraus@gmail.com
8 All rights reserved.
9
10 Redistribution and use in source and binary forms, with or without modification,
11 are permitted provided that the following conditions are met:
12
13 * Redistributions of source code must retain the above copyright notice, this list
14 of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above copyright notice, this
17 list of conditions and the following disclaimer in the documentation and/or other
18 materials provided with the distribution.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34
35 The LS013B7DH02 is a simple display and controller
36 --> no support for contrast adjustment, flip and power down.
37*/
38
39#include "u8x8.h"
40
41#define SWAP8(a) ((((a) & 0x80) >> 7) | (((a) & 0x40) >> 5) | (((a) & 0x20) >> 3) | (((a) & 0x10) >> 1) | (((a) & 0x08) << 1) | (((a) & 0x04) << 3) | (((a) & 0x02) << 5) | (((a) & 0x01) << 7))
42
43#define LS013B7DH03_CMD_UPDATE (0x01)
44#define LS013B7DH03_CMD_ALL_CLEAR (0x04)
45#define LS013B7DH03_VAL_TRAILER (0x00)
46
47static const u8x8_display_info_t u8x8_ls013b7dh03_128x128_display_info =
48{
49 /* chip_enable_level = */ 1,
50 /* chip_disable_level = */ 0,
51 /* post_chip_enable_wait_ns = */ 50,
52 /* pre_chip_disable_wait_ns = */ 50,
53 /* reset_pulse_width_ms = */ 1,
54 /* post_reset_wait_ms = */ 6,
55 /* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
56 /* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
57 /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
58 /* spi_mode = */ 0, /* changed from 2 to 0 (https://github.com/olikraus/u8g2/issues/1771) */
59 /* i2c_bus_clock_100kHz = */ 4,
60 /* data_setup_time_ns = */ 100,
61 /* write_pulse_width_ns = */ 100,
62 /* tile_width = */ 16,
63 /* tile_height = */ 16,
64 /* default_x_offset = */ 0,
65 /* flipmode_x_offset = */ 0,
66 /* pixel_width = */ 128,
67 /* pixel_height = */ 128
68};
69
70uint8_t u8x8_d_ls013b7dh03_128x128(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
71{
72 uint8_t y, c, i;
73 uint8_t *ptr;
74 switch(msg)
75 {
76 case U8X8_MSG_DISPLAY_SETUP_MEMORY:
77 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls013b7dh03_128x128_display_info);
78 break;
79 case U8X8_MSG_DISPLAY_INIT:
80 u8x8_d_helper_display_init(u8x8);
81
82 /* clear screen */
83 u8x8_cad_StartTransfer(u8x8);
84 u8x8_cad_SendCmd(u8x8, SWAP8(LS013B7DH03_CMD_ALL_CLEAR) );
85 u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
86 u8x8_cad_EndTransfer(u8x8);
87
88 break;
89 case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
90 /* not available for the ls013b7dh03 */
91 break;
92 case U8X8_MSG_DISPLAY_DRAW_TILE:
93 /* each tile is 8 lines, with the data starting at the left edge */
94 y = ((((u8x8_tile_t *)arg_ptr)->y_pos) * 8) + 1;
95
96 c = ((u8x8_tile_t *)arg_ptr)->cnt;
97 ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
98
99 /* send data mode byte */
100 u8x8_cad_StartTransfer(u8x8);
101 u8x8_cad_SendCmd(u8x8, SWAP8(LS013B7DH03_CMD_UPDATE) );
102
103 /* send 8 lines of 16 bytes (=128 pixels) */
104 for( i = 0; i < 8; i++ )
105 {
106 u8x8_cad_SendCmd(u8x8, SWAP8(y + i) );
107 u8x8_cad_SendData(u8x8, c, ptr);
108 u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
109
110 ptr += c;
111 }
112
113 /* finish with a trailing byte */
114 u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
115 u8x8_cad_EndTransfer(u8x8);
116
117 break;
118 default:
119 return 0;
120 }
121 return 1;
122}
123
124/*===============================================*/
125
126static const u8x8_display_info_t u8x8_ls027b7dh01_400x240_display_info =
127{
128 /* chip_enable_level = */ 1,
129 /* chip_disable_level = */ 0,
130 /* post_chip_enable_wait_ns = */ 50,
131 /* pre_chip_disable_wait_ns = */ 50,
132 /* reset_pulse_width_ms = */ 1,
133 /* post_reset_wait_ms = */ 6,
134 /* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
135 /* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
136 /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
137 /* spi_mode = */ 0, /* changed from 2 to 0 (https://github.com/olikraus/u8g2/issues/1771) */
138 /* i2c_bus_clock_100kHz = */ 4,
139 /* data_setup_time_ns = */ 100,
140 /* write_pulse_width_ns = */ 100,
141 /* tile_width = */ 50,
142 /* tile_height = */ 30,
143 /* default_x_offset = */ 0,
144 /* flipmode_x_offset = */ 0,
145 /* pixel_width = */ 400,
146 /* pixel_height = */ 240
147};
148
149uint8_t u8x8_d_ls027b7dh01_400x240(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
150{
151 switch(msg)
152 {
153 case U8X8_MSG_DISPLAY_SETUP_MEMORY:
154 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls027b7dh01_400x240_display_info);
155 break;
156 default:
157 return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
158 }
159 return 1;
160}
161
162/*===============================================*/
163
164static const u8x8_display_info_t u8x8_ls027b7dh01_m0_400x240_display_info =
165{
166 /* chip_enable_level = */ 1,
167 /* chip_disable_level = */ 0,
168 /* post_chip_enable_wait_ns = */ 50,
169 /* pre_chip_disable_wait_ns = */ 50,
170 /* reset_pulse_width_ms = */ 1,
171 /* post_reset_wait_ms = */ 6,
172 /* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
173 /* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
174 /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
175 /* spi_mode = */ 0, /* active low, rising edge */
176 /* i2c_bus_clock_100kHz = */ 4,
177 /* data_setup_time_ns = */ 100,
178 /* write_pulse_width_ns = */ 100,
179 /* tile_width = */ 50,
180 /* tile_height = */ 30,
181 /* default_x_offset = */ 0,
182 /* flipmode_x_offset = */ 0,
183 /* pixel_width = */ 400,
184 /* pixel_height = */ 240
185};
186
187uint8_t u8x8_d_ls027b7dh01_m0_400x240(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
188{
189 switch(msg)
190 {
191 case U8X8_MSG_DISPLAY_SETUP_MEMORY:
192 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls027b7dh01_m0_400x240_display_info);
193 break;
194 default:
195 return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
196 }
197 return 1;
198}
199
200/*===============================================*/
201
202static const u8x8_display_info_t u8x8_ls013b7dh05_144x168_display_info =
203{
204 /* chip_enable_level = */ 1,
205 /* chip_disable_level = */ 0,
206 /* post_chip_enable_wait_ns = */ 50,
207 /* pre_chip_disable_wait_ns = */ 50,
208 /* reset_pulse_width_ms = */ 1,
209 /* post_reset_wait_ms = */ 6,
210 /* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
211 /* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
212 /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
213 /* spi_mode = */ 0, /* changed from 2 to 0 (https://github.com/olikraus/u8g2/issues/1771) */
214 /* i2c_bus_clock_100kHz = */ 4,
215 /* data_setup_time_ns = */ 100,
216 /* write_pulse_width_ns = */ 100,
217 /* tile_width = */ 18,
218 /* tile_height = */ 21,
219 /* default_x_offset = */ 0,
220 /* flipmode_x_offset = */ 0,
221 /* pixel_width = */ 144,
222 /* pixel_height = */ 168
223};
224
225uint8_t u8x8_d_ls013b7dh05_144x168(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
226{
227 switch(msg)
228 {
229 case U8X8_MSG_DISPLAY_SETUP_MEMORY:
230 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls013b7dh05_144x168_display_info);
231 break;
232 default:
233 return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
234 }
235 return 1;
236}
237
238/*===============================================*/
239/* https://github.com/olikraus/u8g2/issues/2210 */
240
241static const u8x8_display_info_t u8x8_ls011b7dh03_160x68_display_info =
242{
243 /* chip_enable_level = */ 1,
244 /* chip_disable_level = */ 0,
245 /* post_chip_enable_wait_ns = */ 50,
246 /* pre_chip_disable_wait_ns = */ 50,
247 /* reset_pulse_width_ms = */ 1,
248 /* post_reset_wait_ms = */ 6,
249 /* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
250 /* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
251 /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
252 /* spi_mode = */ 0, /* changed from 2 to 0 (https://github.com/olikraus/u8g2/issues/1771) */
253 /* i2c_bus_clock_100kHz = */ 4,
254 /* data_setup_time_ns = */ 100,
255 /* write_pulse_width_ns = */ 100,
256 /* tile_width = */ 20,
257 /* tile_height = */ 9,
258 /* default_x_offset = */ 0,
259 /* flipmode_x_offset = */ 0,
260 /* pixel_width = */ 160,
261 /* pixel_height = */ 68
262};
263
264uint8_t u8x8_d_ls011b7dh03_160x68(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
265{
266 switch(msg)
267 {
268 case U8X8_MSG_DISPLAY_SETUP_MEMORY:
269 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls011b7dh03_160x68_display_info);
270 break;
271 default:
272 return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
273 }
274 return 1;
275}
276