LibDriver ST7920
Loading...
Searching...
No Matches
driver_st7920_advance.c
Go to the documentation of this file.
1
36
38
39static st7920_handle_t gs_handle;
40
49{
50 uint8_t res;
51
52 /* link functions */
66
67 /* st7920 init */
68 res = st7920_init(&gs_handle);
69 if (res != 0)
70 {
71 st7920_interface_debug_print("st7920: init failed.\n");
72
73 return 1;
74 }
75
76 /* set basic function */
78 if (res != 0)
79 {
80 st7920_interface_debug_print("st7920: set function failed.\n");
81 (void)st7920_deinit(&gs_handle);
82
83 return 1;
84 }
85
86 /* set entry mode */
88 if (res != 0)
89 {
90 st7920_interface_debug_print("st7920: set entry mode failed.\n");
91 (void)st7920_deinit(&gs_handle);
92
93 return 1;
94 }
95
96 /* set display shift mode */
98 if (res != 0)
99 {
100 st7920_interface_debug_print("st7920: set display shift mode failed.\n");
101 (void)st7920_deinit(&gs_handle);
102
103 return 1;
104 }
105
106 /* set cgram address */
107 res = st7920_set_cgram_address(&gs_handle, 0x00);
108 if (res != 0)
109 {
110 st7920_interface_debug_print("st7920: set cgram address failed.\n");
111 (void)st7920_deinit(&gs_handle);
112
113 return 1;
114 }
115
116 /* set ddram address */
117 res = st7920_set_ddram_address(&gs_handle, 0x00);
118 if (res != 0)
119 {
120 st7920_interface_debug_print("st7920: set ddram address failed.\n");
121 (void)st7920_deinit(&gs_handle);
122
123 return 1;
124 }
125
126 /* display clear */
127 res = st7920_display_clear(&gs_handle);
128 if (res != 0)
129 {
130 st7920_interface_debug_print("st7920: display clear failed.\n");
131 (void)st7920_deinit(&gs_handle);
132
133 return 1;
134 }
135
136 /* return home */
137 res = st7920_return_home(&gs_handle);
138 if (res != 0)
139 {
140 st7920_interface_debug_print("st7920: return home failed.\n");
141 (void)st7920_deinit(&gs_handle);
142
143 return 1;
144 }
145
146 /* set display control */
148 if (res != 0)
149 {
150 st7920_interface_debug_print("st7920: set display control failed.\n");
151 (void)st7920_deinit(&gs_handle);
152
153 return 1;
154 }
155
156 return 0;
157}
158
167{
168 /* deinit st7920 */
169 if (st7920_deinit(&gs_handle) != 0)
170 {
171 return 1;
172 }
173 else
174 {
175 return 0;
176 }
177}
178
187{
188 uint8_t res;
189
190 /* set basic function */
192 if (res != 0)
193 {
194 return 1;
195 }
196
197 /* set display control */
199 if (res != 0)
200 {
201 return 1;
202 }
203
204 return 0;
205}
206
215{
216 uint8_t res;
217
218 /* set basic function */
220 if (res != 0)
221 {
222 return 1;
223 }
224
225 /* set display control */
227 if (res != 0)
228 {
229 return 1;
230 }
231
232 return 0;
233}
234
243{
244 uint8_t res;
245
246 /* display clear */
247 res = st7920_display_clear(&gs_handle);
248 if (res != 0)
249 {
250 return 1;
251 }
252
253 return 0;
254}
255
264{
265 uint8_t res;
266
267 /* set basic function */
269 if (res != 0)
270 {
271 return 1;
272 }
273
274 /* display clear */
275 res = st7920_display_clear(&gs_handle);
276 if (res != 0)
277 {
278 return 1;
279 }
280
281 return 0;
282}
283
292{
293 uint8_t res;
294
295 /* set extended function */
297 if (res != 0)
298 {
299 return 1;
300 }
301
302 /* display clear */
303 res = st7920_display_clear(&gs_handle);
304 if (res != 0)
305 {
306 return 1;
307 }
308
309 return 0;
310}
311
322uint8_t st7920_advance_write_point(uint8_t x, uint8_t y, uint8_t data)
323{
324 uint8_t res;
325
326 /* set extended function */
328 if (res != 0)
329 {
330 return 1;
331 }
332
333 /* write point */
334 res = st7920_write_point(&gs_handle, x, y, data);
335 if (res != 0)
336 {
337 return 1;
338 }
339
340 return 0;
341}
342
353uint8_t st7920_advance_read_point(uint8_t x, uint8_t y, uint8_t *data)
354{
355 uint8_t res;
356
357 /* set extended function */
359 if (res != 0)
360 {
361 return 1;
362 }
363
364 /* read point */
365 res = st7920_read_point(&gs_handle, x, y, (uint8_t *)data);
366 if (res != 0)
367 {
368 return 1;
369 }
370
371 return 0;
372}
373
384uint8_t st7920_advance_string(uint8_t x, uint8_t y, char *str)
385{
386 uint8_t res;
387
388 /* set basic function */
390 if (res != 0)
391 {
392 return 1;
393 }
394
395 /* write string */
396 res = st7920_write_string(&gs_handle, x, y, (char *)str);
397 if (res != 0)
398 {
399 return 1;
400 }
401
402 return 0;
403}
404
417uint8_t st7920_advance_rect(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color)
418{
419 uint8_t res;
420
421 /* set extended function */
423 if (res != 0)
424 {
425 return 1;
426 }
427
428 /* fill a rect */
429 res = st7920_fill_rect(&gs_handle, left, top, right, bottom, color);
430 if (res != 0)
431 {
432 return 1;
433 }
434
435 return 0;
436}
437
450uint8_t st7920_advance_picture(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
451{
452 uint8_t res;
453
454 /* set extended function */
456 if (res != 0)
457 {
458 return 1;
459 }
460
461 /* draw picture */
462 res = st7920_draw_picture(&gs_handle, left, top, right, bottom, (uint8_t *)img);
463 if (res != 0)
464 {
465 return 1;
466 }
467
468 return 0;
469}
470
483uint8_t st7920_advance_compress_picture(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
484{
485 uint8_t res;
486
487 /* set extended function */
489 if (res != 0)
490 {
491 return 1;
492 }
493
494 /* draw picture */
495 res = st7920_draw_compress_picture(&gs_handle, left, top, right, bottom, (uint8_t *)img);
496 if (res != 0)
497 {
498 return 1;
499 }
500
501 return 0;
502}
503
513{
514 uint8_t res;
515
516 /* set extended function */
518 if (res != 0)
519 {
520 return 1;
521 }
522
523 /* set reverse line */
524 if (st7920_set_reverse_line(&gs_handle, l) != 0)
525 {
526 return 1;
527 }
528 else
529 {
530 return 0;
531 }
532}
533
542uint8_t st7920_advance_set_scroll(uint8_t addr)
543{
544 uint8_t res;
545
546 /* set extended function */
548 if (res != 0)
549 {
550 return 1;
551 }
552
553 /* set scroll */
554 if (st7920_set_scroll_address(&gs_handle, addr) != 0)
555 {
556 return 1;
557 }
558 else
559 {
560 return 0;
561 }
562}
563
572{
573 uint8_t res;
574
575 /* set extended function */
577 if (res != 0)
578 {
579 return 1;
580 }
581
582 /* st7920 start moving */
583 if (st7920_set_vertical_scroll(&gs_handle, ST7920_BOOL_TRUE) != 0)
584 {
585 return 1;
586 }
587 else
588 {
589 return 0;
590 }
591}
592
601{
602 uint8_t res;
603
604 /* set extended function */
606 if (res != 0)
607 {
608 return 1;
609 }
610
611 /* st7920 stop moving */
612 if (st7920_set_vertical_scroll(&gs_handle, ST7920_BOOL_FALSE) != 0)
613 {
614 return 1;
615 }
616 else
617 {
618 return 0;
619 }
620}
driver st7920 advance header file
uint8_t st7920_set_cgram_address(st7920_handle_t *handle, uint8_t addr)
set the cgram address
uint8_t st7920_set_function(st7920_handle_t *handle, st7920_interface_bus_bit_t bus_bit, st7920_command_mode_t mode)
set the function
uint8_t st7920_display_clear(st7920_handle_t *handle)
clear the display
uint8_t st7920_set_entry_mode(st7920_handle_t *handle, st7920_display_shift_t shift, st7920_address_counter_mode_t mode)
set the entry mode
struct st7920_handle_s st7920_handle_t
st7920 handle structure definition
uint8_t st7920_return_home(st7920_handle_t *handle)
return the home
uint8_t st7920_init(st7920_handle_t *handle)
initialize the chip
uint8_t st7920_deinit(st7920_handle_t *handle)
close the chip
uint8_t st7920_set_ddram_address(st7920_handle_t *handle, uint8_t addr)
set the ddram address
uint8_t st7920_set_display_control(st7920_handle_t *handle, st7920_bool_t display_on, st7920_bool_t cursor_on, st7920_bool_t character_blink_on)
set the display control
uint8_t st7920_write_string(st7920_handle_t *handle, uint8_t x, uint8_t y, char *str)
show a string
uint8_t st7920_set_display_shift_mode(st7920_handle_t *handle, st7920_display_shift_mode_t mode)
set the display shift mode
@ ST7920_BOOL_TRUE
@ ST7920_BOOL_FALSE
@ ST7920_COMMAND_MODE_BASIC
@ ST7920_COMMAND_MODE_EXTENDED
@ ST7920_INTERFACE_BUS_BIT_8
uint8_t st7920_advance_string(uint8_t x, uint8_t y, char *str)
advance example write a string
uint8_t st7920_advance_clear(void)
advance example clear
uint8_t st7920_advance_write_point(uint8_t x, uint8_t y, uint8_t data)
advance example write a point
uint8_t st7920_advance_disable_scroll(void)
advance example disable scroll
uint8_t st7920_advance_enable_scroll(void)
advance example enable scroll
uint8_t st7920_advance_set_scroll(uint8_t addr)
advance example set scroll
uint8_t st7920_advance_compress_picture(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
advance example draw a compressed picture
uint8_t st7920_advance_init(void)
advance example init
uint8_t st7920_advance_set_reverse_line(st7920_reverse_line_t l)
advance example set reverse line
uint8_t st7920_advance_display_on(void)
advance example display on
uint8_t st7920_advance_clear_image(void)
advance example clear image
uint8_t st7920_advance_read_point(uint8_t x, uint8_t y, uint8_t *data)
advance example read a point
uint8_t st7920_advance_picture(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
advance example draw a picture
uint8_t st7920_advance_rect(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color)
advance example fill a rectangle
uint8_t st7920_advance_deinit(void)
advance example deinit
uint8_t st7920_advance_clear_string(void)
advance example clear string
#define ST7920_ADVANCE_DEFAULT_ADDRESS_COUNTER_MODE
#define ST7920_ADVANCE_DEFAULT_DISPLAY_SHIFT
#define ST7920_ADVANCE_DEFAULT_BUS_BIT
st7920 advance example default definition
uint8_t st7920_advance_display_off(void)
advance example display off
#define ST7920_ADVANCE_DEFAULT_DISPLAY_SHIFT_MODE
uint8_t st7920_draw_compress_picture(st7920_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
draw a compressed picture
uint8_t st7920_write_point(st7920_handle_t *handle, uint8_t x, uint8_t y, uint8_t data)
write a point
uint8_t st7920_set_reverse_line(st7920_handle_t *handle, st7920_reverse_line_t l)
set the reverse line
uint8_t st7920_set_vertical_scroll(st7920_handle_t *handle, st7920_bool_t enable)
set the vertical scroll
uint8_t st7920_set_extended_function(st7920_handle_t *handle, st7920_interface_bus_bit_t bus_bit, st7920_command_mode_t mode, st7920_bool_t graphic_display_enable)
set the extended function
st7920_reverse_line_t
st7920 reverse line enumeration definition
uint8_t st7920_fill_rect(st7920_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color)
fill a rectangle
uint8_t st7920_draw_picture(st7920_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
draw a picture
uint8_t st7920_read_point(st7920_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data)
read a point
uint8_t st7920_set_scroll_address(st7920_handle_t *handle, uint8_t addr)
set the scroll address
void st7920_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t st7920_interface_sclk_gpio_write(uint8_t value)
interface sclk gpio write
uint8_t st7920_interface_cs_gpio_deinit(void)
interface cs gpio deinit
uint8_t st7920_interface_sclk_gpio_init(void)
interface sclk gpio init
uint8_t st7920_interface_cs_gpio_write(uint8_t value)
interface cs gpio write
uint8_t st7920_interface_sid_gpio_write(uint8_t value)
interface sid gpio write
void st7920_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t st7920_interface_cs_gpio_init(void)
interface cs gpio init
uint8_t st7920_interface_sclk_gpio_deinit(void)
interface sclk gpio deinit
void st7920_interface_delay_us(uint32_t us)
interface delay us
uint8_t st7920_interface_sid_gpio_init(void)
interface sid gpio init
uint8_t st7920_interface_sid_gpio_deinit(void)
interface sid gpio deinit