📄 rfid_lcdmenu.c
字号:
// $Id: rfid_LCDMenu.c,v 1.3 2006/10/12 14:00:54 tprescott Exp $
/*************************************************************
Project : rfid_LCDMenu.c
Date : 9/08/2006
Author : Toby Prescott
Company : Atmel
Comments: AVR Studio GCC
Revisions:
v1.0 - Started written for CodeVision
v2.6 - Clean for WinAVR
*************************************************************/
#include "rfid_LCDMenu.h"
// Declare your global variables here
// *******************************************************************************
// Menu for controlling LCD and Main Board functions
// ******************************************************************************/
void LCDMenu_Display(void)
{
unsigned char correctionFactor, currentPos=0, nextPos=0;
unsigned char tmpContrast, tmpBright, tmpSoundState, tmpReverseState;
tmpContrast = eeprom_read_byte(&contrastVal);
tmpBright = eeprom_read_byte(&brightVal);
tmpSoundState = eeprom_read_byte(&soundState);
tmpReverseState = eeprom_read_byte(&reverseState);
upDate = 0;
uio_Release(); // Wait for button release
while(cButton != IO_F1 && cButton != IO_F2 && cButton != IO_F3 && cButton != IO_F4)
{
// Menu Display
if(currentPos != nextPos || upDate == 0)
{
currentPos = nextPos;
lcd_clear_area(SCRN_LEFT+1,12,SCRN_RIGHT-1,SCRN_BOTTOM-1);
lcd_put_fString(4, 13, PSTR("Contrast"));
lcd_put_fString(4, 22, PSTR("Brightness"));
lcd_put_fString(4, 31, PSTR("Sound"));
lcd_put_fString(4, 40, PSTR("Inverse"));
if(currentPos == 0){lcd_invert_area(3, 12, end_fString_Pos(4,PSTR("Contrast")), 20);}
else if(currentPos == 1){lcd_invert_area(3, 21, end_fString_Pos(4,PSTR("Brightness")), 29);}
else if(currentPos == 2){lcd_invert_area(3, 30, end_fString_Pos(4,PSTR("Sound")), 38);}
else if(currentPos == 3){lcd_invert_area(3, 39, end_fString_Pos(4,PSTR("Inverse")), 47);}
lcd_ConfigDisplay();
lcd_clear_area(end_fString_Pos(4, PSTR("Brightness"))+3,13,SCRN_RIGHT-3,29);
correctionFactor = tmpContrast - 13;
lcd_box(SCRN_RIGHT-53,13,SCRN_RIGHT-3,20);
lcd_fill_area((SCRN_RIGHT-52+correctionFactor),14,SCRN_RIGHT-4,19);
correctionFactor = tmpBright * 5;
lcd_box(SCRN_RIGHT-53,22,SCRN_RIGHT-3,29);
lcd_fill_area((SCRN_RIGHT-52+correctionFactor),23,SCRN_RIGHT-4,28);
lcd_clear_area(end_fString_Pos(4, PSTR("Inverse"))+3,31,SCRN_RIGHT-6,47);
if(tmpSoundState == 1){lcd_put_fString(end_fString_Pos(4, PSTR("Inverse"))+3, 31, PSTR("= On"));}
else if(tmpSoundState == 0){lcd_put_fString(end_fString_Pos(4, PSTR("Inverse"))+3, 31, PSTR("= Off"));}
if(tmpReverseState == 1){lcd_put_fString(end_fString_Pos(4, PSTR("Inverse"))+3, 40, PSTR("= On"));}
else if(tmpReverseState == 0){lcd_put_fString(end_fString_Pos(4, PSTR("Inverse"))+3, 40, PSTR("= Off"));}
lcd_update(SCRN_TOP,SCRN_BOTTOM);
upDate = 1;
}
// end display
uio_Get();
switch(currentPos){
case 0:
if(cButton == IO_RIGHT && tmpContrast < 63)
{
tmpContrast++;
upDate = 0;
cButton=0;
}
else if(cButton == IO_LEFT && tmpContrast > 13)
{
tmpContrast--;
upDate = 0;
cButton=0;
}
else if(cButton == IO_DOWN)
{
nextPos = 1;
//uio_Release(); // Wait for button release
}
if(cButton>0 && cButton<6){uio_Release();}
upDate = 0;
break;
case 1:
if(cButton == IO_RIGHT && tmpBright < 10)
{
tmpBright ++;
upDate = 0;
cButton=0;
}
else if(cButton == IO_LEFT && tmpBright > 0)
{
tmpBright --;
upDate = 0;
cButton=0;
}
else if(cButton == IO_UP)
{
nextPos = 0;
//uio_Release(); // Wait for button release
}
else if(cButton == IO_DOWN)
{
nextPos = 2;
//uio_Release(); // Wait for button release
}
if(cButton>0 && cButton<6){uio_Release();}
upDate = 0;
break;
case 2:
if(cButton == IO_ENTER || cButton == IO_RIGHT || cButton == IO_LEFT)
{
//while(uio_Get() != 0){;} // Wait for button release
if(tmpSoundState == 0){tmpSoundState = 1;}
else {tmpSoundState = 0;}
}
else if(cButton == IO_UP)
{
nextPos = 1;
//while(uio_Get() != 0){;} // Wait for button release
}
else if(cButton == IO_DOWN)
{
nextPos = 3;
//while(uio_Get() != 0){;} // Wait for button release
}
if(cButton>0 && cButton<6){uio_Release();}
upDate = 0;
break;
case 3:
if(cButton == IO_ENTER || cButton == IO_RIGHT || cButton == IO_LEFT)
{
//while(uio_Get() != 0){;} // Wait for button release
if(tmpReverseState == 0)
{
tmpReverseState = 1;
lcd_Write_Display(CMD,DISPLAY_REVERSE);
}
else
{
tmpReverseState = 0;
lcd_Write_Display(CMD,DISPLAY_NORMAL);
}
}
else if(cButton == IO_UP)
{
nextPos = 2;
//while(uio_Get() != 0){;} // Wait for button release
}
else if(cButton == IO_DOWN){;}
if(cButton>0 && cButton<6){uio_Release();}
upDate = 0;
break;
default:
break;
}
eeprom_write_byte(&contrastVal,tmpContrast);
eeprom_write_byte(&brightVal,tmpBright);
eeprom_write_byte(&soundState,tmpSoundState);
eeprom_write_byte(&reverseState,tmpReverseState);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -