25 #define MENU_DIVIDER 10 // Used for non touchscreen management
27 #define APP_DIVIDER 10
28 #define DELAY_AFTER_SEL 80
29 #define TIME_FOR_TOUCH_MENU (2000)
30 #define MENU_MIDD_POS (-350)
33 void MENU_SetCurrentApp(
void );
40 color_t BGndColor_Menu =
RGB_MAKE( 0xe6, 0xe6, 0xe6 );
41 color_t TextColor_Menu =
RGB_MAKE( 0x0, 0x0, 0x0 );
42 tMenu* CurrentMenu = 0;
45 divider_t dividerCnt = 0;
51 u8 MenuCharHeight = 14;
52 s32 MenuTimePressed = 0;
53 s16 DoubleClickCounter_Menu = 0;
54 bool JoystickAsInput = 1;
56 bool TchscrAsInput = 1;
57 #if !TOUCHSCREEN_AVAIL
58 static s32 Counter_Joystick_Touch = 0;
61 divider_t Appli_Divider = APP_DIVIDER;
62 divider_t Appli_DividerBkp = APP_DIVIDER;
63 color_t title_BGndColor =
RGB_MAKE( 0xE6, 0x0, 0x0 );
65 color_t selected_BGndColor =
RGB_MAKE( 0x8C, 0xBE, 0x0 );
67 tMenu* oldCurrentMenu;
77 {
"Yes", fYes, 0, 0 },
107 bool* CurrentAnswer = 0;
166 #if !TOUCHSCREEN_AVAIL
167 NODEBUG2
void RefreshItem( index_t sel,
bool isInverted )
177 MenuCharWidth = Char_Width * CharMagniCoeff;
178 MenuCharHeight = Char_Height * CharMagniCoeff;
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 );
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 );
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 );
274 void MENU_Handler(
void )
278 #if !TOUCHSCREEN_AVAIL
279 static u32 bdelay = 0;
282 if ( fInitDone == FALSE )
294 MENU_SetCurrentApp();
318 if ( ( CurrentMenu == 0 ) && ( CurrentCommand == 0 ) )
327 #if !TOUCHSCREEN_AVAIL
328 if ( ( CurrentMenu != 0 ) &&
329 ( CurrentCommand == 0 ) &&
331 ( DoubleClickCounter_Menu != MEMS_Info.DoubleClick )
336 #if TOUCHSCREEN_AVAIL
347 if ( ( CurrentMenu != 0 ) && ( CurrentCommand == 0 ) )
359 oldCurrentMenu = CurrentMenu;
362 DoubleClickCounter_Menu = MEMS_Info.DoubleClick;
365 if ( ( CurrentMenu == &AppMenu )
382 if ( CurrentCommand->fMenuFlag &
APP_MENU )
406 CurrentMenu = oldCurrentMenu;
458 #if TOUCHSCREEN_AVAIL
463 #if !TOUCHSCREEN_AVAIL
473 if ( CurrentCommand && CurrentCommand->
Fct_Manage )
475 if ( dividerCnt % Appli_Divider )
500 CurrentCommand = OldCommand;
517 if ( CurrentMenu == 0 )
522 #if !TOUCHSCREEN_AVAIL
526 if ( dividerCnt % MENU_DIVIDER )
535 if ( JoystickAsInput )
545 Counter_Joystick_Touch = WEIGHTED_TIME( DELAY_AFTER_SEL );
551 Counter_Joystick_Touch = WEIGHTED_TIME( DELAY_AFTER_SEL );
554 if ( Counter_Joystick_Touch )
555 Counter_Joystick_Touch-- ;
560 #endif // if Joystick
562 if ( ( MemsAsInput && ( Counter_Joystick_Touch == 0 ) ) || !JoystickAsInput )
565 s16 MenuMaxPosY = MENU_MIDD_POS - 20 * CurrentMenu->
NbItems;
566 s16 MenuMinPosY = MENU_MIDD_POS + 20 * CurrentMenu->
NbItems;
575 if ( MEMS_Info.RELATIVE_Y > MenuMinPosY )
580 else if ( MEMS_Info.RELATIVE_Y < MenuMaxPosY )
583 Newsel = CurrentMenu->
NbItems - 1;
587 Newsel = ( ( MenuMinPosY - MEMS_Info.RELATIVE_Y ) * ( CurrentMenu->
NbItems - 2 ) ) / ( MenuMinPosY - MenuMaxPosY ) + 1 ;
594 if ( Newsel >= CurrentMenu->
NbItems )
596 Newsel = CurrentMenu->
NbItems - 1;
604 if ( Newsel != Oldsel )
613 if ( bdelay >= WEIGHTED_TIME( MAXBTIME ) )
633 #endif // if !Touchscreen
657 DMALCD_ModeLCDAccess = LCD_Only;
679 FS_SetPathFilter( 0 );
702 NODEBUG2
enum MENU_code FS_Explorer_Handler(
void )
704 if ( FS_Explorer() == -1 )
713 #endif //SDCARD_AVAIL
751 TextColor_Menu = TxtColor;
769 return TextColor_Menu;
787 BGndColor_Menu = bgndColor;
805 return BGndColor_Menu;
849 #if !TOUCHSCREEN_AVAIL
856 #if TOUCHSCREEN_AVAIL
859 if ( CurrentToolbar == &DefaultToolbar )
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;
874 for ( i = 0; i < ListMenu.NbItems; i++ )
876 ListMenu.Items[i].Text = (
char* )mptr->
Items[i].
Text;
879 if ( ( ListMenu.XPos + ListMenu.YPos ) == 0 )
882 LIST_Set( (
tList* ) &ListMenu, ListMenu.XPos, ListMenu.YPos, FALSE );
884 #endif // Touchscreen
887 OldCommand = CurrentCommand;
892 #if !TOUCHSCREEN_AVAIL
895 for ( i = 0; i < n; i++ )
897 lg = my_strlen( (
char* )mptr->
Items[i].
Text );
907 lg = my_strlen( (
char* )mptr->
Title );
918 Menu_Font = ( MENU_BigFont ? 1 : 0 );
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;
928 LCD_FillRect_Circle( mptr->
XPos, mptr->
YPos, mptr->
XSize, mptr->
YSize, BGndColor_Menu );
943 for ( i = 0 ; i < n ; i++ )
951 DoubleClickCounter_Menu = MEMS_Info.DoubleClick;
955 #endif // if !TOUCHSCREEN_AVAIL
976 QuestionMenu.
Title = str;
977 CurrentAnswer = answer;
1029 PrintMenu.
Title = str;
1053 Appli_Divider = divider;
1069 Appli_Divider = APP_DIVIDER;