image/svg+xml
Brteve's API for EveApps
Version 0.0.1
The reference document for common folder of EveApps project.
 
Loading...
Searching...
No Matches
EVE_CoCmd_Widgets.c
Go to the documentation of this file.
1
32#include "EVE_Platform.h"
33
34#include <stdarg.h>
35
36#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
42static uint8_t countArgs(const char *str)
43{
44 uint8_t count = 0;
45 const char *tmp = str;
46
47 while ((tmp = strstr(tmp, "%")))
48 {
49 if (*(tmp + 1) == '%')
50 {
51 tmp += 2;
52 }
53 else
54 {
55 count++;
56 tmp++;
57 }
58 }
59 return count;
60}
61#endif
62
63EVE_HAL_EXPORT void EVE_CoCmd_text(EVE_HalContext *phost, int16_t x, int16_t y, int16_t font, uint16_t options, const char *s, ...)
64{
65 va_list args;
66#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
67 uint8_t num;
68#endif
69
70#if EVE_CMD_HOOKS
71 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_TEXT, 0))
72 return;
73#endif
74
75 if (font >= 32)
76 {
77 if (font != 63)
78 eve_printf_debug("Invalid font handle specified: %i\n", (int)font);
79 return;
80 }
81 va_start(args, s);
82#if (EVE_SUPPORT_CHIPID >= EVE_BT815) /* OPT_FORMAT not defined in FT8xx chip */
83 num = (options & OPT_FORMAT) ? (countArgs(s)) : (0); /* Only check % characters if option OPT_FORMAT is set */
84#endif
85
86 EVE_Cmd_startFunc(phost);
87 EVE_Cmd_wr32(phost, CMD_TEXT);
88 EVE_Cmd_wr16(phost, x);
89 EVE_Cmd_wr16(phost, y);
90 EVE_Cmd_wr16(phost, font);
91 EVE_Cmd_wr16(phost, options);
93#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
94 if (EVE_CHIPID >= EVE_BT815)
95 {
96 for (uint8_t i = 0; i < num; i++)
97 EVE_Cmd_wr32(phost, (uint32_t)va_arg(args, uint32_t));
98 }
99#endif
100 EVE_Cmd_endFunc(phost);
101 va_end(args);
102
103#if (EVE_DL_OPTIMIZE)
104 phost->DlPrimitive = 0;
105#endif
106}
107
109{
110#if EVE_CMD_HOOKS
111 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_TEXT, 0))
112 return;
113#endif
114
115 if (font >= 32)
116 {
117 if (font != 63)
118 eve_printf_debug("Invalid font handle specified: %i\n", (int)font);
119 return;
120 }
121
122 EVE_Cmd_startFunc(phost);
123 EVE_Cmd_wr32(phost, CMD_TEXT);
124 EVE_Cmd_wr16(phost, x);
125 EVE_Cmd_wr16(phost, y);
126 EVE_Cmd_wr16(phost, font);
127 EVE_Cmd_wr16(phost, options);
128 EVE_Cmd_wrString(phost, s, length);
129 EVE_Cmd_endFunc(phost);
130
131#if (EVE_DL_OPTIMIZE)
132 phost->DlPrimitive = 0;
133#endif
134}
135
136EVE_HAL_EXPORT void EVE_CoCmd_text_ex(EVE_HalContext *phost, int16_t x, int16_t y, int16_t font, uint16_t options, bool bottom, int16_t baseLine, int16_t capsHeight, int16_t xOffset, const char *s)
137{
138 int16_t yOffset;
139 if (options & OPT_CENTERY)
140 yOffset = baseLine - (capsHeight >> 1);
141 else if (bottom)
142 yOffset = baseLine;
143 else
144 yOffset = baseLine - capsHeight;
145 /*
146 if (options & OPT_RIGHTX)
147 xOffset = 0;
148 else if (options & OPT_CENTERX)
149 xOffset >>= 1;
150 */
151 EVE_CoCmd_text(phost, x - xOffset, y - yOffset, font, options & ~OPT_CENTERY, s);
152}
153
154EVE_HAL_EXPORT void EVE_CoCmd_button(EVE_HalContext *phost, int16_t x, int16_t y, int16_t w, int16_t h, int16_t font, uint16_t options, const char *s, ...)
155{
156 va_list args;
157#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
158 uint8_t num;
159#endif
160
161#if EVE_CMD_HOOKS
162 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_BUTTON, 0))
163 return;
164#endif
165
166 if (font >= 32)
167 {
168 if (font != 63)
169 eve_printf_debug("Invalid font handle specified: %i\n", (int)font);
170 return;
171 }
172
173 va_start(args, s);
174#if (EVE_SUPPORT_CHIPID >= EVE_BT815) /* OPT_FORMAT not defined in FT8xx chip */
175 num = (options & OPT_FORMAT) ? (countArgs(s)) : (0); /* Only check % characters if option OPT_FORMAT is set */
176#endif
177
178 EVE_Cmd_startFunc(phost);
179 EVE_Cmd_wr32(phost, CMD_BUTTON);
180 EVE_Cmd_wr32(phost, (((uint32_t)y << 16) | (x & 0xffff)));
181 EVE_Cmd_wr32(phost, (((uint32_t)h << 16) | (w & 0xffff)));
182 EVE_Cmd_wr32(phost, (((uint32_t)options << 16) | (font & 0xffff)));
184#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
185 if (EVE_CHIPID >= EVE_BT815)
186 {
187 for (uint8_t i = 0; i < num; i++)
188 EVE_Cmd_wr32(phost, (uint32_t)va_arg(args, uint32_t));
189 }
190#endif
191 EVE_Cmd_endFunc(phost);
192 va_end(args);
193
194#if (EVE_DL_OPTIMIZE)
195 phost->DlPrimitive = 0;
196#endif
197}
198
199EVE_HAL_EXPORT void EVE_CoCmd_keys(EVE_HalContext *phost, int16_t x, int16_t y, int16_t w, int16_t h, int16_t font, uint16_t options, const char *s)
200{
201#if EVE_CMD_HOOKS
202 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_KEYS, 0))
203 return;
204#endif
205
206 if (font >= 32)
207 {
208 if (font != 63)
209 eve_printf_debug("Invalid font handle specified: %i\n", (int)font);
210 return;
211 }
212
213 EVE_Cmd_startFunc(phost);
214 EVE_Cmd_wr32(phost, CMD_KEYS);
215 EVE_Cmd_wr16(phost, x);
216 EVE_Cmd_wr16(phost, y);
217 EVE_Cmd_wr16(phost, w);
218 EVE_Cmd_wr16(phost, h);
219 EVE_Cmd_wr16(phost, font);
220 EVE_Cmd_wr16(phost, options);
222 EVE_Cmd_endFunc(phost);
223
224#if (EVE_DL_OPTIMIZE)
225 phost->DlPrimitive = 0;
226#endif
227}
228
229EVE_HAL_EXPORT void EVE_CoCmd_toggle(EVE_HalContext *phost, int16_t x, int16_t y, int16_t w, int16_t font, uint16_t options, uint16_t state, const char *s, ...)
230{
231 va_list args;
232#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
233 uint8_t num;
234#endif
235
236#if EVE_CMD_HOOKS
237 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_TOGGLE, 0))
238 return;
239#endif
240
241 if (font >= 32)
242 {
243 if (font != 63)
244 eve_printf_debug("Invalid font handle specified: %i\n", (int)font);
245 return;
246 }
247
248 va_start(args, s);
249#if (EVE_SUPPORT_CHIPID >= EVE_BT815) /* OPT_FORMAT not defined in FT8xx chip */
250 num = (options & OPT_FORMAT) ? (countArgs(s)) : (0); //Only check % characters if option OPT_FORMAT is set
251#endif
252
253 EVE_Cmd_startFunc(phost);
254 EVE_Cmd_wr32(phost, CMD_TOGGLE);
255 EVE_Cmd_wr16(phost, x);
256 EVE_Cmd_wr16(phost, y);
257 EVE_Cmd_wr16(phost, w);
258 EVE_Cmd_wr16(phost, font);
259 EVE_Cmd_wr16(phost, options);
260 EVE_Cmd_wr16(phost, state);
262#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
263 if (EVE_CHIPID >= EVE_BT815)
264 {
265 for (uint8_t i = 0; i < num; i++)
266 EVE_Cmd_wr32(phost, (uint32_t)va_arg(args, uint32_t));
267 }
268#endif
269 EVE_Cmd_endFunc(phost);
270 va_end(args);
271
272#if (EVE_DL_OPTIMIZE)
273 phost->DlPrimitive = 0;
274#endif
275}
276
278{
279#if EVE_CMD_HOOKS
280 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_NUMBER, 0))
281 return;
282#endif
283
284 if (font >= 32)
285 {
286 if (font != 63)
287 eve_printf_debug("Invalid font handle specified: %i\n", (int)font);
288 return;
289 }
290
291 EVE_Cmd_startFunc(phost);
292 EVE_Cmd_wr32(phost, CMD_NUMBER);
293 EVE_Cmd_wr16(phost, x);
294 EVE_Cmd_wr16(phost, y);
295 EVE_Cmd_wr16(phost, font);
296 EVE_Cmd_wr16(phost, options);
297 EVE_Cmd_wr32(phost, n);
298 EVE_Cmd_endFunc(phost);
299
300#if (EVE_DL_OPTIMIZE)
301 phost->DlPrimitive = 0;
302#endif
303}
304
305/* end of file */
EVE_HAL_EXPORT bool EVE_Cmd_wr16(EVE_HalContext *phost, uint16_t value)
Write 2 bytes to Coprocessor's command fifo.
Definition EVE_Cmd.c:366
EVE_HAL_EXPORT uint32_t EVE_Cmd_wrString(EVE_HalContext *phost, const char *str, uint32_t maxLength)
Write a string into Coprocessor's command fifo.
Definition EVE_Cmd.c:322
EVE_HAL_EXPORT void EVE_Cmd_startFunc(EVE_HalContext *phost)
Begin writing a function, keeps the transfer open.
Definition EVE_Cmd.c:262
EVE_HAL_EXPORT void EVE_Cmd_endFunc(EVE_HalContext *phost)
End writing a function, closes the transfer.
Definition EVE_Cmd.c:274
EVE_HAL_EXPORT bool EVE_Cmd_wr32(EVE_HalContext *phost, uint32_t value)
Write 4 bytes to Coprocessor's command fifo.
Definition EVE_Cmd.c:394
#define EVE_CMD_STRING_MAX
Definition EVE_Cmd.h:44
EVE_HAL_EXPORT void EVE_CoCmd_text_s(EVE_HalContext *phost, int16_t x, int16_t y, int16_t font, uint16_t options, const char *s, uint32_t length)
Send CMD_TEXT with length.
static uint8_t countArgs(const char *str)
Count number of arguments in Cmd_Text for string format.
EVE_HAL_EXPORT void EVE_CoCmd_text_ex(EVE_HalContext *phost, int16_t x, int16_t y, int16_t font, uint16_t options, bool bottom, int16_t baseLine, int16_t capsHeight, int16_t xOffset, const char *s)
Send CMD_TEXT.
EVE_HAL_EXPORT void EVE_CoCmd_button(EVE_HalContext *phost, int16_t x, int16_t y, int16_t w, int16_t h, int16_t font, uint16_t options, const char *s,...)
Send CMD_BUTTON.
EVE_HAL_EXPORT void EVE_CoCmd_toggle(EVE_HalContext *phost, int16_t x, int16_t y, int16_t w, int16_t font, uint16_t options, uint16_t state, const char *s,...)
Send CMD_TOGGLE.
EVE_HAL_EXPORT void EVE_CoCmd_text(EVE_HalContext *phost, int16_t x, int16_t y, int16_t font, uint16_t options, const char *s,...)
Send CMD_TEXT.
EVE_HAL_EXPORT void EVE_CoCmd_number(EVE_HalContext *phost, int16_t x, int16_t y, int16_t font, uint16_t options, int32_t n)
Send CMD_NUMBER.
EVE_HAL_EXPORT void EVE_CoCmd_keys(EVE_HalContext *phost, int16_t x, int16_t y, int16_t w, int16_t h, int16_t font, uint16_t options, const char *s)
Send CMD_KEYS.
#define EVE_HAL_EXPORT
#define EVE_BT815
Definition EVE_Config.h:66
#define EVE_CHIPID
#define OPT_FORMAT
#define CMD_TOGGLE
#define CMD_BUTTON
#define OPT_CENTERY
#define CMD_TEXT
#define CMD_KEYS
#define CMD_NUMBER
unsigned short uint16_t
int int32_t
unsigned int uint32_t
short int16_t
unsigned char uint8_t
Platform selector.
#define eve_printf_debug(fmt,...)
static ft_uint32_t ft_uint8_t ft_uint32_t length
Definition FT_Gpu_Hal.h:140
uint8_t DlPrimitive