LibDriver ST7920
Loading...
Searching...
No Matches
driver_st7920.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_ST7920_H
38#define DRIVER_ST7920_H
39
40#include <stdint.h>
41#include <stdio.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62#ifndef ST7920_COMMAND_CMD_DELAY
63 #define ST7920_COMMAND_CMD_DELAY 100
64#endif
65
69#ifndef ST7920_COMMAND_DATA_DELAY
70 #define ST7920_COMMAND_DATA_DELAY 10
71#endif
72
76typedef enum
77{
81
90
99
110
119
128
132
137
148
152
157
161typedef struct st7920_handle_s
162{
163 uint8_t (*cs_gpio_init)(void);
164 uint8_t (*cs_gpio_deinit)(void);
165 uint8_t (*cs_gpio_write)(uint8_t value);
166 uint8_t (*sclk_gpio_init)(void);
167 uint8_t (*sclk_gpio_deinit)(void);
168 uint8_t (*sclk_gpio_write)(uint8_t value);
169 uint8_t (*sid_gpio_init)(void);
170 uint8_t (*sid_gpio_deinit)(void);
171 uint8_t (*sid_gpio_write)(uint8_t value);
172 void (*debug_print)(const char *const fmt, ...);
173 void (*delay_ms)(uint32_t ms);
174 void (*delay_us)(uint32_t us);
176 uint8_t inited;
178 uint16_t gram[8][64];
180
196
200
207
214#define DRIVER_ST7920_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
215
222#define DRIVER_ST7920_LINK_CS_GPIO_INIT(HANDLE, FUC) (HANDLE)->cs_gpio_init = FUC
223
230#define DRIVER_ST7920_LINK_CS_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->cs_gpio_deinit = FUC
231
238#define DRIVER_ST7920_LINK_CS_GPIO_WRITE(HANDLE, FUC) (HANDLE)->cs_gpio_write = FUC
239
246#define DRIVER_ST7920_LINK_SCLK_GPIO_INIT(HANDLE, FUC) (HANDLE)->sclk_gpio_init = FUC
247
254#define DRIVER_ST7920_LINK_SCLK_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->sclk_gpio_deinit = FUC
255
262#define DRIVER_ST7920_LINK_SCLK_GPIO_WRITE(HANDLE, FUC) (HANDLE)->sclk_gpio_write = FUC
263
270#define DRIVER_ST7920_LINK_SID_GPIO_INIT(HANDLE, FUC) (HANDLE)->sid_gpio_init = FUC
271
278#define DRIVER_ST7920_LINK_SID_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->sid_gpio_deinit = FUC
279
286#define DRIVER_ST7920_LINK_SID_GPIO_WRITE(HANDLE, FUC) (HANDLE)->sid_gpio_write = FUC
287
294#define DRIVER_ST7920_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
295
302#define DRIVER_ST7920_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
303
310#define DRIVER_ST7920_LINK_DELAY_US(HANDLE, FUC) (HANDLE)->delay_us = FUC
311
315
322
331uint8_t st7920_info(st7920_info_t *info);
332
343uint8_t st7920_init(st7920_handle_t *handle);
344
355uint8_t st7920_deinit(st7920_handle_t *handle);
356
374uint8_t st7920_write_string(st7920_handle_t *handle, uint8_t x, uint8_t y, char *str);
375
387
399uint8_t st7920_return_home(st7920_handle_t *handle);
400
415
430uint8_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);
431
445
459
473uint8_t st7920_set_cgram_address(st7920_handle_t *handle, uint8_t addr);
474
488uint8_t st7920_set_ddram_address(st7920_handle_t *handle, uint8_t addr);
489
503uint8_t st7920_write_ram(st7920_handle_t *handle, uint8_t *data, uint8_t len);
504
508
515
533uint8_t st7920_write_point(st7920_handle_t *handle, uint8_t x, uint8_t y, uint8_t data);
534
552uint8_t st7920_read_point(st7920_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data);
553
573uint8_t st7920_fill_rect(st7920_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color);
574
594uint8_t st7920_draw_picture(st7920_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img);
595
615uint8_t st7920_draw_compress_picture(st7920_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img);
616
628uint8_t st7920_set_standby(st7920_handle_t *handle);
629
643
657
672 st7920_command_mode_t mode, st7920_bool_t graphic_display_enable);
673
687uint8_t st7920_set_scroll_address(st7920_handle_t *handle, uint8_t addr);
688
705uint8_t st7920_set_graphic_address(st7920_handle_t *handle, uint8_t vertical_addr, uint8_t horizontal_addr);
706
710
717
729uint8_t st7920_write_cmd(st7920_handle_t *handle, uint8_t cmd);
730
742uint8_t st7920_write_data(st7920_handle_t *handle, uint8_t data);
743
747
751
752#ifdef __cplusplus
753}
754#endif
755
756#endif
uint8_t st7920_set_cgram_address(st7920_handle_t *handle, uint8_t addr)
set the cgram address
uint8_t st7920_info(st7920_info_t *info)
get chip's information
struct st7920_info_s st7920_info_t
st7920 information structure definition
uint8_t st7920_set_function(st7920_handle_t *handle, st7920_interface_bus_bit_t bus_bit, st7920_command_mode_t mode)
set the function
st7920_bool_t
st7920 bool enumeration definition
uint8_t st7920_write_ram(st7920_handle_t *handle, uint8_t *data, uint8_t len)
write the ram
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
st7920_display_shift_t
st7920 display shift enumeration definition
struct st7920_handle_s st7920_handle_t
st7920 handle structure definition
st7920_command_mode_t
st7920 command mode enumeration definition
uint8_t st7920_return_home(st7920_handle_t *handle)
return the home
st7920_address_counter_mode_t
st7920 address counter mode enumeration definition
st7920_display_shift_mode_t
st7920 display shift mode enumeration definition
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
st7920_interface_bus_bit_t
st7920 interface bus bit enumeration definition
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_DISPLAY_SHIFT_LEFT
@ ST7920_DISPLAY_SHIFT_RIGHT
@ ST7920_COMMAND_MODE_BASIC
@ ST7920_COMMAND_MODE_EXTENDED
@ ST7920_ADDRESS_COUNTER_MODE_INCREASE
@ ST7920_ADDRESS_COUNTER_MODE_DECREASE
@ ST7920_DISPLAY_SHIFT_MODE_LL
@ ST7920_DISPLAY_SHIFT_MODE_LH
@ ST7920_DISPLAY_SHIFT_MODE_HL
@ ST7920_DISPLAY_SHIFT_MODE_HH
@ ST7920_INTERFACE_BUS_BIT_4
@ ST7920_INTERFACE_BUS_BIT_8
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_set_standby(st7920_handle_t *handle)
terminate to the standby mode
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_set_graphic_address(st7920_handle_t *handle, uint8_t vertical_addr, uint8_t horizontal_addr)
set the graphic address
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
@ ST7920_REVERSE_LINE_FIRST
@ ST7920_REVERSE_LINE_SECOND
@ ST7920_REVERSE_LINE_THIRD
@ ST7920_REVERSE_LINE_FOURTH
uint8_t st7920_write_data(st7920_handle_t *handle, uint8_t data)
write data
uint8_t st7920_write_cmd(st7920_handle_t *handle, uint8_t cmd)
write command
st7920 handle structure definition
uint8_t(* sid_gpio_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* sclk_gpio_write)(uint8_t value)
uint8_t(* sclk_gpio_deinit)(void)
uint8_t(* cs_gpio_deinit)(void)
uint16_t gram[8][64]
void(* debug_print)(const char *const fmt,...)
uint8_t(* sid_gpio_write)(uint8_t value)
void(* delay_us)(uint32_t us)
uint8_t(* cs_gpio_init)(void)
uint8_t(* sclk_gpio_init)(void)
uint8_t(* cs_gpio_write)(uint8_t value)
uint8_t(* sid_gpio_deinit)(void)
st7920 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]