CircleOS  1
menu.c
Go to the documentation of this file.
1 /****************** COPYRIGHT (C) 2007-2013 KEOLABS S.A.S. ********************/
15 /******************************************************************************/
16 
17 /* Includes ------------------------------------------------------------------*/
18 #include "circle.h"
19 
21 
22 /* Public function prototypes ------------------------------------------------*/
23 
24 /* Private define ------------------------------------------------------------*/
25 #define MENU_DIVIDER 10 // Used for non touchscreen management
26 //~ #define MENU_DIVIDER2 10 //YRT130718 divider is now managed by the scheduler
27 #define APP_DIVIDER 10
28 #define DELAY_AFTER_SEL 80
29 #define TIME_FOR_TOUCH_MENU (2000)
30 #define MENU_MIDD_POS (-350)
31 
32 /* Private function prototypes -----------------------------------------------*/
33 void MENU_SetCurrentApp( void );
34 enum MENU_code fYes( void );
35 enum MENU_code fNo( void );
36 
37 /* External variables --------------------------------------------------------*/
38 
39 /* Private variables ---------------------------------------------------------*/
40 color_t BGndColor_Menu = RGB_MAKE( 0xe6, 0xe6, 0xe6 ); //RGB_GREEN;
41 color_t TextColor_Menu = RGB_MAKE( 0x0, 0x0, 0x0 ); //RGB_BLUE;
42 tMenu* CurrentMenu = 0;
43 tMenuItem* CurrentCommand = 0;
44 tMenuItem* OldCommand = 0;
45 divider_t dividerCnt = 0;
46 bool iToShutDown = 0;
47 index_t CurSel = -1;
48 index_t Oldsel = 0;
49 index_t Newsel = 0;
50 u8 MenuCharWidth = 7;
51 u8 MenuCharHeight = 14;
52 s32 MenuTimePressed = 0;
53 s16 DoubleClickCounter_Menu = 0;
54 bool JoystickAsInput = 1;
55 bool MemsAsInput = 1;
56 bool TchscrAsInput = 1;
57 #if !TOUCHSCREEN_AVAIL
58 static s32 Counter_Joystick_Touch = 0;
59 #endif
60 //~ divider_t Menu_Divider = MENU_DIVIDER; //YRT130718 divider is now managed by the scheduler
61 divider_t Appli_Divider = APP_DIVIDER;
62 divider_t Appli_DividerBkp = APP_DIVIDER;
63 color_t title_BGndColor = RGB_MAKE( 0xE6, 0x0, 0x0 );
64 color_t title_TextColor = RGB_WHITE;
65 color_t selected_BGndColor = RGB_MAKE( 0x8C, 0xBE, 0x0 );
66 color_t selected_TextColor = RGB_WHITE;
67 tMenu* oldCurrentMenu;
68 extern tMenu AppMenu;
69 
70 tMenu QuestionMenu =
71 {
72  1,
73  0,
74  2, 0, 0, 0, 0, 0,
75  0,
76  {
77  { "Yes", fYes, 0, 0 },
78  { "No", fNo, 0, 0 }
79  }
80 };
81 
82 tMenu PrintMenu =
83 {
84  1,
85  0,
86  0, 0, 0, 0, 0, 0,
87  0,
88  {
89  { 0, 0, 0, 0 },
90  { 0, 0, 0, 0 }
91  }
92 };
93 
94 #if TOUCHSCREEN_AVAIL
95 tListMin ListMenu =
96 {
97  1,
98  "Title",
100  0, 0, 0, 0, 0,
101  MENU_MAXITEM,
102  0,
103  0
104 };
105 #endif
106 
107 bool* CurrentAnswer = 0;
108 
109 /* Private functions ---------------------------------------------------------*/
110 enum MENU_code fQuit( void );
111 
112 /*******************************************************************************
113 *
114 * fShutDown
115 *
116 *******************************************************************************/
123 /******************************************************************************/
124 NODEBUG enum MENU_code fShutdown( void )
125 {
126  MENU_Question( "Shutdown?", &iToShutDown );
127 
128  return MENU_CHANGE;
129 }
130 
131 /*******************************************************************************
132 *
133 * fSDCard
134 *
135 *******************************************************************************/
142 /******************************************************************************/
143 #if SDCARD_AVAIL
144 NODEBUG2 enum MENU_code fSDCard( void )
145 {
146  MENU_Set( &SDcardMenu );
147 
148  return MENU_CHANGE;
149 }
150 #endif
151 
152 
153 /*******************************************************************************
154 *
155 * RefreshItem
156 *
157 *******************************************************************************/
165 /******************************************************************************/
166 #if !TOUCHSCREEN_AVAIL
167 NODEBUG2 void RefreshItem( index_t sel, bool isInverted )
168 {
169  color_t save_BGndColor = DRAW_GetBGndColor();
170  color_t save_TextColor = DRAW_GetTextColor();
171 
172  // Set menu DRAW params
173  LCD_ChangeFont( Menu_Font );
174  DRAW_SetBGndColor( ( sel == -1 ) ? title_BGndColor : BGndColor_Menu );
175  DRAW_SetTextColor( ( sel == -1 ) ? title_TextColor : TextColor_Menu );
176 
177  MenuCharWidth = Char_Width * CharMagniCoeff;
178  MenuCharHeight = Char_Height * CharMagniCoeff;
179 
180  // Standard display
181  if ( !isInverted )
182  {
183  DRAW_DisplayString( ( Char_Width / 2 ) + CurrentMenu->XPos + 0,
184  ( Char_Width / 2 ) + CurrentMenu->YPos + ( CurrentMenu->NbItems - sel - 1 ) * MenuCharHeight,
185  ( sel == -1 ) ? ( u8* )CurrentMenu->Title : ( u8* )( CurrentMenu->Items[sel].Text ),
186  CurrentMenu->LgMax );
187  }
188  else
189  {
190  DRAW_SetBGndColor( ( sel == CurrentMenu->SelectedItem ) ? selected_BGndColor : title_BGndColor );
191  DRAW_SetTextColor( ( sel == CurrentMenu->SelectedItem ) ? selected_TextColor : title_TextColor );
192 
193  // Inverted display.
194  DRAW_DisplayString( ( Char_Width / 2 ) + CurrentMenu->XPos,
195  ( Char_Width / 2 ) + CurrentMenu->YPos + ( CurrentMenu->NbItems - sel - 1 ) * MenuCharHeight,
196  ( sel == -1 ) ? ( u8* ) CurrentMenu->Title : ( u8* )( CurrentMenu->Items[sel].Text ),
197  CurrentMenu->LgMax );
198  }
199 
200  // Draw a white rectangle around selected item, or background color for the others itmes.
201  LCD_DrawRect( CurrentMenu->XPos + 2,
202  ( Char_Width / 2 ) + CurrentMenu->YPos + ( CurrentMenu->NbItems - sel - 1 ) * MenuCharHeight,
203  CurrentMenu->LgMax * MenuCharWidth + 1,
204  Char_Height * CharMagniCoeff,
205  ( isInverted ) ? RGB_WHITE : BGndColor_Menu );
206 
207  // Restore previous DRAW params.
209  DRAW_SetBGndColor( save_BGndColor );
210  DRAW_SetTextColor( save_TextColor );
211 }
212 #endif
213 
214 
215 /*******************************************************************************
216 *
217 * fYes
218 *
219 *******************************************************************************/
226 /******************************************************************************/
227 NODEBUG enum MENU_code fYes( void )
228 {
229  if ( CurrentAnswer )
230  {
231  *CurrentAnswer = 1;
232  }
233 
234  return fQuit();
235 }
236 
237 /*******************************************************************************
238 *
239 * fNo
240 *
241 *******************************************************************************/
248 /******************************************************************************/
249 NODEBUG enum MENU_code fNo( void )
250 {
251  if ( CurrentAnswer )
252  {
253  *CurrentAnswer = 0;
254  }
255  return fQuit();
256 }
257 
258 
259 /* Public functions for CircleOS ---------------------------------------------*/
260 
261 /*******************************************************************************
262 *
263 * MENU_Handler
264 *
265 *******************************************************************************/
273 /******************************************************************************/
274 void MENU_Handler( void )
275 {
276  int ret;
277  index_t app;
278 #if !TOUCHSCREEN_AVAIL
279  static u32 bdelay = 0;
280 #endif
281 
282  if ( fInitDone == FALSE )
283  return;
284 
285  //-----------------------------------------------------------------------------
286  // In the 'home' page, the push button calls the main menu
287  //-----------------------------------------------------------------------------
288  if ( ( CurrentMenu == 0 ) && ( BUTTON_GetState() == BUTTON_PUSHED_FORMAIN ) )
289  {
290 
292 
293  // Add current application into main menu
294  MENU_SetCurrentApp();
295 
296  // Display main menu
297  MENU_Set( &MainMenu );
298  }
299 
300  //-----------------------------------------------------------------------------
301  // iToShutDown is a global flag to indicate that a shutdown has been requested
302  // In any situation, a long push will shutdown the power.
303  // This part is managed by the power handler if exists
304  //-----------------------------------------------------------------------------
305 #if !POWER_MNGT
306  if ( iToShutDown )
307  {
308  while ( 1 )
309  {
310  SHUTDOWN_Action();
311  }
312  }
313 #endif
314 
315  //-----------------------------------------------------------------------------
316  // No active menu (nor command) => nothing to do in this handler
317  //-----------------------------------------------------------------------------
318  if ( ( CurrentMenu == 0 ) && ( CurrentCommand == 0 ) )
319  {
320  return;
321  }
322 
323 
324  //-----------------------------------------------------------------------------
325  // When a menu is active, we check whether a command is to be launched
326  //-----------------------------------------------------------------------------
327 #if !TOUCHSCREEN_AVAIL
328  if ( ( CurrentMenu != 0 ) &&
329  ( CurrentCommand == 0 ) &&
331  ( DoubleClickCounter_Menu != MEMS_Info.DoubleClick )
332  ) )
333  {
334 #endif
335 
336 #if TOUCHSCREEN_AVAIL
337 
338  //----------------------------------------------------------------------------------
339  // Continue only each MENU_DIVIDER2 calls (specific for the LIST management).
340  //----------------------------------------------------------------------------------
341  dividerCnt++;
342  //~ if ( dividerCnt % MENU_DIVIDER2 ) //YRT130718 divider is now managed by the scheduler
343  //~ {
344  //~ return;
345  //~ }
346 
347  if ( ( CurrentMenu != 0 ) && ( CurrentCommand == 0 ) )
348  {
349  index_t index = -1;
350 
351  // Management menu by List
352  index = LIST_Manager();
353 
354  // Item selected
355  if ( index != -1 )
356  {
357  CurrentMenu->SelectedItem = index;
358 #endif
359  oldCurrentMenu = CurrentMenu;
360 
362  DoubleClickCounter_Menu = MEMS_Info.DoubleClick;
363 
364  // Handle the application change selection
365  if ( ( CurrentMenu == &AppMenu )
366  && ( AppMenu.Items[AppMenu.SelectedItem].Fct_Init != MENU_Quit ) )
367  {
368  app = APP_FindAppIndex( CurrentMenu->SelectedItem );
370  UTIL_LoadApp( app );
371  }
372 
373  CurrentCommand = &( oldCurrentMenu->Items[oldCurrentMenu->SelectedItem] );
374 
375  if ( CurrentCommand->fMenuFlag & REMOVE_MENU )
376  {
377  MENU_Remove();
378  }
379 
380  if ( oldCurrentMenu->NbItems )
381  {
382  if ( CurrentCommand->fMenuFlag & APP_MENU )
383  {
384  MENU_Remove();
387  LCD_SetRotateScreen( 0 );
388 
389  // By default, set the offset for application compatibility with Open4
390  if ( UTIL_GetPrimerType() > 2 )
392  }
393 
394  // Call application initialization function.
395 #if POWER_MNGT
396  POWER_Reset_Time();
397 #endif
398  ret = CurrentCommand ->Fct_Init();
399 
401 
402  if ( ret != MENU_CHANGE )
403  {
404  if ( ret != MENU_CONTINUE_COMMAND )
405  {
406  CurrentMenu = oldCurrentMenu;
407  }
408  }
409  }
410  else
411  {
412  CurrentMenu = 0;
413 
415  MENU_Remove();
416  fQuit();
417 
418  return;
419  }
420 
421  switch ( ret )
422  {
423  case MENU_LEAVE_AS_IT :
424  CurrentMenu = 0;
425  CurrentCommand = 0;
428  LCD_SetTransparency( 0 );
429  break;
430 
431  case MENU_LEAVE :
432  if ( !( CurrentMenu->Items[CurrentMenu->SelectedItem].fMenuFlag & REMOVE_MENU ) )
433  {
434  MENU_Remove();
435  }
436  CurrentCommand = 0;
437  CurrentMenu = 0;
440  LCD_SetTransparency( 0 );
441  break;
442 
443  case MENU_REFRESH :
444  MENU_Set( CurrentMenu );
445  break;
446 
447  case MENU_CHANGE :
448  case MENU_CONTINUE :
449  break;
450 
451  case MENU_CONTINUE_COMMAND :
452  CurrentCommand = &( oldCurrentMenu->Items[oldCurrentMenu->SelectedItem] );
453  break;
454  }
455 
456  return;
457 
458 #if TOUCHSCREEN_AVAIL
459  } // end if((index != -1))
460 #endif
461  } // end if(CurrentMenu != 0)
462 
463 #if !TOUCHSCREEN_AVAIL
464  //-----------------------------------------------------------------------------
465  // Continue only each Appli_Divider calls.
466  //-----------------------------------------------------------------------------
467  dividerCnt++;
468 #endif
469 
470  //-----------------------------------------------------------------------------
471  // A command is active and we redirect the execution to the application (or the configuration procedure)
472  //-----------------------------------------------------------------------------
473  if ( CurrentCommand && CurrentCommand->Fct_Manage )
474  {
475  if ( dividerCnt % Appli_Divider )
476  {
477  return;
478  }
479 
480  // Call application 'main' function.
481 #if POWER_MNGT
482  POWER_Reset_Time();
483 #endif
484 
485  ret = CurrentCommand->Fct_Manage();
486 
487  if ( ret == MENU_LEAVE )
488  {
491  LCD_SetTransparency( 0 );
492  MENU_Remove();
493  CurrentMenu = 0;
494  CurrentCommand = 0;
495  LCD_SetRotateScreen( 1 ); // YRT20090305
496  }
497  else if ( ( ret == MENU_RESTORE_COMMAND ) && OldCommand )
498  {
499  // YRT20090402 restore previous command,
500  CurrentCommand = OldCommand; // like application for example
501  }
502 
503  return;
504  }
505 
506  //-----------------------------------------------------------------------------
507  // Continue only each MENU_DIVIDER calls.
508  //-----------------------------------------------------------------------------
509  //~ if ( dividerCnt % Menu_Divider ) //YRT130718 divider is now managed by the scheduler
510  //~ {
511  //~ return;
512  //~ }
513 
514  //-----------------------------------------------------------------------------
515  // Check again whether a menu is active
516  //-----------------------------------------------------------------------------
517  if ( CurrentMenu == 0 )
518  {
519  return;
520  }
521 
522 #if !TOUCHSCREEN_AVAIL
523  //-----------------------------------------------------------------------------
524  // Manage the selection change within a menu
525  //-----------------------------------------------------------------------------
526  if ( dividerCnt % MENU_DIVIDER ) //YRT130718
527  {
528  return;
529  }
530 
531 #if JOYSTICK_AVAIL
532  //-----------------------------------------------------------------------------
533  // Manage the command selection with joystick according to interface configuration
534  //-----------------------------------------------------------------------------
535  if ( JoystickAsInput )
536  {
537 #if POWER_MNGT
538  POWER_Reset_Time();
539 #endif
540  switch ( JOYSTICK_GetState() )
541  {
542  case JOYSTICK_DOWN:
543  Newsel = Oldsel + 1;
545  Counter_Joystick_Touch = WEIGHTED_TIME( DELAY_AFTER_SEL ); // to leave the hand to the joystick for a while
546  break;
547 
548  case JOYSTICK_UP:
549  Newsel = Oldsel - 1;
551  Counter_Joystick_Touch = WEIGHTED_TIME( DELAY_AFTER_SEL ); // to leave the hand to the joystick for a while
552  break;
553  default:
554  if ( Counter_Joystick_Touch )
555  Counter_Joystick_Touch-- ;
556  break;
557  }
558  }
559 
560 #endif // if Joystick
561 
562  if ( ( MemsAsInput && ( Counter_Joystick_Touch == 0 ) ) || !JoystickAsInput )
563  {
564  // Manage the command selection with the current menu with mems
565  s16 MenuMaxPosY = MENU_MIDD_POS - 20 * CurrentMenu->NbItems;
566  s16 MenuMinPosY = MENU_MIDD_POS + 20 * CurrentMenu->NbItems;
567 
568  // Filtering of the moves in the menu:
569  // Oldsel and Newsel defines the new selected items.
570  // Newsel is the current selected item, and Oldsel the previous one.
571  // When the selection is stable (Newsel==Oldsel for MAXBTIME times),
572  // we consider that the current selection (sel) can be changed by Newsel.
573 
574  // Try absolute angle for positionning.
575  if ( MEMS_Info.RELATIVE_Y > MenuMinPosY )
576  {
577  // Out of range: too low.
578  Newsel = 0;
579  }
580  else if ( MEMS_Info.RELATIVE_Y < MenuMaxPosY )
581  {
582  // Out of range: too high.
583  Newsel = CurrentMenu->NbItems - 1;
584  }
585  else // In the range
586  {
587  Newsel = ( ( MenuMinPosY - MEMS_Info.RELATIVE_Y ) * ( CurrentMenu->NbItems - 2 ) ) / ( MenuMinPosY - MenuMaxPosY ) + 1 ;
588  }
589  }
590 
591  //-----------------------------------------------------------------------------
592  // Manage the command selection also with mems according to interface configuration
593  //-----------------------------------------------------------------------------
594  if ( Newsel >= CurrentMenu->NbItems )
595  {
596  Newsel = CurrentMenu->NbItems - 1;
597  }
598 
599  if ( Newsel < 0 )
600  {
601  Newsel = 0;
602  }
603 
604  if ( Newsel != Oldsel )
605  {
606  Oldsel = Newsel;
607  }
608  else
609  {
610  // Hysteresis
611  bdelay++;
612 
613  if ( bdelay >= WEIGHTED_TIME( MAXBTIME ) )
614  {
615  CurSel = Newsel;
616  bdelay = 0;
617  }
618  }
619 
620  if ( ( CurrentMenu->SelectedItem != CurSel ) && CurrentMenu->NbItems )
621  {
622  // First refresh old selected item
623  if ( CurrentMenu->SelectedItem >= 0 )
624  {
625  RefreshItem( CurrentMenu->SelectedItem, NORMAL_TEXT );
626  }
627 
628  // Then select the new selected item
629  CurrentMenu->SelectedItem = CurSel;
630  RefreshItem( CurrentMenu->SelectedItem, INVERTED_TEXT );
631  }
632 
633 #endif // if !Touchscreen
634  }
635 
636 /*******************************************************************************
637 *
638 * fQuit
639 *
640 *******************************************************************************/
647 /******************************************************************************/
648 NODEBUG enum MENU_code fQuit( void )
649 {
651 
653 #if DMA2D_AVAIL
654  {
655  extern enum tModeLCDAccess DMALCD_ModeLCDAccess;
656 
657  DMALCD_ModeLCDAccess = LCD_Only; //FL131011 return to non-DMA mode by default
658  ResetScreenApp();
659  }
660 #endif
662 
663  LCD_FullScreen(0);
665 
668  POINTER_Init();
669 
671  DRAW_Clear();
673  LCD_SetTransparency( 0 );
674 
676  LED_Set( LED_RED, LED_OFF );
677 
678 #if SDCARD_AVAIL
679  FS_SetPathFilter( 0 );
680 #endif
681 
683  LCD_SetRotateScreen( 1 );
685  return MENU_LEAVE;
686 }
687 
688 /*******************************************************************************
689 *
690 * FS_Explorer_Handler
691 *
692 *******************************************************************************/
700 /******************************************************************************/
701 #if SDCARD_AVAIL
702  NODEBUG2 enum MENU_code FS_Explorer_Handler( void )
703  {
704  if ( FS_Explorer() == -1 )
705  {
706  return MENU_CONTINUE;
707  }
708  else
709  FS_Unmount( MMCSD_SDIO ); //YRT130605 moved from FS_Explorer()
710  MENU_SetAppliDivider(Appli_DividerBkp); //YRT1307123 moved from FS_Explorer()
711  return fQuit();
712  }
713 #endif //SDCARD_AVAIL
714 
716 
717 /* Public functions ----------------------------------------------------------*/
718 
719 /*******************************************************************************
720 *
721 * MENU_Quit
722 *
723 *******************************************************************************/
730 /******************************************************************************/
731 enum MENU_code MENU_Quit( void )
732 {
733  return fQuit();
734 }
735 
736 /*******************************************************************************
737 *
738 * MENU_SetTextColor
739 *
740 *******************************************************************************/
748 /********************************************************************************/
749 void MENU_SetTextColor( color_t TxtColor )
750 {
751  TextColor_Menu = TxtColor;
752 }
753 
754 /*******************************************************************************
755 *
756 * MENU_GetTextColor
757 *
758 *******************************************************************************/
766 /******************************************************************************/
767 color_t MENU_GetTextColor( void )
768 {
769  return TextColor_Menu;
770 }
771 
772 /*******************************************************************************
773 *
774 * MENU_SetBGndColor
775 *
776 *******************************************************************************/
784 /******************************************************************************/
785 void MENU_SetBGndColor( color_t bgndColor )
786 {
787  BGndColor_Menu = bgndColor;
788 }
789 
790 /*******************************************************************************
791 *
792 * MENU_GetBGndColor
793 *
794 *******************************************************************************/
802 /******************************************************************************/
803 color_t MENU_GetBGndColor( void )
804 {
805  return BGndColor_Menu;
806 }
807 
808 /*******************************************************************************
809 *
810 * MENU_Remove
811 *
812 *******************************************************************************/
818 /******************************************************************************/
819 void MENU_Remove( void )
820 {
821  CurrentMenu = 0;
822  DRAW_Clear();
826  LCD_SetTransparency( 0 );
827  /*#if TOUCHSCREEN_AVAIL
828  CharMagniCoeff_List = 1;
829  #endif*/
830 }
831 
832 /*******************************************************************************
833 *
834 * MENU_Set
835 *
836 *******************************************************************************/
844 /******************************************************************************/
845 void MENU_Set( tMenu * mptr )
846 {
847  int i;
848 
849 #if !TOUCHSCREEN_AVAIL
850  int lg;
851  int lg_max = 0;
852  int n = mptr->NbItems;
853  int nlines = n;
854 #endif
855 
856 #if TOUCHSCREEN_AVAIL
857 
858  // Menu management by list
859  if ( CurrentToolbar == &DefaultToolbar )
860  {
861  TOOLBAR_ChangeButton( 0, 0, 0 ); // Remove the 'config' button
862  TOUCHSCR_SetMode( TS_NORMAL );
863  }
864 
865  // Primer menu management by LIST
866  ListMenu.fdispTitle = mptr->fdispTitle;
867  ListMenu.Title = mptr->Title;
868  ListMenu.NbItems = mptr->NbItems;
869  ListMenu.NbDisp = mptr->NbItems;
870  ListMenu.XPos = mptr->XPos;
871  ListMenu.YPos = mptr->YPos;
872  ListMenu.FirstDisplayItem = 0;
873 
874  for ( i = 0; i < ListMenu.NbItems; i++ )
875  {
876  ListMenu.Items[i].Text = ( char* )mptr->Items[i].Text;
877  }
878 
879  if ( ( ListMenu.XPos + ListMenu.YPos ) == 0 )
880  LIST_Set( ( tList* ) &ListMenu, 0, 0, TRUE );
881  else
882  LIST_Set( ( tList* ) &ListMenu, ListMenu.XPos, ListMenu.YPos, FALSE );
883 
884 #endif // Touchscreen
885 
886  CurrentMenu = mptr;
887  OldCommand = CurrentCommand;
888 
891 
892 #if !TOUCHSCREEN_AVAIL
893 
894  // Old menu management
895  for ( i = 0; i < n; i++ )
896  {
897  lg = my_strlen( ( char* )mptr->Items[i].Text );
898 
899  if ( lg > lg_max )
900  {
901  lg_max = lg;
902  }
903  }
904 
905  if ( mptr->fdispTitle )
906  {
907  lg = my_strlen( ( char* )mptr->Title );
908 
909  if ( lg > lg_max )
910  {
911  lg_max = lg;
912  }
913 
914  nlines++;
915  }
916 
917 #if !EXT_FONT
918  Menu_Font = ( MENU_BigFont ? 1 : 0 );
919 #endif
920  LCD_ChangeFont( Menu_Font );
921  mptr->LgMax = lg_max;
922  mptr->XSize = ( lg_max * Char_Width * CharMagniCoeff ) + Char_Width;
923  mptr->YSize = ( nlines * Char_Height * CharMagniCoeff ) + Char_Width;
924  mptr->XPos = ( Screen_Width - mptr->XSize ) / 2;
925  mptr->YPos = ( Screen_Height - mptr->YSize ) / 2;
926 
927  //
928  LCD_FillRect_Circle( mptr->XPos, mptr->YPos, mptr->XSize, mptr->YSize, BGndColor_Menu );
929  LCD_DrawRect( mptr->XPos, mptr->YPos, mptr->XSize, mptr->YSize, 0 );
930 
931  // Display title.
932  if ( mptr->fdispTitle )
933  {
934  RefreshItem( -1, NORMAL_TEXT );
935  }
936 
937  // Set variables used for filtering/stability.
938  CurSel = mptr->SelectedItem;
939  Oldsel = CurSel;
940  Newsel = CurSel;
941 
942  // Display the list of items.
943  for ( i = 0 ; i < n ; i++ )
944  {
945  RefreshItem( i, ( i == mptr->SelectedItem ) ? INVERTED_TEXT : NORMAL_TEXT );
946  }
947 
948  // No time display while a menu is active.
949  fDisplayTime = 0;
950 
951  DoubleClickCounter_Menu = MEMS_Info.DoubleClick;
952 
954 
955 #endif // if !TOUCHSCREEN_AVAIL
956 
958 }
959 
960 /*******************************************************************************
961 *
962 * MENU_Question
963 *
964 *******************************************************************************/
973 /********************************************************************************/
974 void MENU_Question( const u8 * str, bool * answer )
975 {
976  QuestionMenu.Title = str;
977  CurrentAnswer = answer;
978 
979  MENU_Set( &QuestionMenu );
980 }
981 
982 /***********************************************************************************
983 *
984 * MENU_ClearCurrentCommand
985 *
986 ************************************************************************************/
992 /********************************************************************************/
994 {
995  CurrentCommand = 0;
996 }
997 
998 /***********************************************************************************
999 *
1000 * MENU_ClearCurrentMenu
1001 *
1002 ************************************************************************************/
1008 /********************************************************************************/
1010 {
1011  CurrentMenu = 0;
1012 }
1013 
1014 /***********************************************************************************
1015 *
1016 * MENU_Print
1017 *
1018 ************************************************************************************/
1026 /********************************************************************************/
1027 void MENU_Print( const u8 * str )
1028 {
1029  PrintMenu.Title = str;
1030 
1031  MENU_Set( &PrintMenu );
1032 }
1033 
1034 /***********************************************************************************
1035 *
1036 * MENU_SetAppliDivider
1037 *
1038 ************************************************************************************/
1050 /********************************************************************************/
1051 void MENU_SetAppliDivider( divider_t divider )
1052 {
1053  Appli_Divider = divider;
1054 }
1055 
1056 /***********************************************************************************
1057 *
1058 * MENU_RestoreAppliDivider
1059 *
1060 ************************************************************************************/
1066 /********************************************************************************/
1068 {
1069  Appli_Divider = APP_DIVIDER;
1070 }