Sun, 21 Oct 2018 13:07:50 +0200
Updated documentation
0 | 1 | /** |
2 | * @file buttons.h | |
3 | * @brief The touch buttons. | |
4 | */ | |
5 | ||
6 | #ifndef _BUTTONS_H | |
7 | #define _BUTTONS_H | |
8 | ||
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
9 | #define MAXBUTTONS 40 ///< Maximum buttons on a screen |
0 | 10 | |
11 | ||
12 | /** | |
13 | * @brief Definition of the touch screen buttons. | |
14 | */ | |
15 | typedef struct { | |
16 | int x; ///< Starting X position, -1 is terminator. | |
17 | int y; ///< Starting Y position | |
18 | int w; ///< Width | |
19 | int h; ///< Height | |
20 | char text[11]; ///< Button text | |
21 | bool dark; ///< Alternate dark color. | |
22 | bool small; ///< Use small font. | |
23 | bool lock; ///< Indicate locked color. | |
24 | } sButton; | |
25 | ||
26 | ||
27 | /** | |
28 | * @brief Wait for the touch screen is released. | |
29 | */ | |
30 | void WaitTouchReleased(void); | |
31 | ||
32 | /** | |
33 | * @brief Clear the configured buttons list | |
34 | */ | |
35 | void Buttons_Clear(void); | |
36 | ||
37 | /** | |
38 | * @brief Add a button to the buttons list. | |
39 | * @param x The X start position | |
40 | * @param y The Y start position | |
41 | * @param w The width of the button in pixels | |
42 | * @param h The height of the button in pixels. | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
43 | * @param txt The text to display on the button. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
44 | * If the txt is empty, no key will be shown. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
45 | * Use this for other areas that must act as a key. |
0 | 46 | * @param order The order number in the list. |
47 | */ | |
48 | void Buttons_Add(int x, int y, int w, int h, char *txt, int order); | |
49 | ||
50 | /** | |
51 | * @brief Draw all defined buttons in the list on the screen. | |
52 | */ | |
53 | void Buttons_Show(void); | |
54 | ||
55 | /** | |
56 | * @brief Search if the x and y coordinates belong to a button. | |
57 | * @param x The touched X position. | |
58 | * @param y The touched Y position. | |
59 | * @return The order number if a valid button, -1 is not valid. | |
60 | */ | |
61 | int Buttons_Search(int x, int y); | |
62 | ||
63 | /** | |
64 | * @brief Scan for the touch of a button. A touch is only valid after the | |
65 | * screen is left untouched. So a short or long press makes no difference. | |
66 | * @return The order number for a valid button, -1 if not valid. | |
67 | */ | |
68 | int Buttons_Scan(void); | |
69 | ||
70 | /** | |
71 | * @brief Scan keyboard, all characters, 4 screens. | |
72 | * @return The ASCII code of the key, or -1 if no key is pressed. | |
73 | */ | |
74 | int KeyBoardAll(void); | |
75 | ||
76 | /** | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
77 | * @brief Scan keyboard, just digits. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
78 | * @return The ASCII code of the key, or -1 if no key is pressed. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
79 | */ |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
80 | int KeyBoardDigits(void); |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
81 | |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
82 | /** |
0 | 83 | * @brief Show data text field. |
84 | * @param x The X position on the screen | |
85 | * @param y The Y position on the screen | |
86 | * @param label The field name text | |
87 | * @param txt The field text data | |
88 | */ | |
89 | void ShowText(uint16_t x, uint16_t y, char *label, char *txt); | |
90 | ||
91 | /** | |
92 | * @brief Show integer data field. | |
93 | * @param x The X position on the screen | |
94 | * @param y The Y position on the screen | |
95 | * @param label The field name text | |
96 | * @param suffix Some text after the data value or NULL | |
97 | * @param val The integer data value to show. | |
98 | */ | |
99 | void ShowInteger(uint16_t x, uint16_t y, char *label, char *suffix, int val); | |
100 | ||
101 | /** | |
102 | * @brief Show boolean data field. | |
103 | * @param x The X position on the screen | |
104 | * @param y The Y position on the screen | |
105 | * @param label The field name text | |
106 | * @param val The bolean value, displays 'J' or 'N' | |
107 | */ | |
108 | void ShowBool(uint16_t x, uint16_t y, char *label, bool val); | |
109 | ||
110 | /** | |
111 | * @brief Show SSR2 value. | |
112 | * @param x The X position on the screen | |
113 | * @param y The Y position on the screen | |
114 | * @param val The SSR2 value. | |
115 | */ | |
116 | void ShowSSR2(uint16_t x, uint16_t y, int val); | |
117 | ||
118 | /** | |
119 | * @brief Show float data field. | |
120 | * @param x The X position on the screen | |
121 | * @param y The Y position on the screen | |
122 | * @param label The field name text | |
123 | * @param suffix Some text after the data value or NULL | |
124 | * @param val The float data value to show. | |
125 | * @param decimals The number of decimals to show. | |
126 | */ | |
127 | void ShowFloat(uint16_t x, uint16_t y, char *label, char *suffix, float val, int decimals); | |
128 | ||
129 | /** | |
130 | @brief Show double data field. | |
131 | * @param x The X position on the screen | |
132 | * @param y The Y position on the screen | |
133 | * @param label The field name text | |
134 | * @param suffix Some text after the data value or NULL | |
135 | * @param val The float data value to show. | |
136 | * @param decimals The number of decimals to show. | |
137 | */ | |
138 | void ShowDouble(uint16_t x, uint16_t y, char *label, char *suffix, double val, int decimals); | |
139 | ||
140 | /** | |
141 | * @brief Edit data field. A complete new screen is used. | |
142 | * @param label The field name text | |
143 | * @param txt The field text data | |
144 | * @param errmsg The error message to show after an input error. | |
145 | * @param len The total length of the data field. | |
146 | * @param type The keyboard type to use. | |
147 | */ | |
148 | void Editer(char *label, char *txt, char *errmsg, int len, int type); | |
149 | ||
150 | /** | |
151 | * @brief Edit data field. A complete new screen is used. | |
152 | * @param label The field name text | |
153 | * @param txt The field text data | |
154 | * @param len The total length of the data field. | |
155 | */ | |
156 | void EditText(char *label, char *txt, int len); | |
157 | ||
158 | /** | |
159 | * @brief Edit data field. A complete new screen is used. | |
160 | * @param label The field name text | |
161 | * @param txt The field text data | |
162 | * @param len The total length of the data field. | |
163 | * @param min The minimum field length. | |
164 | */ | |
165 | void EditTextMin(char *label, char *txt, int len, int min); | |
166 | ||
167 | /** | |
168 | * @brief Edit integer field. A complete new screen is used. | |
169 | * @param label The field name text | |
170 | * @param val The field integer data | |
171 | * @param min The minimum value of the data. | |
172 | * @param max The maximum value of the data. | |
173 | */ | |
174 | void EditInt(char *label, int *val, int min, int max); | |
175 | ||
176 | /** | |
177 | * @brief Edit uint8_t field. A complete new screen is used. | |
178 | * @param label The field name text | |
179 | * @param val The field uint8_t data | |
180 | * @param min The minimum value of the data. | |
181 | * @param max The maximum value of the data. | |
182 | */ | |
183 | void EditUint8(char *label, uint8_t *val, uint8_t min, uint8_t max); | |
184 | ||
185 | /** | |
186 | * @brief Edit uint16_t field. A complete new screen is used. | |
187 | * @param label The field name text | |
188 | * @param val The field uint16_t data | |
189 | * @param min The minimum value of the data. | |
190 | * @param max The maximum value of the data. | |
191 | */ | |
192 | void EditUint16(char *label, uint16_t *val, uint16_t min, uint16_t max); | |
193 | ||
194 | /** | |
195 | * @brief Edit float field. A complete new screen is used. | |
196 | * @param label The field name text | |
197 | * @param val The field float data | |
198 | * @param min The minimum value of the data. | |
199 | * @param max The maximum value of the data. | |
200 | * @param decimals The number of decimals to show. | |
201 | */ | |
202 | void EditFloat(char *label, float *val, float min, float max, int decimals); | |
203 | ||
204 | /** | |
205 | * @brief Edit double field. A complete new screen is used. | |
206 | * @param label The field name text | |
207 | * @param val The field float data | |
208 | * @param min The minimum value of the data. | |
209 | * @param max The maximum value of the data. | |
210 | * @param decimals The number of decimals to show. | |
211 | */ | |
212 | void EditDouble(char *label, double *val, double min, double max, int decimals); | |
213 | ||
214 | /** | |
215 | * @brief Edit a boolean value | |
216 | * @param label The field name text | |
217 | * @param val The field integer data | |
218 | */ | |
219 | void EditBool(char *label, bool *val); | |
220 | ||
221 | /** | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
222 | * @brief Edit SSR2 value. |
0 | 223 | * @param val The SSR2 value. |
224 | */ | |
225 | void EditSSR2(int *val); | |
226 | ||
227 | /** | |
228 | * @brief Confirm or not choice. Uses the whole screen. | |
229 | * @param top The top screen message. | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
230 | * @param ack The text for the ack button. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
231 | * @param nak The text for the nack button. |
0 | 232 | * @return true when ack, or false. |
233 | */ | |
234 | int Confirm(char *top, char *ack, char *nak); | |
235 | ||
236 | #endif |