📄 menux.c
字号:
}
/* "KEY" key is pressed */
if(!GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_9))
{
while(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_9) == Bit_RESET)
{
}
return KEY;
}
/* No key is pressed */
else
{
return NOKEY;
}
}
/*******************************************************************************
* Function Name : IdleFunc
* Description : Idle function.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void IdleFunc(void)
{
/* Nothing to execute: return */
return;
}
/*******************************************************************************
* Function Name : DisplayIcons
* Description : Display menu icons.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void DisplayIcons(void)
{
u32 j = 0, l = 0, iconline = 0, iconcolumn = 0;
iconline = 98;
iconcolumn = 290 ;
// for(i = 0; i < 3; i++)
{
for(j = 0; j < 4; j++)
{
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
LCD_SetDisplayWindow(iconline, iconcolumn, 64, 64);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, DISABLE);
LCD_NORDisplay(IconsAddr[l]);
iconcolumn -= 65;
l++;
if(l == NumberOfIcons)
{
return;
}
}
//iconline += 65;
//iconcolumn = 290;
}
}
/*******************************************************************************
* Function Name : ShowMenuIcons
* Description : Show the main menu icon.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void ShowMenuIcons(void)
{
u32 MyKey = 0, i = 0;
u16 IconRect[4][2] ={{34, 290}, {34, 225}, {34, 160}, {34, 95},};
/* Disable the JoyStick interrupts */
IntExtOnOffConfig(DISABLE);
while(ReadKey() != NOKEY)
{
}
/* Initializes the Menu state machine */
Menu_Init();
MenuItemIndex = 0;
/* Clear*/
LCD_Clear(White);
/* Set the Back Color */
LCD_SetBackColor(Blue);
/* Set the Text Color */
LCD_SetTextColor(White);
LCD_DisplayStringLine(Line0, psMenuItem->pszTitle);
/* Set the Back Color */
LCD_SetBackColor(White);
/* Set the Text Color */
LCD_SetTextColor(Blue);
/* Displays Icons */
DisplayIcons();
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
/* Disable LCD Window mode */
LCD_WindowModeDisable();
LCD_DrawRect(IconRect[0][0], IconRect[0][1], 64, 65);
while(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1) == RESET)
{
}
/* Endless loop */
while(1)
{
/* Check which key is pressed */
MyKey = ReadKey();
/* If "UP" pushbutton is pressed */
if(MyKey == UP)
{
/* Set the Text Color */
LCD_SetTextColor(White);
LCD_DrawRect(IconRect[i][0], IconRect[i][1], 64, 65);
/* if(i <= 3)
{
i += 8;
if(i >= NumberOfIcons)
{
i = (NumberOfIcons - 1);
}
}
else
{
i -= 4;
} */
if(i==0)
i=3;
else i--;
/* Set the Text Color */
LCD_SetTextColor(Blue);
LCD_DrawRect(IconRect[i][0], IconRect[i][1], 64, 65);
/* Set the Back Color */
LCD_SetBackColor(Blue);
/* Set the Text Color */
LCD_SetTextColor(White);
/* Test on the MenuItemIndex value before incrementing it */
if(MenuItemIndex==0)
MenuItemIndex=3;
else MenuItemIndex--;
/*if(MenuItemIndex <= 3)
{
MenuItemIndex += 8;
if(MenuItemIndex >= NumberOfIcons)
{
MenuItemIndex = (NumberOfIcons - 1);
}
}
else
{
MenuItemIndex -= 4;
} */
/* Get the current menu */
psMenuItem = &(psCurrentMenu->psItems[MenuItemIndex]);
LCD_DisplayStringLine(Line0, psMenuItem->pszTitle);
ItemNumb[nMenuLevel] = MenuItemIndex;
}
/* If "DOWN" pushbutton is pressed */
if(MyKey == DOWN)
{
/* Set the Text Color */
LCD_SetTextColor(White);
LCD_DrawRect(IconRect[i][0], IconRect[i][1], 64, 65);
if(i==3)
i=0;
else i++;
/* Set the Text Color */
LCD_SetTextColor(Blue);
LCD_DrawRect(IconRect[i][0], IconRect[i][1], 64, 65);
/* Set the Back Color */
LCD_SetBackColor(Blue);
/* Set the Text Color */
LCD_SetTextColor(White);
/* Test on the MenuItemIndex value before incrementing it */
if(MenuItemIndex==3)
MenuItemIndex=0;
else MenuItemIndex++;
/* Get the current menu */
psMenuItem = &(psCurrentMenu->psItems[MenuItemIndex]);
LCD_DisplayStringLine(Line0, psMenuItem->pszTitle);
ItemNumb[nMenuLevel] = MenuItemIndex;
}
/* If "LEFT" pushbutton is pressed */
if(MyKey == LEFT)
{
/* Set the Text Color */
LCD_SetTextColor(White);
LCD_DrawRect(IconRect[i][0], IconRect[i][1], 64, 65);
if(i==0)
i=3;
else i--;
/* Set the Text Color */
LCD_SetTextColor(Blue);
LCD_DrawRect(IconRect[i][0], IconRect[i][1], 64, 65);
/* Set the Back Color */
LCD_SetBackColor(Blue);
/* Set the Text Color */
LCD_SetTextColor(White);
if(MenuItemIndex==0)
MenuItemIndex=3;
else MenuItemIndex--;
psMenuItem = &psCurrentMenu->psItems[MenuItemIndex];
LCD_DisplayStringLine(Line0, psMenuItem->pszTitle);
ItemNumb[nMenuLevel] = MenuItemIndex;
}
/* If "RIGHT" pushbutton is pressed */
if(MyKey == RIGHT)
{
/* Set the Text Color */
LCD_SetTextColor(White);
LCD_DrawRect(IconRect[i][0], IconRect[i][1], 64, 65);
if(i==3)
i=0;
else i++;
/* Set the Text Color */
LCD_SetTextColor(Blue);
LCD_DrawRect(IconRect[i][0], IconRect[i][1], 64, 65);
/* Set the Back Color */
LCD_SetBackColor(Blue);
/* Set the Text Color */
LCD_SetTextColor(White);
/* Test on the MenuItemIndex value before incrementing it */
if(MenuItemIndex==3)
MenuItemIndex=0;
else MenuItemIndex++;
/* Get the current menu */
psMenuItem = &(psCurrentMenu->psItems[MenuItemIndex]);
LCD_DisplayStringLine(Line0, psMenuItem->pszTitle);
ItemNumb[nMenuLevel] = MenuItemIndex;
}
/* If "SEL" pushbutton is pressed */
if(MyKey == SEL)
{
SelFunc();
IntExtOnOffConfig(ENABLE);
return;
}
}
}
/*******************************************************************************
* Function Name : STM32Intro
* Description : Display the STM32 introduction.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void STM32Intro(void)
{
u32 GPIOD_CRL = GPIOD->CRL, GPIOD_CRH = GPIOD->CRH;
u32 GPIOE_CRL = GPIOE->CRL, GPIOE_CRH = GPIOE->CRH;
u32 GPIOF_CRL = GPIOF->CRL, GPIOF_CRH = GPIOF->CRH;
u32 GPIOG_CRL = GPIOG->CRL, GPIOG_CRH = GPIOG->CRH;
/* Set the Back Color */
LCD_SetBackColor(White);
/* Set the Text Color */
LCD_SetTextColor(Blue);
LCD_SetDisplayWindow(239, 0x13F, 240, 320);
LCD_NORDisplay(ST_LOGO);
Delay(100);
LCD_SetDisplayWindow(239, 0x13F, 240, 320);
LCD_NORDisplay(SlideAddr[0]);
Delay(100);
GPIOD->CRL = GPIOD_CRL;
GPIOD->CRH = GPIOD_CRH;
GPIOE->CRL = GPIOE_CRL;
GPIOE->CRH = GPIOE_CRH;
GPIOF->CRL = GPIOF_CRL;
GPIOF->CRH = GPIOF_CRH;
GPIOG->CRL = GPIOG_CRL;
GPIOG->CRH = GPIOG_CRH;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
}
/*******************************************************************************
* Function Name : HelpFunc
* Description : Display the Help menu.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
/*void HelpFunc(void)
{
IntExtOnOffConfig(DISABLE);
while(ReadKey() != NOKEY)
{
}
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
LCD_SetDisplayWindow(239, 0x13F, 240, 320);
LCD_NORDisplay(HELP);
while(ReadKey() != NOKEY)
{
}
while(ReadKey() == NOKEY)
{
}
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); */
/* Set the Back Color */
//LCD_SetBackColor(Blue);
/* Set the Text Color */
/* LCD_SetTextColor(White);
LCD_DisplayStringLine(Line0, "UP, DOWN, RIGHT and ");
LCD_DisplayStringLine(Line1, "LEFT push-buttons ");
LCD_DisplayStringLine(Line2, "perform circular ");
LCD_DisplayStringLine(Line3, "navigation in the ");
LCD_DisplayStringLine(Line4, "main menu, current ");
LCD_DisplayStringLine(Line5, "menu items. SEL ");
LCD_DisplayStringLine(Line6, "push-button selects ");
LCD_DisplayStringLine(Line7, "the current item. UP");
LCD_DisplayStringLine(Line8, "and DOWN perform ");
LCD_DisplayStringLine(Line9, "vertical navigation.");
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, DISABLE);
while(ReadKey() == NOKEY)
{
}
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
LCD_Clear(White);
DisplayMenu();
IntExtOnOffConfig(ENABLE);
} */
/*******************************************************************************
* Function Name : AboutFunc
* Description : Display the About menu.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void AboutFunc(void)
{
LCD_Clear(White);
IntExtOnOffConfig(DISABLE);
while(ReadKey() != NOKEY)
{
}
/* Set the Back Color */
LCD_SetBackColor(Magenta);
/* Set the Text Color */
LCD_SetTextColor(White);
LCD_ClearLine(Line0);
LCD_DisplayStringLine(Line1, " STM32F10X-DK ");
LCD_DisplayStringLine(Line2, " Demonstration ");
LCD_DisplayStringLine(Line3, " Version 2.0.1 ");
LCD_ClearLine(Line4);
LCD_DisplayStringLine(Line5, " u-easytech Team ");
LCD_DisplayStringLine(Line6, " COPYRIGHT 2008 ");
LCD_DisplayStringLine(Line7, " U-EASYTECH company ");
LCD_ClearLine(Line8);
LCD_DisplayStringLine(Line9, " www.u-easytech.com ");
while(ReadKey() == NOKEY)
{
}
LCD_Clear(White);
DisplayMenu();
IntExtOnOffConfig(ENABLE);
}
/*******************************************************************************
* Function Name : LCD_NORDisplay
* Description : Display a picture from the NOR Flash.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void LCD_NORDisplay(u32 address)
{
u32 GPIOD_CRL = GPIOD->CRL, GPIOD_CRH = GPIOD->CRH;
u32 GPIOE_CRL = GPIOE->CRL, GPIOE_CRH = GPIOE->CRH;
u32 GPIOF_CRL = GPIOF->CRL, GPIOF_CRH = GPIOF->CRH;
u32 GPIOG_CRL = GPIOG->CRL, GPIOG_CRH = GPIOG->CRH;
/* Write/read to/from FSMC SRAM memory *************************************/
/* Enable the FSMC Clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
/* Configure FSMC Bank1 NOR/SRAM2 */
FSMC_NOR_Init();
/* Read NOR memory ID */
FSMC_NOR_ReadID(&NOR_ID);
FSMC_NOR_ReturnToReadMode();
/* Slide n
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -