versadac  1
versadac - Scalable Recorder Firmware
ui_private.h
1 #ifndef UI_PRIVATE_H
2 #define UI_PRIVATE_H
3 
4 
5 #define AMPIRE_TFT
6 
7 #include "stdtypes.h"
8 #include "template.h"
9 #include "ui_interface.h"
10 
11 #ifndef WIN32
12 #include "uhh_nav_functions.h"
13 #include "ENUM_UhhMsg_Err.h"
14 #endif
15 
16 /* Display definitions */
17 #define DISPLAY_WIDTH 320
18 #define DISPLAY_HEIGHT 240
19 
20 // Maximum number of trended points on the operator pages (upto 6 bar-graphs, upto 6 trends, etc..)
21 #define MAX_TRENDED_POINTS 6
22 
23 
24 #define UI_CMD_BUFF_SIZE 20 // Max amount of commands stored in buffer
25 
26 
27 #define DARKER_BY(rgb16, fraction) RGB24TORGB16( \
28  ((uint8)((((RGB16TORGB24(rgb16)) >> 16) & 0xFF) * (1.0 - (fraction))) << 16) + \
29  ((uint8)((((RGB16TORGB24(rgb16)) >> 8) & 0xFF) * (1.0 - (fraction))) << 8) + \
30  ((uint8)((((RGB16TORGB24(rgb16)) >> 0) & 0xFF) * (1.0 - (fraction))) << 0) \
31  )
32 
33 
34 
35 /* Extern references */
36 extern char line[256];
37 
38 #ifdef WIN32
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 extern unsigned short frame_buffer[DISPLAY_WIDTH][DISPLAY_HEIGHT];
44 extern unsigned short shadow_frame_buffer[DISPLAY_WIDTH][DISPLAY_HEIGHT];
45 
46 #ifdef __cplusplus
47 }
48 #endif
49 #endif
50 
51 
52 typedef struct {
53  int16 x1;
54  int16 y1;
55  int16 x2;
56  int16 y2;
57 } coord_t;
58 
59 
60 /* Internal data used by the descriptor drawing code */
61 typedef struct
62 {
63  bool available;
64  uint8 trend_point;
65  uint8 max_resolution; // Define the maximum number of decimal places to display the PV
66  uint16 pen_x;
67  color_t color;
68  unicode_p name;
69  unicode_p units;
70  f32_status_t pv;
71  coord_t rect;
72 
73  // Flags for enabling/disabling features for the faceplate
74  struct
75  {
76  uint8 default_position : 1; // When TRUE, renders the faceplate in the default location (otherwise use coordinates provided)
77  uint8 pen_background : 1; // Renders the background of pen bar
78  uint8 pen : 1; // Renders the pen bitmap (at the pen_x location)
79  uint8 pen_up_arrow : 1; // If set, draws the pen as an up arrow, otherwise uses a down arrow
80  } enable;
81 } descriptor_t;
82 extern descriptor_t descriptor;
83 
84 
85 
86 /* Frame buffer(s) */
87 typedef struct
88 {
89  unsigned short pixel[DISPLAY_HEIGHT][DISPLAY_WIDTH];
90 } frame_t;
91 
92 extern frame_t * g_frame_buffer_p;
93 
94 
95 extern CISP_t g_cisp;
96 extern union_t g_value;
97 
98 extern void put_pixel_bounds_check(uint16 x, uint16 y, uint16 colour);
99 
100 #define PUT_PIXEL(x,y,c) put_pixel_bounds_check((x),(y),(c))
101 
102 #ifdef WIN32
103 
104 #define PUT_PIXEL_NO_BOUNDS_CHECK(x,y,c) shadow_frame_buffer[(x)][(y)] = c;
105 #define GET_PIXEL(x,y) shadow_frame_buffer[(x)][(y)]
106 
107 #elif defined (AMPIRE_TFT)
108 
109 #define PUT_PIXEL_NO_BOUNDS_CHECK(x,y,c) g_frame_buffer_p->pixel[y][x] = c;
110 #define GET_PIXEL(x,y) g_frame_buffer_p->pixel[(y)][(x)]
111 
112 #else /* Hitachi TFT */
113 
114 #define GET_PIXEL(x,y) g_frame_buffer_p->pixel[319-(x)][(y)]
115 
116 #endif
117 
118 /* Define the return status from the previous paradigm */
119 typedef enum
120 {
121  // Operator views
122  UI_UNDEFINED_STATUS,
123  UI_VK_CANCEL, // User canceled out of the VK with no changes
124  UI_VK_OK, // User selected ok but with no changes to string contents
125  UI_VK_MODIFIED, // User selected ok with modified string contents
126  UI_CONFIRMATION_YES,
127  UI_CONFIRMATION_NO
128 
129 } status_t;
130 
131 
132 /* Define the update flags - prioritised from lowest to highest */
133 typedef enum
134 {
135  NO_UPDATE,
136  REFRESH_LIVE_DATA,
137  REFRESH_MENU_SELECTION,
138  REFRESH_ALL, // Refresh the active area for the current display paradigm
139  INITIALISE_PARADIGM // Initialises the paradigm including navigation variables - also performs a REFRESH_ALL
140 } update_flags_t;
141 
142 
143 /* Define the display paradigms */
144 typedef enum
145 {
146  // Operator views
147  OPERATOR_VERTICAL_BARGRAPH,
148  OPERATOR_HORIZONTAL_BARGRAPH,
149  OPERATOR_VERTICAL_TREND,
150  OPERATOR_HORIZONTAL_TREND,
151  OPERATOR_NUMERIC,
152  OPERATOR_CONTROL_LOOP1,
153  OPERATOR_CONTROL_LOOP2,
154  OPERATOR_CONTROL_DUAL_LOOP,
155  OPERATOR_PROGRAM_SUMMARY,
156  OPERATOR_ALARM_SUMMARY,
157  OPERATOR_MESSAGE_SUMMARY,
158  OPERATOR_NOTES,
159  OPERATOR_ARCHIVING,
160  OPERATOR_HORIZONTAL_HISTORY,
161  OPERATOR_VERTICAL_HISTORY,
162  OPERATOR_INST_ALARMS,
163  OPERATOR_USER_SCREEN,
164  OPERATOR_ALARM_PANEL,
165  OPERATOR_STERILISER,
166  OPERATOR_MODBUS_MASTER_USER_PAGE,
167  OPERATOR_ETHERNETIP_USER_PAGE,
168  OPERATOR_SATURATED_STEAM,
169  OPERATOR_MASS_FLOW,
170 
171  // Configuration views
172  CONFIGURATION_LIST,
173  INSTANCES_LIST,
174  SUBCLASS_LIST,
175  PARAMETER_LIST,
176  VIRTUAL_KEYBOARD,
177  VIRTUAL_NUMERIC_KEYBOARD,
178  VIRTUAL_KEYBOARD_POPUP,
179 
180  // Others
181  INSTRUMENT_MENU,
182  GOTO_VIEW_MENU,
183  HISTORY_MENU,
184  MESSAGE_SUMMARY_MENU,
185  OPERATOR_NOTES_MENU,
186  LOGIN_DIALOG,
187  PALETTE_POPUP,
188  USER_WIRING,
189  USER_WIRING_EXPLORER_VIEW,
190  DIALOG_POPUP,
191  BARREL_POPUP,
192  FILE_EXPLORER
193 
194 } paradigm_t;
195 
196 
197 /* Define menu list attributes */
198 typedef struct
199 {
200  uint8 order;
201  CISP_t cisp;
202 } clist_t;
203 
204 
205 /* Define the colour attributes for the various components that make up the user interface */
206 typedef struct
207 {
208  color_t status_bar_background_from;
209  color_t status_bar_background_to;
210  color_t status_bar_text_foreground;
211 
212  color_t system_background_from;
213  color_t system_background_to;
214 
215  color_t menu_item_background_from;
216  color_t menu_item_background_to;
217  color_t menu_item_background_selected_from;
218  color_t menu_item_background_selected_to;
219  color_t menu_item_text_foreground;
220  color_t border;
222 
223 /* Define the various status of parameter edit */
224 typedef enum
225 {
226  PEDIT_NOT_EDITING,
227  PEDIT_EDIT_MODE,
228  PEDIT_EDITING
229 } parameter_edit_t;
230 
231 #ifdef __cplusplus
232 extern "C" {
233 #endif
234 
235 typedef struct
236 {
237  double home_page_timeout;
238  double summary_timeout;
239 
240  uint16 timer_500ms; // 500ms key repeat rate timer
241  uint16 timer_200ms; // 200ms key repeat rate timer
242  uint16 timer_2s; // 2 second key timer
243  uint16 timer_3s; // 3 second key timer
244  uint8 key_repeat; // A bitfield describing how long the current key combination has been held for
245  uint8 keys; // A bitfield describing which keys are held down
246 
247  // These arrays hold a FIFO buffer of commands and their related subsets.
248  // When a command is interpreted, it is added to the buffer (together with its subset)
249  // at the position indexed by g_cmd_buff_in. When a command is to be processed, it is
250  // removed from the buffer at the position indicated by g_cmd_buff_out. Command subsets
251  // contain extra information about a command, such as which timer has expired or how long
252  // a key has been held down.
253  uint8 cmd_buff [UI_CMD_BUFF_SIZE];
254  uint8 cmd_subset [UI_CMD_BUFF_SIZE];
255  uint8 cmd_buff_in;
256  uint8 cmd_buff_out;
257  uint8 cmd_last;
258 
259  update_flags_t update;
260  update_flags_t next_update;
261  update_flags_t feature_security_update;
262 
263  paradigm_t paradigm;
264  paradigm_t previous_paradigm;
265  paradigm_t last_paradigm;
266 
267  // Configuration paradigm (this information is built up while navigating through Class,Instance,Subclass menus
268  struct
269  {
270  uint8 c;
271  uint8 i;
272  uint8 s;
273  } cisp;
274 
275  // Parameter list paradigm data
276  parameter_edit_t pmenu_edit;
277  uint8 pmenu_binary_cursor_position;
278 
279  // used by the user screen page
280  parameter_edit_t umenu_edit;
281 
282 
283  // Faceplate cycling timer
284  double faceplate_ticks;
285 
286 
287  // Flag that denotes which history page to show (vertical or horizontal)
288  bool vertical_history;
289 
290 
291  // Set when the display paradigm want to ignore scroll_delayed_cmd and scroll_release_cmd
292  // Gives a way of forcing the user to release thew scroll before pressing again
293  bool prohibit_scroll_commands;
294 
295 
296  // a return status passed back from the current to the previous paradigm
297  status_t rtn;
298 
299  color_attributes_t color;
300 
301  // Attributes that are common across operator views
302  struct
303  {
304  // Keep a record of how many points are configured to appear on the trend displays
305  // If the value changes, force a re-initialisation
306  uint8 number_trends;
307 
308  // Sequential list of configured trend points (unconfigured trend points do not appear in this array)
309  uint8 sequential_trend_point[MAX_TRENDED_POINTS];
310 
311  // Zero based, index into the trend point parameters
312  uint8 active_trend_point;
313 
314  // Keep track of whether the horizontal bargraph is showing descriptor text or PV
315  bool horizontal_bar_show_pv;
316  } operator_view;
317 
318 
319  // Allow PLATE to invoke a number of display tests
320  struct
321  {
322  bool display_test;
323  uint8 display_mode;
324  uint8 timeout;
325  } plate;
326 
327 
328  //
329  // Global data to allow passcodes to be encrypted/decrytped.
330  // Saves on using local stack storage within a function.
331  // Maximum size is defined as the maximum length of any (password string * 2) + 8 + null
332  // The FTP/Network passcodes are the longest at 40 characters plus a null-terminator
333  //
334  unicode_c passcode[89];
335 
336 
337  //
338  // Flag to allow key auto-repeat but only after pressing a key for the first time
339  //
340  bool auto_repeat;
341 
342  //
343  // For the class help - keep track of what to display.
344  // This allows for scrolling the class menu help text.
345  //
346  bool help_more;
347  uint8 help_row;
348 
349 } ui_t;
350 
351 extern ui_t ui;
352 extern bool g_flash;
353 
354 #ifdef __cplusplus
355 }
356 #endif
357 
358 typedef struct
359 {
360  float32 scale_low;
361  float32 scale_high;
362  f32_status_t pv;
363  unicode_p desciptor;
364  CI_t ci; // Class and Instance of alarm
365  uint8 max_resolution;
366  color_t color;
367 
368  float32 alm_sp;
369  uint8 alm_inst;
370  uint8 alm_type;
371  uint8 alm_status;
372 
374 
375 
376 /* Define the masks for the keys */
377 #define RAISE_KEY 0x08
378 #define LOWER_KEY 0x04
379 #define SCROLL_KEY 0x02
380 #define PAGE_KEY 0x01
381 
382 
383 /* Define the command identifiers */
384 #define NO_CMD 0
385 #define RAISE_CMD 1
386 #define LOWER_CMD 2
387 #define SCROLL_CMD 3
388 #define PAGE_CMD 4
389 #define SCROLL_RAISE_CMD 5
390 #define SCROLL_BACK_CMD 6
391 #define SCROLL_DELAYED_CMD 7
392 #define SCROLL_RELEASED_CMD 8
393 #define RAISE_LOWER_CMD 9
394 #define RAISE_RELEASED_CMD 10
395 #define LOWER_RELEASED_CMD 11
396 #define PAGE_RELEASED_CMD 12
397 #define PAGE_RAISE_CMD 13
398 #define PAGE_LOWER_CMD 14
399 
400 
401 /* Key repeat rates */
402 #define REPEAT_FIRST BIT0
403 #define REPEAT_500MS BIT1
404 #define REPEAT_200MS BIT2
405 #define REPEAT_2S BIT3
406 #define REPEAT_3S BIT4
407 
408 
409 /* Common times */
410 #define HUNDRED_MILLISECONDS 100L /* number of milliseconds in */
411 #define ONE_SECOND 1000L /* number of milliseconds in */
412 #define ONE_MINUTE 60000L /* number of milliseconds in */
413 #define ONE_HOUR 3600000L /* number of milliseconds in */
414 #define SIXTY_MINUTES (ONE_MINUTE * 60) /* number of milliseconds in */
415 #define HUNDRED_MINUTES (ONE_MINUTE * 100) /* number of milliseconds in */
416 #define HUNDRED_HOURS (ONE_HOUR * 100) /* number of milliseconds in */
417 #define MAX_DISPLAY_HOURS (ONE_HOUR * 500) /* number of milliseconds in */
418 
419 
420 #ifdef __cplusplus
421 extern "C" {
422 #endif
423 
424 /* Function prototypes */
425 bool ui_get_cmd_buffer (uint8 * z_cmd_p, uint8 * z_cmd_subset_p);
426 void ui_add_cmd_buffer (uint8 z_command, uint8 z_command_subset);
427 void ui_reset_cmd_buffer (void);
428 bool ui_process_generic_command (uint8 z_command, uint8 z_command_subset);
429 void ui_goto_next_operator_view (void);
430 void ui_goto_previous_operator_view (void);
431 void ui_operator_view_no_trends (DictRef_t z_title);
432 void uw_cisp_to_text (CISP_t param_cisp, unicode_p uc_src);
433 
434 #ifdef WIN32
435 void ui_command_interpreter (uint16 z_period);
436 #endif
437 
438 #ifdef __cplusplus
439 }
440 #endif
441 
442 
443 #endif /* UI_INTERFACE_H */
Definition: ui_private.h:235
Definition: stdtypes.h:134
Definition: stdtypes.h:116
Definition: ui_private.h:52
Definition: ui_private.h:358
Definition: ui_private.h:206
Definition: ui_private.h:87
Definition: ui_private.h:61
Definition: ui_private.h:198