main/buttons.h

changeset 0
b74b0e4902c3
child 1
ad2c8b13eb88
equal deleted inserted replaced
-1:000000000000 0:b74b0e4902c3
1 /**
2 * @file buttons.h
3 * @brief The touch buttons.
4 */
5
6 #ifndef _BUTTONS_H
7 #define _BUTTONS_H
8
9 #define MAXBUTTONS 40
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.
43 * @param text The text to display on the button.
44 * If the text is empty, no key will be shown.
45 * Use this for other areas that must act as a key.
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 /**
77 * @brief Show data text field.
78 * @param x The X position on the screen
79 * @param y The Y position on the screen
80 * @param label The field name text
81 * @param txt The field text data
82 */
83 void ShowText(uint16_t x, uint16_t y, char *label, char *txt);
84
85 /**
86 * @brief Show integer data field.
87 * @param x The X position on the screen
88 * @param y The Y position on the screen
89 * @param label The field name text
90 * @param suffix Some text after the data value or NULL
91 * @param val The integer data value to show.
92 */
93 void ShowInteger(uint16_t x, uint16_t y, char *label, char *suffix, int val);
94
95 /**
96 * @brief Show boolean data field.
97 * @param x The X position on the screen
98 * @param y The Y position on the screen
99 * @param label The field name text
100 * @param val The bolean value, displays 'J' or 'N'
101 */
102 void ShowBool(uint16_t x, uint16_t y, char *label, bool val);
103
104 /**
105 * @brief Show SSR2 value.
106 * @param x The X position on the screen
107 * @param y The Y position on the screen
108 * @param val The SSR2 value.
109 */
110 void ShowSSR2(uint16_t x, uint16_t y, int val);
111
112 /**
113 * @brief Show float data field.
114 * @param x The X position on the screen
115 * @param y The Y position on the screen
116 * @param label The field name text
117 * @param suffix Some text after the data value or NULL
118 * @param val The float data value to show.
119 * @param decimals The number of decimals to show.
120 */
121 void ShowFloat(uint16_t x, uint16_t y, char *label, char *suffix, float val, int decimals);
122
123 /**
124 @brief Show double data field.
125 * @param x The X position on the screen
126 * @param y The Y position on the screen
127 * @param label The field name text
128 * @param suffix Some text after the data value or NULL
129 * @param val The float data value to show.
130 * @param decimals The number of decimals to show.
131 */
132 void ShowDouble(uint16_t x, uint16_t y, char *label, char *suffix, double val, int decimals);
133
134 /**
135 * @brief Edit data field. A complete new screen is used.
136 * @param label The field name text
137 * @param txt The field text data
138 * @param errmsg The error message to show after an input error.
139 * @param len The total length of the data field.
140 * @param type The keyboard type to use.
141 */
142 void Editer(char *label, char *txt, char *errmsg, int len, int type);
143
144 /**
145 * @brief Edit data field. A complete new screen is used.
146 * @param label The field name text
147 * @param txt The field text data
148 * @param len The total length of the data field.
149 */
150 void EditText(char *label, char *txt, int len);
151
152 /**
153 * @brief Edit data field. A complete new screen is used.
154 * @param label The field name text
155 * @param txt The field text data
156 * @param len The total length of the data field.
157 * @param min The minimum field length.
158 */
159 void EditTextMin(char *label, char *txt, int len, int min);
160
161 /**
162 * @brief Edit integer field. A complete new screen is used.
163 * @param label The field name text
164 * @param val The field integer data
165 * @param min The minimum value of the data.
166 * @param max The maximum value of the data.
167 */
168 void EditInt(char *label, int *val, int min, int max);
169
170 /**
171 * @brief Edit uint8_t field. A complete new screen is used.
172 * @param label The field name text
173 * @param val The field uint8_t data
174 * @param min The minimum value of the data.
175 * @param max The maximum value of the data.
176 */
177 void EditUint8(char *label, uint8_t *val, uint8_t min, uint8_t max);
178
179 /**
180 * @brief Edit uint16_t field. A complete new screen is used.
181 * @param label The field name text
182 * @param val The field uint16_t data
183 * @param min The minimum value of the data.
184 * @param max The maximum value of the data.
185 */
186 void EditUint16(char *label, uint16_t *val, uint16_t min, uint16_t max);
187
188 /**
189 * @brief Edit float field. A complete new screen is used.
190 * @param label The field name text
191 * @param val The field float data
192 * @param min The minimum value of the data.
193 * @param max The maximum value of the data.
194 * @param decimals The number of decimals to show.
195 */
196 void EditFloat(char *label, float *val, float min, float max, int decimals);
197
198 /**
199 * @brief Edit double field. A complete new screen is used.
200 * @param label The field name text
201 * @param val The field float data
202 * @param min The minimum value of the data.
203 * @param max The maximum value of the data.
204 * @param decimals The number of decimals to show.
205 */
206 void EditDouble(char *label, double *val, double min, double max, int decimals);
207
208 /**
209 * @brief Edit a boolean value
210 * @param label The field name text
211 * @param val The field integer data
212 */
213 void EditBool(char *label, bool *val);
214
215 /**
216 * @bried Edit SSR2 value.
217 * @param val The SSR2 value.
218 */
219 void EditSSR2(int *val);
220
221 /**
222 * @brief Confirm or not choice. Uses the whole screen.
223 * @param top The top screen message.
224 * #param yes The text for the ack button.
225 * @param no The text for the nack button.
226 * @return true when ack, or false.
227 */
228 int Confirm(char *top, char *ack, char *nak);
229
230 #endif

mercurial