LibDriver SSD1681
Loading...
Searching...
No Matches
driver_ssd1681_basic.c
Go to the documentation of this file.
1
36
38
39static ssd1681_handle_t gs_handle;
40static uint8_t gs_lut[153] = {
41 0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
42 0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
43 0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
44 0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
45 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
46 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
47 0x8, 0x1, 0x0, 0x8, 0x1, 0x0, 0x2,
48 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
49 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
50 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
51 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
52 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
53 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
54 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
55 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
56 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
57 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
58 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0,
59};
60
68uint8_t ssd1681_basic_init(void)
69{
70 uint8_t res;
71
72 /* link functions */
89
90 /* init */
91 res = ssd1681_init(&gs_handle);
92 if (res != 0)
93 {
94 ssd1681_interface_debug_print("ssd1681: init failed.\n");
95
96 return 1;
97 }
98
99 /* reset the chip */
100 res = ssd1681_software_reset(&gs_handle);
101 if (res != 0)
102 {
103 ssd1681_interface_debug_print("ssd1681: software reset failed.\n");
104 (void)ssd1681_deinit(&gs_handle);
105
106 return 1;
107 }
108
109 /* set the default driver output */
114 if (res != 0)
115 {
116 ssd1681_interface_debug_print("ssd1681: set the driver output failed.\n");
117 (void)ssd1681_deinit(&gs_handle);
118
119 return 1;
120 }
121
122 /* set the default data entry mode */
124 if (res != 0)
125 {
126 ssd1681_interface_debug_print("ssd1681: set data entry mode failed.\n");
127 (void)ssd1681_deinit(&gs_handle);
128
129 return 1;
130 }
131
132 /* set the default temperature sensor */
134 if (res != 0)
135 {
136 ssd1681_interface_debug_print("ssd1681: set temperature sensor failed.\n");
137 (void)ssd1681_deinit(&gs_handle);
138
139 return 1;
140 }
141
142 /* set the default border waveform */
145 if (res != 0)
146 {
147 ssd1681_interface_debug_print("ssd1681: set border waveform failed.\n");
148 (void)ssd1681_deinit(&gs_handle);
149
150 return 1;
151 }
152
153 /* set the default x range */
155 if (res != 0)
156 {
157 ssd1681_interface_debug_print("ssd1681: set ram x failed.\n");
158 (void)ssd1681_deinit(&gs_handle);
159
160 return 1;
161 }
162
163 /* set the default y range */
165 if (res != 0)
166 {
167 ssd1681_interface_debug_print("ssd1681: set ram y failed.\n");
168 (void)ssd1681_deinit(&gs_handle);
169
170 return 1;
171 }
172
173 /* set the default ram x address counter */
175 if (res != 0)
176 {
177 ssd1681_interface_debug_print("ssd1681: set ram x address counter failed.\n");
178 (void)ssd1681_deinit(&gs_handle);
179
180 return 1;
181 }
182
183 /* set the default ram y address counter */
185 if (res != 0)
186 {
187 ssd1681_interface_debug_print("ssd1681: set ram y address counter failed.\n");
188 (void)ssd1681_deinit(&gs_handle);
189
190 return 1;
191 }
192
193 /* set the default display update control mode */
195 if (res != 0)
196 {
197 ssd1681_interface_debug_print("ssd1681: set display update control failed.\n");
198 (void)ssd1681_deinit(&gs_handle);
199
200 return 1;
201 }
202
203 /* set the default sequence */
205 if (res != 0)
206 {
207 ssd1681_interface_debug_print("ssd1681: set display sequence failed.\n");
208 (void)ssd1681_deinit(&gs_handle);
209
210 return 1;
211 }
212
213 /* set the default vcom sense duration */
215 if (res != 0)
216 {
217 ssd1681_interface_debug_print("ssd1681: set vcom sense duration failed.\n");
218 (void)ssd1681_deinit(&gs_handle);
219
220 return 1;
221 }
222
223 /* enter the vcom sense */
224 res = ssd1681_set_enter_vcom_sense(&gs_handle);
225 if (res != 0)
226 {
227 ssd1681_interface_debug_print("ssd1681: set enter vcom sense failed.\n");
228 (void)ssd1681_deinit(&gs_handle);
229
230 return 1;
231 }
232
233 /* set the vcom control reg */
234 res = ssd1681_set_vcom_control_reg(&gs_handle);
235 if (res != 0)
236 {
237 ssd1681_interface_debug_print("ssd1681: set vcom control reg failed.\n");
238 (void)ssd1681_deinit(&gs_handle);
239
240 return 1;
241 }
242
243 /* set the lut register */
244 res = ssd1681_set_lut_register(&gs_handle, gs_lut, 153);
245 if (res != 0)
246 {
247 ssd1681_interface_debug_print("ssd1681: set lut register failed.\n");
248 (void)ssd1681_deinit(&gs_handle);
249
250 return 1;
251 }
252
253 /* set the default end option */
255 if (res != 0)
256 {
257 ssd1681_interface_debug_print("ssd1681: set end option failed.\n");
258 (void)ssd1681_deinit(&gs_handle);
259
260 return 1;
261 }
262
263 /* set the default gate driving voltage */
265 if (res != 0)
266 {
267 ssd1681_interface_debug_print("ssd1681: set gate driving voltage failed.\n");
268 (void)ssd1681_deinit(&gs_handle);
269
270 return 1;
271 }
272
273 /* set the default source driving voltage */
275 if (res != 0)
276 {
277 ssd1681_interface_debug_print("ssd1681: set source driving voltage failed.\n");
278 (void)ssd1681_deinit(&gs_handle);
279
280 return 1;
281 }
282
283 /* set the default vcom */
285 if (res != 0)
286 {
287 ssd1681_interface_debug_print("ssd1681: set vcom register failed.\n");
288 (void)ssd1681_deinit(&gs_handle);
289
290 return 1;
291 }
292
293 /* set the default auto write red ram */
295 if (res != 0)
296 {
297 ssd1681_interface_debug_print("ssd1681: set auto write red ram failed.\n");
298 (void)ssd1681_deinit(&gs_handle);
299
300 return 1;
301 }
302
303 /* set the default auto write black ram */
305 if (res != 0)
306 {
307 ssd1681_interface_debug_print("ssd1681: set auto write black ram failed.\n");
308 (void)ssd1681_deinit(&gs_handle);
309
310 return 1;
311 }
312
313 /* set the default hv ready detection */
315 if (res != 0)
316 {
317 ssd1681_interface_debug_print("ssd1681: set hv ready detection failed.\n");
318 (void)ssd1681_deinit(&gs_handle);
319
320 return 1;
321 }
322
323 /* set the default vci detection */
325 if (res != 0)
326 {
327 ssd1681_interface_debug_print("ssd1681: set vci detection failed.\n");
328 (void)ssd1681_deinit(&gs_handle);
329
330 return 1;
331 }
332
333 /* set the default booster soft start param */
334 res = ssd1681_set_booster_soft_start(&gs_handle,
339 if (res != 0)
340 {
341 ssd1681_interface_debug_print("ssd1681: set booster soft start failed.\n");
342 (void)ssd1681_deinit(&gs_handle);
343
344 return 1;
345 }
346
347 /* set the default mode */
349 if (res != 0)
350 {
351 ssd1681_interface_debug_print("ssd1681: set mode failed.\n");
352 (void)ssd1681_deinit(&gs_handle);
353
354 return 1;
355 }
356
357 /* clear the black */
358 res = ssd1681_gram_clear(&gs_handle, SSD1681_COLOR_BLACK);
359 if (res != 0)
360 {
361 ssd1681_interface_debug_print("ssd1681: clear failed.\n");
362 (void)ssd1681_deinit(&gs_handle);
363
364 return 1;
365 }
366
367 /* clear the red */
368 res = ssd1681_gram_clear(&gs_handle, SSD1681_COLOR_RED);
369 if (res != 0)
370 {
371 ssd1681_interface_debug_print("ssd1681: clear failed.\n");
372 (void)ssd1681_deinit(&gs_handle);
373
374 return 1;
375 }
376
377 return 0;
378}
379
388{
389 /* deinit ssd1681 */
390 if (ssd1681_deinit(&gs_handle) != 0)
391 {
392 return 1;
393 }
394 else
395 {
396 return 0;
397 }
398}
399
409{
410 /* clear */
411 if (ssd1681_clear(&gs_handle, color) != 0)
412 {
413 return 1;
414 }
415 else
416 {
417 return 0;
418 }
419}
420
432uint8_t ssd1681_basic_write_point(ssd1681_color_t color, uint8_t x, uint8_t y, uint8_t data)
433{
434 uint8_t res;
435
436 /* write point */
437 res = ssd1681_gram_write_point(&gs_handle, color, x, y, data);
438 if (res != 0)
439 {
440 return 1;
441 }
442
443 /* update gram */
444 if (ssd1681_gram_update(&gs_handle, color) != 0)
445 {
446 return 1;
447 }
448 else
449 {
450 return 0;
451 }
452}
453
465uint8_t ssd1681_basic_read_point(ssd1681_color_t color, uint8_t x, uint8_t y, uint8_t *data)
466{
467 uint8_t res;
468
469 /* read point in gram */
470 res = ssd1681_gram_read_point(&gs_handle, color, x, y, data);
471 if (res != 0)
472 {
473 return 1;
474 }
475
476 return 0;
477}
478
493uint8_t ssd1681_basic_string(ssd1681_color_t color, uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t data, ssd1681_font_t font)
494{
495 uint8_t res;
496
497 /* write string in gram */
498 res = ssd1681_gram_write_string(&gs_handle, color, x, y, str, len, data, font);
499 if (res != 0)
500 {
501 return 1;
502 }
503
504 /* update gram */
505 if (ssd1681_gram_update(&gs_handle, color) != 0)
506 {
507 return 1;
508 }
509 else
510 {
511 return 0;
512 }
513}
514
528uint8_t ssd1681_basic_rect(ssd1681_color_t color, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t data)
529{
530 uint8_t res;
531
532 /* fill rect in gram */
533 res = ssd1681_gram_fill_rect(&gs_handle, color, left, top, right, bottom, data);
534 if (res != 0)
535 {
536 return 1;
537 }
538
539 /* update gram */
540 if (ssd1681_gram_update(&gs_handle, color) != 0)
541 {
542 return 1;
543 }
544 else
545 {
546 return 0;
547 }
548}
549
563uint8_t ssd1681_basic_picture(ssd1681_color_t color, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
564{
565 uint8_t res;
566
567 /* draw picture in gram */
568 res = ssd1681_gram_draw_picture(&gs_handle, color, left, top, right, bottom, img);
569 if (res != 0)
570 {
571 return 1;
572 }
573
574 /* update gram */
575 if (ssd1681_gram_update(&gs_handle, color) != 0)
576 {
577 return 1;
578 }
579 else
580 {
581 return 0;
582 }
583}
driver ssd1681 basic header file
uint8_t ssd1681_deinit(ssd1681_handle_t *handle)
close the chip
uint8_t ssd1681_set_display_sequence(ssd1681_handle_t *handle, ssd1681_display_sequence_t sequence)
set the display sequence
uint8_t ssd1681_init(ssd1681_handle_t *handle)
initialize the chip
uint8_t ssd1681_set_ram_y_address_counter(ssd1681_handle_t *handle, uint16_t cnt)
set the ram y address counter
struct ssd1681_handle_s ssd1681_handle_t
ssd1681 handle structure definition
uint8_t ssd1681_set_lut_register(ssd1681_handle_t *handle, uint8_t *reg, uint16_t len)
set the lut register
uint8_t ssd1681_set_vcom_sense_duration(ssd1681_handle_t *handle, uint8_t duration)
set the vcom sense duration
uint8_t ssd1681_set_vcom_control_reg(ssd1681_handle_t *handle)
write register for vcom control
ssd1681_color_t
ssd1681 color enumeration definition
uint8_t ssd1681_set_driver_output(ssd1681_handle_t *handle, uint16_t mux, ssd1681_bool_t gd, ssd1681_bool_t sm, ssd1681_bool_t tb)
set the driver output
uint8_t ssd1681_gram_draw_picture(ssd1681_handle_t *handle, ssd1681_color_t color, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
draw a picture in the gram
uint8_t ssd1681_gram_write_string(ssd1681_handle_t *handle, ssd1681_color_t color, uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t data, ssd1681_font_t font)
draw a string in the gram
uint8_t ssd1681_gram_clear(ssd1681_handle_t *handle, ssd1681_color_t color)
clear the screen in the gram
uint8_t ssd1681_gram_fill_rect(ssd1681_handle_t *handle, ssd1681_color_t color, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t data)
fill a rectangle in the gram
uint8_t ssd1681_set_display_update_control(ssd1681_handle_t *handle, ssd1681_display_control_t red_control, ssd1681_display_control_t black_control)
set the display update control
uint8_t ssd1681_gram_read_point(ssd1681_handle_t *handle, ssd1681_color_t color, uint8_t x, uint8_t y, uint8_t *data)
read a point from the gram
uint8_t ssd1681_set_end_option(ssd1681_handle_t *handle, ssd1681_end_opt_t opt)
end option
uint8_t ssd1681_set_ram_y(ssd1681_handle_t *handle, uint16_t start, uint16_t end)
set the ram y range
uint8_t ssd1681_software_reset(ssd1681_handle_t *handle)
software reset
ssd1681_font_t
ssd1681 font enumeration definition
uint8_t ssd1681_set_mode(ssd1681_handle_t *handle, ssd1681_mode_t mode)
set the mode
uint8_t ssd1681_set_gate_driving_voltage(ssd1681_handle_t *handle, ssd1681_gate_driving_voltage_t voltage)
set the gate driving voltage
uint8_t ssd1681_set_hv_ready_detection(ssd1681_handle_t *handle, uint8_t cool_down_duration, uint8_t cool_down_loop_num)
set the hv ready detection
uint8_t ssd1681_set_ram_x_address_counter(ssd1681_handle_t *handle, uint8_t cnt)
set the ram x address counter
uint8_t ssd1681_set_auto_write_black_ram(ssd1681_handle_t *handle, ssd1681_step_height_t height, ssd1681_step_width_t width)
set the auto write black ram
uint8_t ssd1681_set_auto_write_red_ram(ssd1681_handle_t *handle, ssd1681_step_height_t height, ssd1681_step_width_t width)
set the auto write red ram
uint8_t ssd1681_gram_write_point(ssd1681_handle_t *handle, ssd1681_color_t color, uint8_t x, uint8_t y, uint8_t data)
write a point in the gram
uint8_t ssd1681_set_enter_vcom_sense(ssd1681_handle_t *handle)
set enter vcom sense
uint8_t ssd1681_set_booster_soft_start(ssd1681_handle_t *handle, uint8_t phase1, uint8_t phase2, uint8_t phase3, uint8_t duration)
set the booster soft start
uint8_t ssd1681_set_source_driving_voltage(ssd1681_handle_t *handle, ssd1681_vsh_t vsh1, ssd1681_vsh_t vsh2, ssd1681_vsl_t vsl)
set the source driving voltage
uint8_t ssd1681_set_temperature_sensor(ssd1681_handle_t *handle, ssd1681_temperature_sensor_t sensor)
set the temperature sensor
uint8_t ssd1681_set_vcom_register(ssd1681_handle_t *handle, ssd1681_vcom_t vcom)
write vcom register
uint8_t ssd1681_set_data_entry_mode(ssd1681_handle_t *handle, ssd1681_address_mode_t mode, ssd1681_address_direction_t direction)
set the data entry mode
uint8_t ssd1681_clear(ssd1681_handle_t *handle, ssd1681_color_t color)
clear the screen
uint8_t ssd1681_set_ram_x(ssd1681_handle_t *handle, uint8_t start, uint8_t end)
set the ram x range
uint8_t ssd1681_set_border_waveform(ssd1681_handle_t *handle, ssd1681_vbd_t vbd, ssd1681_vbd_fix_level_t level, ssd1681_gs_transition_t gs_tran, ssd1681_vbd_transition_t vbd_tran)
set the border waveform
uint8_t ssd1681_set_vci_detection(ssd1681_handle_t *handle, ssd1681_vci_level_t level)
set the vci detection
uint8_t ssd1681_gram_update(ssd1681_handle_t *handle, ssd1681_color_t color)
update the gram data
@ SSD1681_COLOR_RED
@ SSD1681_COLOR_BLACK
@ SSD1681_VCOM_NEGATIVE_0P8
#define SSD1681_BASIC_DEFAULT_RAM_X_END
#define SSD1681_BASIC_DEFAULT_DRIVER_OUTPUT_SM
#define SSD1681_BASIC_DEFAULT_DISPLAY_SEQUENCE
#define SSD1681_BASIC_DEFAULT_COOL_DOWN_LOOP_NUM
#define SSD1681_BASIC_DEFAULT_VSH1
#define SSD1681_BASIC_DEFAULT_VCI
#define SSD1681_BASIC_DEFAULT_DRIVER_OUTPUT_GD
#define SSD1681_BASIC_DEFAULT_VBD_FIX_LEVEL
#define SSD1681_BASIC_DEFAULT_RAM_Y_END
#define SSD1681_BASIC_DEFAULT_GATE_DRIVING_VOLTAGE
#define SSD1681_BASIC_DEFAULT_VBD_TRANSITION
uint8_t ssd1681_basic_read_point(ssd1681_color_t color, uint8_t x, uint8_t y, uint8_t *data)
basic example read a point
#define SSD1681_BASIC_DEFAULT_DURATION
uint8_t ssd1681_basic_rect(ssd1681_color_t color, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t data)
basic example fill a rectangle
#define SSD1681_BASIC_DEFAULT_AUTO_BLACK_STEP_HEIGHT
#define SSD1681_BASIC_DEFAULT_AUTO_RED_STEP_HEIGHT
uint8_t ssd1681_basic_init(void)
basic example init
#define SSD1681_BASIC_DEFAULT_VSH2
#define SSD1681_BASIC_DEFAULT_MODE
#define SSD1681_BASIC_DEFAULT_DISPLAY_CONTROL_BLACK
uint8_t ssd1681_basic_picture(ssd1681_color_t color, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
basic example draw a picture
#define SSD1681_BASIC_DEFAULT_VCOM_SENSE_DURATION
#define SSD1681_BASIC_DEFAULT_DRIVER_OUTPUT_TB
#define SSD1681_BASIC_DEFAULT_END_OPT
uint8_t ssd1681_basic_write_point(ssd1681_color_t color, uint8_t x, uint8_t y, uint8_t data)
basic example write a point
#define SSD1681_BASIC_DEFAULT_GS_TRANSITION
#define SSD1681_BASIC_DEFAULT_DISPLAY_CONTROL_RED
uint8_t ssd1681_basic_deinit(void)
basic example deinit
#define SSD1681_BASIC_DEFAULT_RAM_X_START
#define SSD1681_BASIC_DEFAULT_RAM_X_ADDRESS_COUNTER
uint8_t ssd1681_basic_string(ssd1681_color_t color, uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t data, ssd1681_font_t font)
basic example draw a string
#define SSD1681_BASIC_DEFAULT_COOL_DOWN_DURATION
#define SSD1681_BASIC_DEFAULT_PHASE3
#define SSD1681_BASIC_DEFAULT_PHASE2
#define SSD1681_BASIC_DEFAULT_VSL
#define SSD1681_BASIC_DEFAULT_ADDRESS_MODE
#define SSD1681_BASIC_DEFAULT_PHASE1
uint8_t ssd1681_basic_clear(ssd1681_color_t color)
basic example clear
#define SSD1681_BASIC_DEFAULT_RAM_Y_ADDRESS_COUNTER
#define SSD1681_BASIC_DEFAULT_RAM_Y_START
#define SSD1681_BASIC_DEFAULT_DRIVER_OUTPUT_MUX
ssd1681 basic example default definition
#define SSD1681_BASIC_DEFAULT_VBD
#define SSD1681_BASIC_DEFAULT_AUTO_RED_STEP_WIDTH
#define SSD1681_BASIC_DEFAULT_AUTO_BLACK_STEP_WIDTH
#define SSD1681_BASIC_DEFAULT_ADDRESS_DIRECTION
#define SSD1681_BASIC_DEFAULT_TEMPERATURE_SENSOR
uint8_t ssd1681_interface_spi_cmd_data_gpio_write(uint8_t value)
interface command && data gpio write
uint8_t ssd1681_interface_spi_cmd_data_gpio_deinit(void)
interface command && data gpio deinit
uint8_t ssd1681_interface_spi_deinit(void)
interface spi bus deinit
uint8_t ssd1681_interface_reset_gpio_deinit(void)
interface reset gpio deinit
uint8_t ssd1681_interface_reset_gpio_init(void)
interface reset gpio init
uint8_t ssd1681_interface_spi_init(void)
interface spi bus init
uint8_t ssd1681_interface_spi_write_cmd(uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t ssd1681_interface_spi_cmd_data_gpio_init(void)
interface command && data gpio init
uint8_t ssd1681_interface_reset_gpio_write(uint8_t value)
interface reset gpio write
void ssd1681_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t ssd1681_interface_busy_gpio_read(uint8_t *value)
interface busy gpio read
void ssd1681_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t ssd1681_interface_spi_read_cmd(uint8_t *buf, uint16_t len)
interface spi bus read
uint8_t ssd1681_interface_busy_gpio_init(void)
interface busy gpio init
uint8_t ssd1681_interface_busy_gpio_deinit(void)
interface busy gpio deinit