1 /* This is a small demo of the high-performance GUIX graphics framework. */
2
3 #include "demo_guix_industrial.h"
4
5 #define SEQUENCE_TIMER 10
6 #define SEQUENCE_TIMER_TICKS (40 / GX_SYSTEM_TIMER_MS)
7
8 #define LEFT_PROGRESS_BAR_INCREMENT 3
9
10 #define TASK_PROPERTY_ANIMATION_STEPS 10
11 #define TASK_ICON_ANIMATION_STEPS 8
12 #define TASK_TITLE_ANIMATION_STEPS 8
13 #define TASK_TITLE_ANIMATION_SHIFT 60
14 #define TASK_TITLE_ANIMATION_START_X 19
15
16 /* Define task IDs. */
17 enum task_ids {
18 TASK_ID_INSPECTING = 0,
19 TASK_ID_ASSEMBLING,
20 TASK_ID_WELDING,
21 TASK_ID_PALLETIZING,
22 TASK_COUNT
23 };
24
25 /* Define task information struture. */
26 typedef struct TASK_INFO_STRUCT {
27 INT task_id;
28 GX_PIXELMAP_BUTTON* task_button;
29 GX_RESOURCE_ID task_text_id;
30 GX_RESOURCE_ID task_icon_id;
31 GX_RESOURCE_ID progress_1_text_id;
32 GX_RESOURCE_ID progress_2_text_id;
33 GX_RESOURCE_ID progress_3_text_id;
34 GX_RESOURCE_ID progress_4_text_id;
35 }TASK_INFO;
36
37 /* Define progress information structure. */
38 typedef struct PROGRESS_INFO_STRUCT {
39 INT current_val;
40 GX_PROGRESS_BAR *progress_bar;
41 GX_NUMERIC_PROMPT *value_prompt;
42 GX_PROMPT *percent_flag_prompt;
43 GX_ICON *complete_icon;
44 }PROGRESS_INFO;
45
46 /* Define property information structure. */
47 typedef struct PROPERTY_INFO_STRUCT {
48 INT values[TASK_COUNT];
49 GX_WIDGET *widget;
50 }PROPERTY_INFO;
51
52 static int timer_minute;
53 static int timer_second;
54 static int timer_tick;
55
56 static int current_task_property_animation_step = TASK_PROPERTY_ANIMATION_STEPS;
57 static int current_task_title_animation_step = TASK_TITLE_ANIMATION_STEPS;
58 static int current_task_icon_animation_step = TASK_ICON_ANIMATION_STEPS;
59 static int current_task_id = TASK_ID_INSPECTING;
60
61 static int task_title_blend_alpha = 255;
62 extern USHORT toggle_animation_flag;
63
64 PROGRESS_INFO left_progress_info_list[] = {
65 {
66 0,
67 &sequence_window.sequence_window_progress_1,
68 &sequence_window.sequence_window_progress_1_value,
69 &sequence_window.sequence_window_progress_1_percent_flag,
70 &sequence_window.sequence_window_complete_icon_1
71 },
72 {
73 0,
74 &sequence_window.sequence_window_progress_2,
75 &sequence_window.sequence_window_progress_2_value,
76 &sequence_window.sequence_window_progress_2_percent_flag,
77 &sequence_window.sequence_window_complete_icon_2
78 },
79 {
80 0,
81 &sequence_window.sequence_window_progress_3,
82 &sequence_window.sequence_window_progress_3_value,
83 &sequence_window.sequence_window_progress_3_percent_flag,
84 &sequence_window.sequence_window_complete_icon_3
85 },
86 {
87 0,
88 &sequence_window.sequence_window_progress_4,
89 &sequence_window.sequence_window_progress_4_value,
90 &sequence_window.sequence_window_progress_4_percent_flag,
91 &sequence_window.sequence_window_complete_icon_4
92 }
93 };
94
95 TASK_INFO task_info_list[] =
96 {
97 {
98 TASK_ID_INSPECTING,
99 &main_screen.main_screen_button_inspecting,
100 GX_STRING_ID_INSPECTING,
101 GX_PIXELMAP_ID_CIRCLE_ICON_INSPECTING,
102 GX_STRING_ID_SURFACE,
103 GX_STRING_ID_COMPONENTS,
104 GX_STRING_ID_TRACING_PATTERN,
105 GX_STRING_ID_CIRCUIT_TEST
106 },
107 {
108 TASK_ID_ASSEMBLING,
109 &main_screen.main_screen_button_inspecting,
110 GX_STRING_ID_ASSEMBLING,
111 GX_PIXELMAP_ID_CIRCLE_ICON_ASSEMBLING,
112 GX_STRING_ID_ROTATE_AXIS,
113 GX_STRING_ID_DRIVE_PRESS,
114 GX_STRING_ID_FORCE_JOIN,
115 GX_STRING_ID_ASSEMBLING
116 },
117 {
118 TASK_ID_WELDING,
119 &main_screen.main_screen_button_welding,
120 GX_STRING_ID_WELDING,
121 GX_PIXELMAP_ID_CIRCLE_ICON_WELDING,
122 GX_STRING_ID_CURRENT_CHECK,
123 GX_STRING_ID_TARGET_CLAMPS,
124 GX_STRING_ID_BRAZING_FLUX,
125 GX_STRING_ID_GROUND_FLUSH
126 },
127 {
128 TASK_ID_PALLETIZING,
129 &main_screen.main_screen_button_palletizing,
130 GX_STRING_ID_PALLETIZING,
131 GX_PIXELMAP_ID_CIRCLE_ICON_PALLET,
132 GX_STRING_ID_LEVEL_SURFACE,
133 GX_STRING_ID_ARM_AUXILIARY,
134 GX_STRING_ID_PALLET_FRICTION,
135 GX_STRING_ID_UNITSET
136 }
137 };
138
139 PROPERTY_INFO property_prompt_value_list[] = {
140 {{ 75, 70, 79, 68 }, (GX_WIDGET*)&sequence_window.sequence_window_prompt_SX },
141 {{ 72, 69, 74, 63 }, (GX_WIDGET*)&sequence_window.sequence_window_prompt_SY },
142 {{ -1050, -1050, 9290, -1050 }, (GX_WIDGET*)&sequence_window.sequence_window_prompt_RX },
143 {{ 13650, 13650, 3870, 13650 }, (GX_WIDGET*)&sequence_window.sequence_window_prompt_RY },
144 {{ 112, 423, 1822, 205 }, (GX_WIDGET*)&sequence_window.sequence_window_prompt_UP },
145 {{ 8, 217, 1436, 129 }, (GX_WIDGET*)&sequence_window.sequence_window_prompt_DN },
146 {{ 814, 756, 903, 816 }, (GX_WIDGET*)&sequence_window.sequence_window_prompt_X },
147 {{ 734, 680, 588, 734}, (GX_WIDGET*)&sequence_window.sequence_window_prompt_Y },
148 {{ 387, 360, 373, 388 }, (GX_WIDGET*)&sequence_window.sequence_window_prompt_Z }
149 };
150
151 PROPERTY_INFO property_radial_progress_value_list[] ={
152 {{ -220, -270, -200, -250 }, (GX_WIDGET*)&sequence_window.sequence_window_radial_progress_speed },
153 {{ -160, -170, -150, -160 }, (GX_WIDGET*)&sequence_window.sequence_window_radial_progress_rotation },
154 {{ -90, -40, -50, -80 },(GX_WIDGET*)&sequence_window.sequence_window_radial_progress_force }
155 };
156
157 VOID sequence_window_init();
158 VOID task_set(int new_mode);
159 TASK_INFO* task_info_get(INT task_id);
160 VOID task_time_update();
161 VOID task_progress_information_init();
162 VOID task_progress_information_update();
163 VOID task_properties_init();
164 VOID task_properties_update();
165 VOID task_title_animation_init();
166 VOID task_title_animation_update();
167 VOID task_icon_animation_update();
168 UINT string_length_get(GX_CONST GX_CHAR* input_string, UINT max_string_length);
169
170 /******************************************************************************************/
171 /* Retrieve tasl information according to task id. */
172 /******************************************************************************************/
task_info_get(INT task_id)173 TASK_INFO *task_info_get(INT task_id)
174 {
175 if (task_id < sizeof(task_info_list) / sizeof(TASK_INFO))
176 {
177 return &task_info_list[task_id];
178 }
179
180 return GX_NULL;
181 }
182
183 /******************************************************************************************/
184 /* Override event processing of "sequence_window" to handle signals from my child widgets.*/
185 /******************************************************************************************/
sequence_window_event_process(GX_WINDOW * window,GX_EVENT * event_ptr)186 UINT sequence_window_event_process(GX_WINDOW *window, GX_EVENT *event_ptr)
187 {
188 switch (event_ptr->gx_event_type)
189 {
190 case GX_EVENT_TIMER:
191 if (event_ptr->gx_event_payload.gx_event_timer_id == SEQUENCE_TIMER)
192 {
193 sequence_animation_update();
194 }
195 break;
196
197 case GX_SIGNAL(ID_INSPECTING, GX_EVENT_CLICKED):
198 task_set(TASK_ID_INSPECTING);
199 break;
200
201 case GX_SIGNAL(ID_ASSEMBLING, GX_EVENT_CLICKED):
202 task_set(TASK_ID_ASSEMBLING);
203 break;
204
205 case GX_SIGNAL(ID_WELDING, GX_EVENT_CLICKED):
206 task_set(TASK_ID_WELDING);
207 break;
208
209 case GX_SIGNAL(ID_PALLETIZING, GX_EVENT_CLICKED):
210 task_set(TASK_ID_PALLETIZING);
211 break;
212
213 default:
214 return gx_window_event_process(window, event_ptr);
215 }
216
217 return 0;
218 }
219
220 /******************************************************************************************/
221 /* Override drawing of "task_icon" to draw the icon with specified blending alpha. */
222 /******************************************************************************************/
task_icon_draw(GX_ICON * icon)223 VOID task_icon_draw(GX_ICON *icon)
224 {
225 GX_BRUSH *brush;
226 GX_PIXELMAP *map;
227 GX_RECTANGLE *size;
228 INT angle;
229 TASK_INFO *tinfo;
230
231 if ((toggle_animation_flag == ANIMATION_NONE))
232 {
233 gx_context_brush_get(&brush);
234 brush->gx_brush_alpha = task_title_blend_alpha;
235 }
236
237 /* Call default icon draw. */
238 gx_icon_draw(icon);
239
240 tinfo = task_info_get(current_task_id);
241
242 if (!tinfo)
243 {
244 return;
245 }
246
247 /* Retrieve task icon pixelmap. */
248 gx_context_pixelmap_get(tinfo->task_icon_id, &map);
249 size = &icon->gx_widget_size;
250
251 if (current_task_icon_animation_step < TASK_ICON_ANIMATION_STEPS)
252 {
253 if (map)
254 {
255 angle = -90 * (current_task_icon_animation_step - TASK_ICON_ANIMATION_STEPS) / TASK_ICON_ANIMATION_STEPS;
256
257 /* Rotate task icon. */
258 gx_canvas_pixelmap_rotate(size->gx_rectangle_left, size->gx_rectangle_top, map, angle, -1, -1);
259 }
260 }
261 else
262 {
263 /* Draw task icon. */
264 gx_canvas_pixelmap_draw(size->gx_rectangle_left, size->gx_rectangle_top, map);
265 }
266 }
267
268 /******************************************************************************************/
269 /* Override drawing of "task_title" to draw the prompt with specified blending alpha. */
270 /******************************************************************************************/
task_title_draw(GX_PROMPT * prompt)271 VOID task_title_draw(GX_PROMPT *prompt)
272 {
273 GX_BRUSH *brush;
274
275 if ((toggle_animation_flag == ANIMATION_NONE))
276 {
277 gx_context_brush_get(&brush);
278 brush->gx_brush_alpha = task_title_blend_alpha;
279 }
280
281 gx_prompt_draw(prompt);
282 }
283
284 /******************************************************************************************/
285 /* Initiate widget values in sequence window. */
286 /******************************************************************************************/
sequence_window_init()287 VOID sequence_window_init()
288 {
289 timer_minute = 0;
290 timer_second = 0;
291 timer_tick = 0;
292
293 /* Init timer values. */
294 gx_numeric_prompt_value_set(&sequence_window.sequence_window_timer_minute, timer_minute);
295 gx_numeric_prompt_value_set(&sequence_window.sequence_window_timer_second, timer_second);
296 gx_numeric_prompt_value_set(&sequence_window.sequence_window_timer_tick, timer_tick);
297
298 gx_sprite_current_frame_set(&sequence_window.sequence_window_sprite, 0);
299
300 task_set(TASK_ID_INSPECTING);
301 }
302
303 /******************************************************************************************/
304 /* Start sequence animation. */
305 /******************************************************************************************/
sequence_animation_start()306 VOID sequence_animation_start()
307 {
308 /* Create a sequence timer. */
309 gx_system_timer_start(&sequence_window, SEQUENCE_TIMER, SEQUENCE_TIMER_TICKS, SEQUENCE_TIMER_TICKS);
310 gx_sprite_start(&sequence_window.sequence_window_sprite, 0);
311 }
312
313 /******************************************************************************************/
314 /* Process one step for sequence animation. */
315 /******************************************************************************************/
sequence_animation_update()316 VOID sequence_animation_update()
317 {
318 task_time_update();
319 task_title_animation_update();
320 task_icon_animation_update();
321 task_properties_update();
322 task_progress_information_update();
323 }
324
325 /******************************************************************************************/
326 /* Stop sequence animation. */
327 /******************************************************************************************/
sequence_animation_stop()328 VOID sequence_animation_stop()
329 {
330 gx_system_timer_stop(&sequence_window, SEQUENCE_TIMER);
331 gx_sprite_stop(&sequence_window.sequence_window_sprite);
332 }
333
334 /******************************************************************************************/
335 /* Set sequence mode. */
336 /******************************************************************************************/
task_set(int new_task_id)337 VOID task_set(int new_task_id)
338 {
339 TASK_INFO *tinfo;
340
341 if (new_task_id > TASK_ID_PALLETIZING)
342 {
343 screen_toggle_animation_start((GX_WINDOW*)&complete_window, (GX_WINDOW*)&sequence_window);
344 return;
345 }
346
347 current_task_id = new_task_id;
348
349 tinfo = task_info_get(new_task_id);
350
351 if (!tinfo)
352 {
353 return;
354 }
355
356 button_indicator_attach(tinfo->task_button);
357
358 /* Set title text. */
359 gx_prompt_text_id_set(&sequence_window.sequence_window_progress_1_title, tinfo->progress_1_text_id);
360 gx_prompt_text_id_set(&sequence_window.sequence_window_progress_2_title, tinfo->progress_2_text_id);
361 gx_prompt_text_id_set(&sequence_window.sequence_window_progress_3_title, tinfo->progress_3_text_id);
362 gx_prompt_text_id_set(&sequence_window.sequence_window_progress_4_title, tinfo->progress_4_text_id);
363 gx_prompt_text_id_set(&sequence_window.sequence_window_task_title, tinfo->task_text_id);
364
365 task_progress_information_init();
366 task_properties_init();
367 task_title_animation_init();
368 }
369
370 /******************************************************************************************/
371 /* Update task time. */
372 /******************************************************************************************/
task_time_update()373 VOID task_time_update()
374 {
375 int ms;
376
377 if (timer_tick < GX_TICKS_SECOND)
378 {
379 timer_tick += SEQUENCE_TIMER_TICKS;
380
381 ms = timer_tick * GX_SYSTEM_TIMER_MS / 10;
382
383 gx_numeric_prompt_value_set(&sequence_window.sequence_window_timer_tick, ms);
384 }
385 else if (timer_second < 59)
386 {
387 timer_tick = 0;
388 timer_second++;
389
390 gx_numeric_prompt_value_set(&sequence_window.sequence_window_timer_tick, timer_tick);
391 gx_numeric_prompt_value_set(&sequence_window.sequence_window_timer_second, timer_second);
392 }
393 else if (timer_minute < 59)
394 {
395 timer_second = 0;
396 timer_minute++;
397
398 gx_numeric_prompt_value_set(&sequence_window.sequence_window_timer_second, timer_tick);
399 gx_numeric_prompt_value_set(&sequence_window.sequence_window_timer_minute, timer_second);
400 }
401 else
402 {
403 timer_minute = 0;
404
405 gx_numeric_prompt_value_set(&sequence_window.sequence_window_timer_minute, timer_second);
406 }
407 }
408
409 /******************************************************************************************/
410 /* Initialize progress information in left and bottom. */
411 /******************************************************************************************/
task_progress_information_init()412 VOID task_progress_information_init()
413 {
414 PROGRESS_INFO *pinfo;
415 INT stage;
416
417 for (stage = 0; stage < sizeof(left_progress_info_list) / sizeof(PROGRESS_INFO); stage++)
418 {
419 pinfo = &left_progress_info_list[stage];
420
421 pinfo->current_val = 0;
422
423 /* Init progress bar value. */
424 gx_progress_bar_value_set(pinfo->progress_bar, 0);
425
426 /* Init progress value prompt value. */
427 gx_numeric_prompt_value_set(pinfo->value_prompt, 0);
428
429 /* Show progress value prompt. */
430 gx_widget_show(pinfo->value_prompt);
431
432 /* Show percentage flag. */
433 gx_widget_show(pinfo->percent_flag_prompt);
434
435 /* Hide progress complete icon. */
436 gx_widget_hide(pinfo->complete_icon);
437 }
438
439 /* Init bottom progress bar values. */
440 gx_progress_bar_value_set(&sequence_window.sequence_window_bottom_progress, 0);
441 gx_numeric_prompt_value_set(&sequence_window.sequence_window_bottom_progress_value, 0);
442 }
443
444 /******************************************************************************************/
445 /* Update progress information in left and bottom. */
446 /******************************************************************************************/
task_progress_information_update()447 VOID task_progress_information_update()
448 {
449 INT progress_val = 0;
450 PROGRESS_INFO *pinfo;
451 TASK_INFO *tinfo = task_info_get(current_task_id);
452 INT stage;
453 INT total_stage = sizeof(left_progress_info_list) / sizeof(PROGRESS_INFO);
454
455 if (!tinfo)
456 {
457 return;
458 }
459
460 for (stage = 0; stage < total_stage; stage++)
461 {
462 /* Update progress information when stage is 0 or previous stage is 25% completed. */
463 if (stage == 0 || (left_progress_info_list[stage - 1].current_val >= 25))
464 {
465 pinfo = &left_progress_info_list[stage];
466
467 if (pinfo->current_val < 100)
468 {
469 pinfo->current_val += LEFT_PROGRESS_BAR_INCREMENT;
470
471 /* Update progress bar value. */
472 gx_progress_bar_value_set(pinfo->progress_bar, pinfo->current_val);
473 gx_numeric_prompt_value_set(pinfo->value_prompt, pinfo->current_val);
474
475 if (pinfo->current_val >= 100)
476 {
477 gx_widget_hide(pinfo->value_prompt);
478 gx_widget_hide(pinfo->percent_flag_prompt);
479 gx_widget_show(pinfo->complete_icon);
480 }
481 }
482 }
483 }
484
485 progress_val = (tinfo->task_id * 100 / TASK_COUNT);
486
487 if (left_progress_info_list[total_stage - 1].current_val)
488 {
489 progress_val += (75 + left_progress_info_list[total_stage - 1].current_val) * 25 / 175;
490 }
491 else
492 {
493 progress_val += (left_progress_info_list[0].current_val) * 25 / 175;
494 }
495
496 /* Start next task when last stage completed. */
497 if (left_progress_info_list[total_stage - 1].current_val >= 100)
498 {
499 task_set(current_task_id + 1);
500 }
501
502 /* Update bottom progress information. */
503 gx_progress_bar_value_set(&sequence_window.sequence_window_bottom_progress, progress_val);
504 gx_numeric_prompt_value_set(&sequence_window.sequence_window_bottom_progress_value, progress_val);
505 }
506
507 /******************************************************************************************/
508 /* Initialize task title animation. */
509 /******************************************************************************************/
task_title_animation_init()510 VOID task_title_animation_init()
511 {
512 GX_RECTANGLE *size;
513 INT shift;
514
515 current_task_title_animation_step = 0;
516 task_title_blend_alpha = 255;
517
518 size = &sequence_window.sequence_window_task_title.gx_widget_size;
519
520 if (size->gx_rectangle_left != TASK_TITLE_ANIMATION_START_X)
521 {
522 shift = TASK_TITLE_ANIMATION_START_X - size->gx_rectangle_left;
523 gx_widget_shift((GX_WIDGET*)&sequence_window.sequence_window_task_title, shift, 0, GX_TRUE);
524 gx_widget_shift((GX_WIDGET*)&sequence_window.sequence_window_task_icon, shift, 0, GX_TRUE);
525 }
526 }
527
528 /******************************************************************************************/
529 /* Udpate task title animation. */
530 /******************************************************************************************/
task_title_animation_update()531 VOID task_title_animation_update()
532 {
533 INT shift;
534
535 if (current_task_title_animation_step < TASK_TITLE_ANIMATION_STEPS)
536 {
537 current_task_title_animation_step++;
538 if (current_task_title_animation_step <= TASK_TITLE_ANIMATION_STEPS / 2)
539 {
540 shift = TASK_TITLE_ANIMATION_SHIFT;
541 task_title_blend_alpha -= 50;
542 }
543 else
544 {
545 shift = -TASK_TITLE_ANIMATION_SHIFT;
546 task_title_blend_alpha += 50;
547 }
548
549 gx_widget_shift((GX_WIDGET *)&sequence_window.sequence_window_task_title, shift, 0, GX_TRUE);
550 gx_widget_shift((GX_WIDGET *)&sequence_window.sequence_window_task_icon, shift, 0, GX_TRUE);
551
552 if (current_task_title_animation_step == TASK_TITLE_ANIMATION_STEPS)
553 {
554 /* Start mode icon animation. */
555 current_task_icon_animation_step = 0;
556 }
557 }
558 }
559
560 /******************************************************************************************/
561 /* Update mode icon animation. */
562 /******************************************************************************************/
task_icon_animation_update()563 VOID task_icon_animation_update()
564 {
565 if (current_task_icon_animation_step < TASK_ICON_ANIMATION_STEPS)
566 {
567 current_task_icon_animation_step++;
568
569 gx_system_dirty_mark(&sequence_window.sequence_window_task_icon);
570 }
571 }
572
573 /******************************************************************************************/
574 /* Initialize task perperty values. */
575 /******************************************************************************************/
task_properties_init()576 VOID task_properties_init()
577 {
578 INT index;
579 PROPERTY_INFO *pinfo;
580
581 for (index = 0; index < sizeof(property_prompt_value_list) / sizeof(PROPERTY_INFO); index++)
582 {
583 pinfo = &property_prompt_value_list[index];
584
585 gx_numeric_prompt_value_set((GX_NUMERIC_PROMPT *)pinfo->widget, pinfo->values[0]);
586 }
587
588 for (index = 0; index < sizeof(property_radial_progress_value_list) / sizeof(PROPERTY_INFO); index++)
589 {
590 pinfo = &property_radial_progress_value_list[index];
591
592 gx_radial_progress_bar_value_set((GX_RADIAL_PROGRESS_BAR *)pinfo->widget, 0);
593 }
594
595 current_task_property_animation_step = 0;
596 }
597
598 /******************************************************************************************/
599 /* Update task property values. */
600 /******************************************************************************************/
task_properties_update()601 VOID task_properties_update()
602 {
603 INT start_val;
604 INT target_val;
605 INT value;
606 INT index;
607 PROPERTY_INFO *pinfo;
608
609 if (current_task_property_animation_step < TASK_PROPERTY_ANIMATION_STEPS)
610 {
611 current_task_property_animation_step++;
612
613 for (index = 0; index < sizeof(property_prompt_value_list) / sizeof(PROPERTY_INFO); index++)
614 {
615 pinfo = &property_prompt_value_list[index];
616
617 target_val = pinfo->values[current_task_id];
618
619 if (current_task_id == 0)
620 {
621 start_val = pinfo->values[TASK_COUNT - 1];
622 }
623 else
624 {
625 start_val = pinfo->values[current_task_id - 1];
626 }
627
628 value = start_val + (target_val - start_val) * current_task_property_animation_step / TASK_PROPERTY_ANIMATION_STEPS;
629
630 gx_numeric_prompt_value_set((GX_NUMERIC_PROMPT*)pinfo->widget, value);
631 }
632
633 for (index = 0; index < sizeof(property_radial_progress_value_list) / sizeof(PROPERTY_INFO); index++)
634 {
635 pinfo = &property_radial_progress_value_list[index];
636
637 target_val = pinfo->values[current_task_id];
638
639
640 value = target_val * current_task_property_animation_step / TASK_PROPERTY_ANIMATION_STEPS;
641
642 gx_radial_progress_bar_value_set((GX_RADIAL_PROGRESS_BAR*)pinfo->widget, value);
643 }
644 }
645 }
646
647 /******************************************************************************************/
648 /* Define a value format function for timer prompts. */
649 /******************************************************************************************/
timer_value_format(GX_NUMERIC_PROMPT * prompt,INT value)650 VOID timer_value_format(GX_NUMERIC_PROMPT *prompt, INT value)
651 {
652 gx_utility_ltoa(value, prompt->gx_numeric_prompt_buffer, GX_NUMERIC_PROMPT_BUFFER_SIZE);
653
654 if (value < 10)
655 {
656 prompt->gx_numeric_prompt_buffer[1] = prompt->gx_numeric_prompt_buffer[0];
657 prompt->gx_numeric_prompt_buffer[0] = '0';
658 prompt->gx_numeric_prompt_buffer[2] = '\0';
659 }
660 }
661
662 /******************************************************************************************/
663 /* Define a value format function for value prompts in mode windows. */
664 /******************************************************************************************/
mode_value_format(GX_NUMERIC_PROMPT * prompt,INT value)665 VOID mode_value_format(GX_NUMERIC_PROMPT *prompt, INT value)
666 {
667 INT index;
668
669 gx_utility_ltoa(value / 100, prompt->gx_numeric_prompt_buffer, GX_NUMERIC_PROMPT_BUFFER_SIZE);
670 index = string_length_get(prompt->gx_numeric_prompt_buffer, GX_NUMERIC_PROMPT_BUFFER_SIZE - 1);
671 prompt->gx_numeric_prompt_buffer[index++] = '.';
672
673 if (value < 0)
674 {
675 value *= -1;
676 }
677
678 gx_utility_ltoa(value % 100, prompt->gx_numeric_prompt_buffer + index, GX_NUMERIC_PROMPT_BUFFER_SIZE - index);
679 }
680
681 /******************************************************************************************/
682 /* Define a value format function for position value prompts. */
683 /******************************************************************************************/
position_value_format(GX_NUMERIC_PROMPT * prompt,INT value)684 VOID position_value_format(GX_NUMERIC_PROMPT *prompt, INT value)
685 {
686 INT index;
687
688 gx_utility_ltoa(value / 10, prompt->gx_numeric_prompt_buffer, GX_NUMERIC_PROMPT_BUFFER_SIZE);
689 index = string_length_get(prompt->gx_numeric_prompt_buffer, GX_NUMERIC_PROMPT_BUFFER_SIZE);
690 prompt->gx_numeric_prompt_buffer[index++] = '.';
691 gx_utility_ltoa(value % 10, prompt->gx_numeric_prompt_buffer + index, GX_NUMERIC_PROMPT_BUFFER_SIZE - index);
692 }
693