20 #define MAXLOCKMEMS 200
21 #define ANGLEPAUSE -100
22 #define MIN_ANGLE_FOR_SHIFT_UP (ANGLEPAUSE+CurrentAngleStart + 150)
23 #define MIN_ANGLE_FOR_SHIFT_DOWN (ANGLEPAUSE-CurrentAngleStart - 150)
24 #define TIME_FOR_TOUCH_LIST (2000)
25 #define LIST_DIVIDER 10
26 #define DELAY_BEFORE_DBCLK 80
29 #define JOY_MAXBTIME 20
30 #define JOY_HIGH_SPEED 5
31 #define JOY_LOW_SPEED 1
33 #define FIRST_VISIBLE ( CurrentList->FirstDisplayItem - ( (nb_move<0) ? 1 : 0 ) )
36 extern color_t bmpTmp[LCD_DMA_SIZE];
41 s32 DisplaySelectedItem = 0;
42 s32 CurOrientList =
V12;
43 s32 OldOrientList = -1;
44 bool move_old_Pressed = FALSE;
46 s32 Max_X_List, Min_X_List;
47 s32 Max_Y_List, Min_Y_List;
50 static s32 ListTimePressed = 0;
51 static divider_t ListCptDivider = 0;
54 tList* CurrentList = 0;
58 static u16 JoyDelay = 0;
59 static u16 JoyInc = 1;
63 void LIST_RefreshItem( index_t sel,
bool isInverted );
64 s32 LIST_GetNewSelectedItem(
void );
65 s32 LIST_DetectMove(
void );
66 void StoreStringWithMode( u16* buffer,
const u8* ptr, u8 len, u8 offset, u8 nblines );
67 void StoreChar( u16* buffer, u8* bmp, u8 nblines, u8 offset, color_t textColor, color_t bGndColor, mag_t CharMagniCoeff );
68 void SearchNewFirstItem(
void );
69 void InitListDMA(
void );
70 void LIST_LCD_RectRead( coord_t x, coord_t y, coord_t width, coord_t height );
71 void LIST_DRAW_SetImage( coord_t x, coord_t y, coord_t width, coord_t height );
72 void LIST_StoreString( u16* buffer,
const u8* ptr, u8 len, u8 offset, u8 nblines, u16 textColor, u16 bGndColor, u16 CharMagniCoeff );
73 void LIST_StoreChar( u16* buffer, u8* bmp, u8 nblines, u8 offset, u16 textColor, u16 bGndColor, u16 CharMagniCoeff );
79 extern u32 DoubleClickCounter_Menu;
80 extern color_t title_BGndColor;
81 extern color_t title_TextColor;
82 extern color_t selected_BGndColor;
83 extern color_t selected_TextColor;
84 extern s16 CurrentAngleStart;
97 NODEBUG2
void SearchNewFirstItem(
void )
102 nb_char_move = ( nb_move * DeltaY ) / ListCharHeight;
107 DisplaySelectedItem -= nb_char_move;
108 nb_move -= ( nb_char_move * ListCharHeight / DeltaY );
126 #if TOUCHSCREEN_AVAIL
127 NODEBUG2 s32 LIST_GetNewSelectedItem(
void )
130 s32 SelectedItem = -1;
131 static bool fJoystickHasInput_old = 0;
133 static s32 MemsLockCounter = MAXLOCKMEMS ;
134 bool fJoystickHasInput;
145 if ( ( X < Screen_Width ) && ( Y < Screen_Height ) )
148 if ( ( Y < Min_Y_List ) || ( Y > Max_Y_List ) )
152 SelectedItem = ( Max_Y_List - Y + ( nb_move * DeltaY ) ) / ListCharHeight ;
153 if ( SelectedItem >= CurrentList->
NbDisp )
155 SelectedItem = CurrentList->
NbDisp - ( nb_move ? 0 : 1 );
157 if ( SelectedItem < 0 )
161 if ( SelectedItem != DisplaySelectedItem )
167 fJoystickHasInput = FALSE;
170 if ( JoystickAsInput && ( SelectedItem == -1 ) )
176 fJoystickHasInput = TRUE;
184 if ( ( fJoystickHasInput_old == 0 ) || ( JoyDelay >= WEIGHTED_TIME( 3 * JOY_MAXBTIME ) ) )
191 if ( ( DisplaySelectedItem < CurrentList->NbDisp ) && ( CurrentList->
SelectedItem < CurrentList->
NbItems - 1 ) )
192 SelectedItem = DisplaySelectedItem + 1;
197 if ( DisplaySelectedItem > 0 )
198 SelectedItem = DisplaySelectedItem - 1;
203 fJoystickHasInput_old = fJoystickHasInput;
207 if ( SelectedItem != -1 )
209 MemsLockCounter = WEIGHTED_TIME( 2 * MAXLOCKMEMS );
212 if ( MemsLockCounter )
218 if ( MEMSASINPUT && ( SelectedItem == -1 ) && ( JoyPos ==
JOYSTICK_RELEASED ) && ( fIsPressed == 0 ) )
221 if ( ( DisplaySelectedItem < CurrentList->NbDisp ) && ( CurrentList->
SelectedItem < CurrentList->
NbItems - 1 )
222 && ( MEMS_Info.RELATIVE_Y < MIN_ANGLE_FOR_SHIFT_DOWN ) )
224 SelectedItem = DisplaySelectedItem + 1;
226 if ( ( DisplaySelectedItem > 0 ) && ( MEMS_Info.RELATIVE_Y > MIN_ANGLE_FOR_SHIFT_UP ) )
228 SelectedItem = DisplaySelectedItem - 1;
230 if ( SelectedItem != -1 )
232 MemsLockCounter = WEIGHTED_TIME( MAXLOCKMEMS / 3 );
238 #endif //TOUCHSCREEN_AVAIL
256 #if TOUCHSCREEN_AVAIL
257 NODEBUG2 s32 LIST_DetectMove(
void )
259 static s32 move_old_Y = 0;
262 static s32 MemsLockCounter = MAXLOCKMEMS ;
263 bool fJoystickHasInput;
273 if ( ( X > Min_X_List ) && ( X < Max_X_List ) )
275 if ( move_old_Pressed == FALSE )
277 move_old_Y = move_cur_Y;
281 dir = ( move_cur_Y - move_old_Y ) / DeltaY;
285 move_old_Y += DeltaY;
287 else if ( dir <= -1 )
290 move_old_Y -= DeltaY;
293 move_old_Pressed = TRUE;
299 move_old_Pressed = FALSE;
304 fJoystickHasInput = FALSE;
305 if ( JoystickAsInput )
310 if ( DisplaySelectedItem <= 0 )
315 if ( DisplaySelectedItem >= CurrentList->
NbDisp )
322 fJoystickHasInput = TRUE;
330 if ( JoyDelay >= JOY_MAXBTIME )
331 JoyInc = JOY_HIGH_SPEED;
333 JoyInc = JOY_LOW_SPEED;
339 MemsLockCounter = WEIGHTED_TIME( MAXLOCKMEMS );
342 if ( MemsLockCounter )
348 if ( MEMSASINPUT && ( dir == 0 ) && ( JoyPos ==
JOYSTICK_RELEASED ) && ( move_old_Pressed == 0 ) )
350 extern s16 CurrentAngleStart ;
352 if ( ( ( DisplaySelectedItem >= CurrentList->
NbDisp ) && ( MEMS_Info.RELATIVE_Y < MIN_ANGLE_FOR_SHIFT_DOWN ) )
353 || ( ( DisplaySelectedItem <= 0 ) && ( MEMS_Info.RELATIVE_Y > MIN_ANGLE_FOR_SHIFT_UP ) ) )
355 dir = -MEMS_Info.RELATIVE_Y ;
361 #endif //TOUCHSCREEN_AVAIL
376 NODEBUG2
void LIST_RefreshItem( index_t sel,
bool isInverted )
378 s32 lg = CurrentList->
LgMax;
387 if ( ( !CurrentList->
fdispTitle ) && ( sel == -1 ) )
397 offs = ( sel == -1 ) ? 0 : ( nb_move * DeltaY );
403 LCD_DrawCharSetFilter( Min_X_List, Max_X_List, Min_Y_List, Max_Y_List );
406 CurrentList->
YPos - ( ( sel + 2 ) * ListCharHeight ) - ListCharHeight / 4 + offs,
407 ( sel == -1 ) ? (
char* )CurrentList->
Title : (
char* )( CurrentList->
Items[index].
Text ),
413 LCD_DrawCharSetFilter( 0, Screen_Width, 0, Screen_Height );
422 LCD_DrawCharSetFilter( Min_X_List, Max_X_List, Min_Y_List, Max_Y_List );
425 CurrentList->
YPos - ( ( sel + 2 ) * ListCharHeight ) - ListCharHeight / 4 + offs,
426 ( sel == -1 ) ? (
char* ) CurrentList->
Title : (
char* )( CurrentList->
Items[index].
Text ),
432 LCD_DrawCharSetFilter( 0, Screen_Width, 0, Screen_Height );
461 NODEBUG2
void LIST_StoreString( u16* buffer,
const u8* ptr, u8 len, u8 offset, u8 nblines, u16 textColor, u16 bGndColor, u16 charMagniCoeff )
463 u8 c, car = 0, Char_By_Line;
465 Char_By_Line = Screen_Width / ( Char_Width * charMagniCoeff );
468 if ( len > Char_By_Line )
473 for ( car = 0 ; car < len ; car++ )
487 LIST_StoreChar( ( u16* ) buffer, ( u8* )&CurrentFont[( ( c - 32 ) * ( 2 * Char_Width ) )], nblines / charMagniCoeff, offset, textColor, bGndColor, charMagniCoeff );
490 buffer += ( nblines * Char_Width * charMagniCoeff );
517 NODEBUG2
void LIST_StoreChar( u16* buffer, u8* bmp, u8 nblines, u8 offset, u16 textColor, u16 bGndColor, u16 charMagniCoeff )
526 for ( i = 0 ; i < offset; i++ )
531 for ( i = 0 ; i < nblines; i++ )
535 for ( i = 0; i < Char_Width ; i++ )
538 matrix = ( bmp[2 * i] << 8 ) | bmp[2 * i + 1];
540 for ( k1 = 0; k1 < charMagniCoeff; k1++ )
543 for ( mask = k3; mask > k4 ; mask >>= 1 )
545 for ( k2 = 0; k2 < charMagniCoeff; k2++ )
547 *( buffer++ ) = ( ( matrix & mask ) ? textColor : bGndColor ) ;
599 DisplaySelectedItem = 0;
610 for ( i = 0; i < CurrentList->
NbItems; i++ )
612 lg = my_strlen( ( u8* )CurrentList->
Items[i].
Text );
619 lg = my_strlen( ( u8* )CurrentList->
Title );
627 CurrentList->
LgMax = lg_max;
634 CurrentList->
XSize = ( lg_max + 1 ) * ListCharWidth;
635 CurrentList->
YSize = ( ( CurrentList->
NbDisp + 1 ) * ListCharHeight ) + ListCharHeight / 2;
638 CurrentList->
XPos = ( Screen_Width - CurrentList->
XSize ) / 2;
639 CurrentList->
YPos = ( ( Screen_Height - CurrentList->
YSize ) / 2 ) + CurrentList->
YSize;
643 CurrentList->
XPos = posX;
644 CurrentList->
YPos = posY;
648 Max_Y_List = CurrentList->
YPos - ListCharHeight - ListCharHeight / 4;
649 Min_Y_List = Max_Y_List - CurrentList->
NbDisp * ListCharHeight ;
650 XSize = ( lg_max ) * ListCharWidth;
651 YSize = ( Max_Y_List - Min_Y_List ) + ( ListCharHeight );
652 Min_X_List = ( CurrentList->
XPos ) + ( ListCharWidth / 2 );
653 Max_X_List = Min_X_List + XSize;
656 LCD_FillRect_Circle( CurrentList->
XPos, CurrentList->
YPos - CurrentList->
YSize, CurrentList->
XSize, CurrentList->
YSize, BGndColor_Menu );
666 if ( CurrentList->
NbItems != 0 )
669 for ( i = 0 ; i < CurrentList->
NbDisp ; i++ )
682 DoubleClickCounter_Menu = MEMS_Info.DoubleClick;
710 #if TOUCHSCREEN_AVAIL
714 s32 offset, move = 0;
719 if ( CurrentList == 0 )
725 width = Max_X_List - Min_X_List;
731 NewSelList = move_old_Pressed ? DisplaySelectedItem : LIST_GetNewSelectedItem();
733 if ( ( NewSelList != -1 ) && ( NewSelList != DisplaySelectedItem ) )
736 if ( ( DisplaySelectedItem >= 0 ) && ( DisplaySelectedItem <= CurrentList->NbDisp ) )
738 LIST_RefreshItem( DisplaySelectedItem,
NORMAL_TEXT );
742 DisplaySelectedItem = NewSelList;
747 if ( ( DisplaySelectedItem >= 0 ) && ( DisplaySelectedItem <= CurrentList->NbDisp ) )
757 if ( ( CurOrientList != OldOrientList )
758 && ( CurrentMenu == 0 ) )
760 LCD_FillRect_Circle( CurrentList->
XPos, CurrentList->
YPos - CurrentList->
YSize, CurrentList->
XSize, CurrentList->
YSize, BGndColor_Menu );
767 for ( i = 0 ; i < CurrentList->
NbDisp ; i++ )
772 OldOrientList = CurOrientList;
775 move = LIST_DetectMove();
786 for ( y = Min_Y_List + DeltaY; y < Max_Y_List ; y += DeltaY )
788 LIST_LCD_RectRead( x, y, width, DeltaY );
789 LIST_DRAW_SetImage( x, y - DeltaY, width, DeltaY );
797 ptr = ( u8* )( CurrentList->
Items[FIRST_VISIBLE].
Text );
802 offset += Char_Height;
804 txtcolor = ( ( DisplaySelectedItem + ( ( nb_move < 0 ) ? 1 : 0 ) ) == 0 ) ? selected_TextColor : TextColor_Menu ;
805 bgdcolor = ( ( DisplaySelectedItem + ( ( nb_move < 0 ) ? 1 : 0 ) ) == 0 ) ? selected_BGndColor : BGndColor_Menu ;
806 LIST_StoreString( ( u16* )&bmpTmp, ptr, CurrentList->
LgMax + 1, offset, DeltaY, txtcolor, bgdcolor, DRAW_GetCharMagniCoeff() );
808 DRAW_SetImage( (
const color_t* ) &bmpTmp, x, Max_Y_List - DeltaY, width, DeltaY );
818 for ( y = Max_Y_List - ( 2 * DeltaY ) ; y >= Min_Y_List ; y -= DeltaY )
820 LIST_LCD_RectRead( x, y, width, DeltaY );
821 LIST_DRAW_SetImage( x, y + DeltaY, width, DeltaY );
828 ptr = ( u8* )( CurrentList->
Items[FIRST_VISIBLE + CurrentList->
NbDisp].
Text );
831 offset = Char_Height - offset;
833 txtcolor = ( DisplaySelectedItem == ( CurrentList->
NbDisp - ( ( nb_move <= 0 ) ? 1 : 0 ) ) ) ? selected_TextColor : TextColor_Menu ;
834 bgdcolor = ( DisplaySelectedItem == ( CurrentList->
NbDisp - ( ( nb_move <= 0 ) ? 1 : 0 ) ) ) ? selected_BGndColor : BGndColor_Menu ;
836 LIST_StoreString( ( u16* )&bmpTmp, ptr, CurrentList->
LgMax + 1, offset, DeltaY, txtcolor, bgdcolor, DRAW_GetCharMagniCoeff() );
839 DRAW_SetImage( (
const color_t* ) &bmpTmp, x, Min_Y_List, width, DeltaY );
843 SearchNewFirstItem();
848 static u8 buffer[15] =
"F10 M-XX S02";
865 CurrentList->
Title = buffer;
870 if ( ListCptDivider < DELAY_BEFORE_DBCLK )
871 DoubleClickCounter_Menu = MEMS_Info.DoubleClick;
876 || ( DoubleClickCounter_Menu != MEMS_Info.DoubleClick )
880 DoubleClickCounter_Menu = MEMS_Info.DoubleClick;
893 ListTimePressed += LIST_DIVIDER;