forked from ginge/libdgus_ii
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dgus_control_text.h
229 lines (207 loc) · 6.34 KB
/
dgus_control_text.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#pragma once
/**
* @file dgus_control_text.h
* @author Barry Carter
* @date 01 Jan 2021
* @brief DGUS II LCD Text Utilites
*/
#include <stddef.h>
#include <stdint.h>
#include "dgus_reg.h"
#include "dgus.h"
typedef struct __attribute__((packed)) dgus_control_text_display {
uint16_t vp;
dgus_control_position pos;
uint16_t colour;
dgus_control_size size;
uint16_t text_len;
uint8_t font_0_id;
uint8_t font_1_id;
uint8_t font_x_dots;
uint8_t font_y_dots;
uint8_t encode_mode;
uint8_t hor_distance;
uint8_t ver_distance;
uint8_t reserved0;
} dgus_control_text_display; /**< Register layout for the text SP register */
/**
* @brief Read from VAR address as text
* Reads in 8 bit data format when using 0x02 GBK
*
* @param addr
* @param buf
* @param len
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_get_text(uint16_t addr, uint8_t *buf, uint8_t len);
/**
* @brief Write text to the address VAR
* @warning The DGUS does not do string null termination when rendering. You will need to clear the value beforehand, or use the dgus_set_text()
*
* @param addr address to write to
* @param text text to send. Must be null terinated
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_set_text(uint16_t addr, char *text);
/**
* @brief Write text to the address VAR and clear all text after to field length @p len
*
* @param addr
* @param text
* @param len
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_set_text_padded(uint16_t addr, char *text, uint8_t len);
/**
* @brief Set the VP pointer address in memory
* @note addr must be an SP address and SP must be enabled
* e.g. uint16_t vp; dgus_get_text_vp(0x4000, &vp);
*
* @param addr address to write to
* @param vp variable to place result the memory VP address
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_get_text_vp(uint16_t addr, uint16_t *vp);
/**
* @brief Set the virtual pointer VP address for the control
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param vp
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_set_text_vp(uint16_t addr, uint16_t vp);
/**
* @brief Get the position of the text on the screen
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param pos
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_get_text_pos(uint16_t addr, dgus_control_position *pos);
/**
* @brief Set the position of the text on the screen
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param pos
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_set_text_pos(uint16_t addr, dgus_control_position pos);
/**
* @brief Get the colour of the text
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param colour
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_get_text_colour(uint16_t addr, uint16_t *colour);
/**
* @brief Set the colur of the text
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param colour
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_set_text_colour(uint16_t addr, uint16_t colour);
/**
* @brief Set the size of the box containing the text
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param size
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_get_text_bounding_size(uint16_t addr, dgus_control_size *size);
/**
* @brief Get the size of the box containing the text
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param size
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_set_text_bounding_size(uint16_t addr, dgus_control_size size);
/**
* @brief Get the text length
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param len
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_get_text_len(uint16_t addr, uint16_t *len);
/**
* @brief Set the text length
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param len
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_set_text_len(uint16_t addr, uint16_t len);
/**
* @brief Get the current font id
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param font0
* @param font1
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_get_text_fonts(uint16_t addr, uint8_t *font0, uint8_t *font1);
/**
* @brief set the font ids
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param font0
* @param font1
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_set_text_fonts(uint16_t addr, uint8_t font0, uint8_t font1);
/**
* @brief Get the elipses breakpoint. i.e. how long before we ...
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param fontx_dots
* @param fonty_dots
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_get_text_font_dots(uint16_t addr, uint8_t *fontx_dots, uint8_t *fonty_dots);
/**
* @brief Set the elipses breakpoint. i.e. how long before we ...
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param fontx_dots
* @param fonty_dots
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_set_text_font_dots(uint16_t addr, uint8_t fontx_dots, uint8_t fonty_dots);
/**
* @brief Set the text encoding mode and vertical spacing
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param encode_mode 0x00=8bit, 0x01=GB2312, 0x02=GBK (most compatible with this lib), 0x03=BIG5, 0x04=SJIS, 0x05=UNICODE
* @param vert_distance spacing y
* @param horiz_distance spacing x
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_get_text_encode_mode_distance(uint16_t addr, uint8_t *encode_mode, uint8_t *vert_distance, uint8_t *horiz_distance);
/**
* @brief get text encoding mode and vertical spacing
* @note addr must be an SP address and SP must be enabled
*
* @param addr
* @param encode_mode 0x00=8bit, 0x01=GB2312, 0x02=GBK (most compatible with this lib), 0x03=BIG5, 0x04=SJIS, 0x05=UNICODE
* @param vert_distance spacing y
* @param horiz_distance spacing x
* @return Response such as #DGUS_TIMEOUT
*/
DGUS_RETURN dgus_set_text_encode_mode_distance(uint16_t addr, uint8_t encode_mode, uint8_t vert_distance, uint8_t horiz_distance);