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 File Reference

EVE's co-processor command. More...

#include "EVE_Platform.h"
#include <stdarg.h>

Go to the source code of this file.

Functions

static uint8_t countArgs (const char *str)
 Count number of arguments in Cmd_Text for string format.
 
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_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.
 
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_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.
 
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_number (EVE_HalContext *phost, int16_t x, int16_t y, int16_t font, uint16_t options, int32_t n)
 Send CMD_NUMBER.
 

Detailed Description

EVE's co-processor command.

Author
Bridgetek
Date
2018

MIT License

Copyright (c) [2019] [Bridgetek Pte Ltd (BRTChip)]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file EVE_CoCmd_Widgets.c.

Function Documentation

◆ countArgs()

static uint8_t countArgs ( const char *  str)
static

Count number of arguments in Cmd_Text for string format.

Parameters
str
Returns
count

Definition at line 42 of file EVE_CoCmd_Widgets.c.

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}
unsigned char uint8_t

◆ EVE_CoCmd_button()

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.

Parameters
phostPointer to Hal context
xx-coordinate of button top-left, in pixels
yy-coordinate of button top-left, in pixels
wButton width
hButton height
fontfont to use for text, 0-31
optionsFont option
sButton label text, UTF-8 encoding
...Format of button label text, like printf

Definition at line 154 of file EVE_CoCmd_Widgets.c.

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}
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
static uint8_t countArgs(const char *str)
Count number of arguments in Cmd_Text for string format.
#define EVE_BT815
Definition EVE_Config.h:66
#define EVE_CHIPID
#define OPT_FORMAT
#define CMD_BUTTON
unsigned int uint32_t
#define eve_printf_debug(fmt,...)
uint8_t DlPrimitive

◆ EVE_CoCmd_keys()

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.

Parameters
phostPointer to Hal context
xx-coordinate of keys top-left, in pixels
yy-coordinate of keys top-left, in pixels
wKeys width
hKeys height
fontFont for keys label
optionsDrawing option
skey labels, one character per key

Definition at line 199 of file EVE_CoCmd_Widgets.c.

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}
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
#define CMD_KEYS

◆ EVE_CoCmd_number()

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.

Parameters
phostPointer to Hal context
xx-coordinate of text base, in pixels
yy-coordinate of text base, in pixels
fontfont to use for text, 0-31
optionsDrawing option
nThe number to display, either unsigned or signed 32-bit

Definition at line 277 of file EVE_CoCmd_Widgets.c.

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}
#define CMD_NUMBER

◆ EVE_CoCmd_text()

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.

Parameters
phostPointer to Hal context
xx-coordinate of text base, in pixels
yy-coordinate of text base, in pixels
fontFont to use for text, 0-31
optionsText option
sText string, UTF-8 encoding
...Text format

Definition at line 63 of file EVE_CoCmd_Widgets.c.

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}
#define CMD_TEXT

◆ EVE_CoCmd_text_ex()

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.

Parameters
phostPointer to Hal context
xx-coordinate of text base, in pixels
yy-coordinate of text base, in pixels
fontFont to use for text, 0-31
optionsText option
bottom
baseLine
capsHeight
xOffset
sText string, UTF-8 encoding

Definition at line 136 of file EVE_CoCmd_Widgets.c.

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}
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.
#define OPT_CENTERY
short int16_t

◆ EVE_CoCmd_text_s()

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.

Parameters
phostPointer to Hal context
xx-coordinate of text base, in pixels
yy-coordinate of text base, in pixels
fontFont to use for text, 0-31
optionsText option
sText string, UTF-8 encoding
lengthlength of text

Definition at line 108 of file EVE_CoCmd_Widgets.c.

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}
static ft_uint32_t ft_uint8_t ft_uint32_t length
Definition FT_Gpu_Hal.h:140

◆ EVE_CoCmd_toggle()

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.

Parameters
phostPointer to Hal context
xx-coordinate of top-left of toggle, in pixels
yy-coordinate of top-left of toggle, in pixels
wwidth of toggle, in pixels
fontfont to use for text, 0-31
optionsDrawing option
statestate of the toggle: 0 is off, 65535 is on.
sstring labels for toggle,UTF-8 encoding
...string labels format

Definition at line 229 of file EVE_CoCmd_Widgets.c.

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}
#define CMD_TOGGLE