|
楼主 |
发表于 2014-5-28 10:38:29
|
显示全部楼层
比如这个也算是个菜单,可以调整一些参数,界面也不难看。
- static void Menu_Screen_Set(void)//屏幕设定
- {
- UINT8 xdata Select=0;
- UINT8 xdata Last_Select=0;
- bit RePaint_Menu=1;
-
- UINT8 xdata str[4];
- UINT8 xdata tmp1=Roms[0];
- UINT8 xdata tmp2=Roms[1];
- UINT8 xdata tmp3=Roms[31];
- bit RePaint=1;//是否重画整个菜单项
- while(1)
- {
- if(RePaint==1)
- {
- ST7565_Paint_RectangleFill(0,0,64,128,0);//清屏
- ST7565_Paint_Rectangle(0,8,64,112,1);//边框
- ST7565_Paint_HLine(13,8,112,1);//横线
- ST7565_Paint_MixStr(1,40,"屏幕设定",0);
- ST7565_Paint_MixStr(18,28,"屏幕对比度",0);
- ST7565_Paint_MixStr(32,19,"关闭时间 时 分",0);
- ST7565_Paint_MixStr(46,22,"数码管对比度",0);
- ST7565_Paint_HLine(30,88,12,1);//
- ST7565_Paint_HLine(44,67,6,1);//
- ST7565_Paint_HLine(44,85,12,1);//
- ST7565_Paint_HLine(58,94,12,1);//
- }
- if(Select==0 || Last_Select==0 || RePaint_Menu==1)//选择了第1项
- {
- sprintf(str,"%02d", (UINT16)tmp1);//对比度
- ST7565_Paint_MixStr(18,88,str,(Select==0)?1:0);
- }
-
- if(Select==1 || Last_Select==1 || RePaint_Menu==1)//选择了第1项
- {
- sprintf(str,"%01d", (UINT16)(tmp2/60));//
- ST7565_Paint_MixStr(32,67,str,(Select==1)?1:0);//时
- sprintf(str,"%02d", (UINT16)(tmp2%60));//
- ST7565_Paint_MixStr(32,85,str,(Select==1)?1:0);//分
- }
-
- if(Select==2 || Last_Select==2 || RePaint_Menu==1)//选择了第1项
- {
- sprintf(str,"%02d", (UINT16)(tmp3));//
- ST7565_Paint_MixStr(46,94,str,(Select==2)?1:0);//数码管对比度
- }
-
- RePaint=0;
- Last_Select=Select;//保存上次的选择
- ST7565_Paint_Push_Data();//刷新显示
- //键盘
- Key_Scan();//扫描键盘
- while(Key_Trg==0)//等待按一个键
- {
- Key_Scan();//扫描键盘
- }
- if(Key_Trg & Key_Cancel) break;
- if(Key_Trg & Key_Select)
- {
- Select>1?Select=0:Select++;
- }
- if(Key_Trg & Key_plus)
- {
- if(Select==0) (tmp1>51)?(tmp1=25):(tmp1++);//对比度
- if(Select==1) (tmp2>254)?(tmp2=1):(tmp2++);//关屏时间
- if(Select==2) (tmp3>6)?(tmp3=0):(tmp3++);
- }
- if(Key_Trg & Key_Minus)
- {
- if(Select==0) (tmp1<26)?(tmp1=52):(tmp1--);//对比度
- if(Select==1) (tmp2<2)?(tmp2=255):(tmp2--);//关屏时间
- if(Select==2) (tmp3<1)?(tmp3=7):(tmp3--);
- }
- if(Key_Trg & Key_Ok)
- {
- Roms[0]=tmp1;//对比度的值
- Roms[1]=tmp2;//关屏时间的值
- Roms[31]=tmp3;
- SaveOfSetting();//保存设置
- break;
- }
- ST7565_Set_Contrast(tmp1);//即时做出对比度的设定
- TM1638_SetContrast(tmp3);//立即更改TM1638的对比度
- }
- }
复制代码
|
|