完整代碼下載地址:http://www.zg4o1577.cn/f/29782212PDA.rar
#include <stm32f10x_lib.h>
#include "app.h"
#include "sd.h"
#include "ff.h"
#include "touch.h"
#include "ui.h"
#include "delay.h"
#include "ILI9320.h"
#include "rtc.h"http://時間設置,屏保用
#include "picdecoder.h"http://顯示圖標用
#include "theme.h"http://顯示圖標用
#include "string.h"http://SD卡信息用到
#include "w25x16.h"http://關于用到
#include "adc.h"http://引用ADC,CPU溫度用
/////////////////////////////////////////////
//此文件實現小功能
//時間日期設置
//SD卡
//關于
//////////////////////////////////////////////
//檢查SD卡是否存在
u8 SD_Sta;//SD卡存在狀態,存在為1,不存在為0
void Check_SD(void)
{
u8 sta=3;//初始數值,默認SD卡存在
RECHECK:
if(SD_Init()!=0)
{
Windows(10,110,230,210,"注意——SD卡錯誤",12);//顯示窗體,標題欄高18
show_string(62,136,158,"未檢測到SD卡,這將導致無法使用與SD卡相關的功能!",12,color(0,0,0));//文本框高度28,文本框長180
show_string(62,160,158,"確認不使用SD卡嗎?",12,color(0,0,0));//文本框高度28,文本框長180
Button(20,180,68,204,UNPRESS,"不使用",36,12);//顯示是按鈕
Button(172,180,220,204,UNPRESS,"使用",24,12);//顯示否按鈕
show_ico(15,133,59,177,sigh.addr,sigh.size);//顯示圖標
sta=0;
}
else
{
SD_Sta=1;//SD卡存在標志
f_mount(0,&fatfs);
}
while(sta==0)
{
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(20,180,68,204))//((Pen_Point.x0>20)&&(Pen_Point.x0<68))&&((Pen_Point.y0>180)&&(Pen_Point.y0<204)))
sta=1;
else if(((Pen_Point.x0>172)&&(Pen_Point.x0<220))&&((Pen_Point.y0>180)&&(Pen_Point.y0<204)))
sta=2;
else sta=0;
if(sta==1)Button(20,180,68,204,PRESS,"不使用",36,12);//顯示是按鈕
else if(sta==2)Button(172,180,220,204,PRESS,"使用",24,12);//顯示否按鈕
else if(sta==0)
{
Button(20,180,68,204,UNPRESS,"不使用",36,12);//顯示是按鈕
Button(172,180,220,204,UNPRESS,"使用",24,12);//顯示否按鈕
}
Delay_us(50);
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
}
if(sta==2)goto RECHECK;//選擇否
else if(sta==1)SD_Sta=0;//選擇是,SD標志為SD卡沒檢測到
}
Creat_Readme();//生成Readme文件
}
//刷新SD卡
//成功返回1,失敗返回0
u8 Reflash_SD(void)
{
u8 sta=0;
if(SD_Sta==0)
{
Windows(10,122,230,198,"請插入SD卡",12);//顯示窗體,標題欄高18
show_string(42,148,158,"是否插入SD卡以使用此功能?",12,color(0,0,0));//文本框高度28,文本框長180
Button(20,168,68,192,UNPRESS,"是(Y)",30,12);//顯示是按鈕
Button(172,168,220,192,UNPRESS,"否(N)",30,12);//顯示否按鈕
while(sta==0)
{
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(20,168,68,192))//((Pen_Point.x0>20)&&(Pen_Point.x0<68))&&((Pen_Point.y0>168)&&(Pen_Point.y0<192)))
sta=1;
else if(Is_In_Area(172,168,220,192))//((Pen_Point.x0>172)&&(Pen_Point.x0<220))&&((Pen_Point.y0>168)&&(Pen_Point.y0<192)))
sta=2;
else sta=0;
if(sta==1)Button(20,168,68,192,PRESS,"是(Y)",30,12);//顯示是按鈕
else if(sta==2)Button(172,168,220,192,PRESS,"否(N)",30,12);//顯示否按鈕
else if(sta==0)
{
Button(20,168,68,192,UNPRESS,"是(Y)",30,12);//顯示是按鈕
Button(172,168,220,192,UNPRESS,"否(N)",30,12);//顯示否按鈕
}
Delay_us(50);
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
}
if(sta==1)Check_SD();
else if(sta==2)return 0;//選擇是,SD標志為SD卡沒檢測到
}
}
return SD_Sta;
}
//時間設置UI
#include "rtc.h"
extern const u8 mon_date[12];//引用月份號數數據表
void Adjust_Time(void)
{
u16 year;
u8 month,day,hour,minutes,secon;
u8 key_sta=0;
u32 count=0;
Get_Time();
year=time.year;
month=time.month;
day=time.day;
hour=time.hour;
minutes=time.minutes;
secon=time.secon;
Windows(10,88,230,232,"請設定系統時間",12);
Hole(110,125,138,139);//年孔
show_nums(112,127,year,4,12,color(0,0,0),0);
show_string(139,127,12,"年",12,color(0,0,0));
Hole(150,125,166,139);//月孔
show_nums(152,127,month,2,12,color(0,0,0),0);
show_string(167,127,12,"月",12,color(0,0,0));
Hole(178,125,194,139);//日孔
show_nums(180,127,day,2,12,color(0,0,0),0);
show_string(195,127,12,"日",12,color(0,0,0));
Hole(110,169,126,183);//時孔
show_nums(112,171,hour,2,12,color(0,0,0),0);
show_string(127,171,12,":",12,color(0,0,0));
Hole(138,169,154,183);//分孔
show_nums(140,171,minutes,2,12,color(0,0,0),0);
show_string(155,171,12,":",12,color(0,0,0));
Hole(166,169,182,183);//秒孔
show_nums(168,171,secon,2,12,color(0,0,0),0);
//顯示按鈕(日期)
Button_Up(117,113,131,123,UNPRESS);
Button_Up(150,113,166,123,UNPRESS);
Button_Up(178,113,194,123,UNPRESS);
Button_Down(117,140,131,151,UNPRESS);
Button_Down(150,140,166,151,UNPRESS);
Button_Down(178,140,194,151,UNPRESS);
//顯示按鈕(時間)
Button_Up(110,157,126,167,UNPRESS);
Button_Up(138,157,154,167,UNPRESS);
Button_Up(166,157,182,167,UNPRESS);
Button_Down(110,184,126,195,UNPRESS);
Button_Down(138,184,154,195,UNPRESS);
Button_Down(166,184,182,195,UNPRESS);
//顯示按鈕確定,取消
Button(20,202,68,226,UNPRESS,"確定",24,12);//顯示是按鈕
Button(172,202,220,226,UNPRESS,"取消",24,12);//顯示否按鈕
//顯示帶陰影時鐘一個
show_clock_app(61,155,40,hour,minutes,secon,color(255,255,255));
show_clock_app(60,154,40,hour,minutes,secon,color(0x40,0x40,0x40));
while((key_sta!=13)&&(key_sta!=14))
{
Pen_Point.x0=0;
Pen_Point.y0=0;
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(117,113,131,123))key_sta=1;//((Pen_Point.x0>117)&&(Pen_Point.x0<131))&&(Pen_Point.y0>113)&&(Pen_Point.y0<123))key_sta=1;//年上
else if(Is_In_Area(117,140,131,151))key_sta=2;//((Pen_Point.x0>117)&&(Pen_Point.x0<131))&&(Pen_Point.y0>140)&&(Pen_Point.y0<151))key_sta=2;//年下
else if(Is_In_Area(150,113,166,123))key_sta=3;//((Pen_Point.x0>150)&&(Pen_Point.x0<166))&&(Pen_Point.y0>113)&&(Pen_Point.y0<123))key_sta=3;//月上
else if(Is_In_Area(150,140,166,151))key_sta=4;//((Pen_Point.x0>150)&&(Pen_Point.x0<166))&&(Pen_Point.y0>140)&&(Pen_Point.y0<151))key_sta=4;//月下
else if(Is_In_Area(178,113,194,123))key_sta=5;//((Pen_Point.x0>178)&&(Pen_Point.x0<194))&&(Pen_Point.y0>113)&&(Pen_Point.y0<123))key_sta=5;//日上
else if(Is_In_Area(178,140,194,151))key_sta=6;//((Pen_Point.x0>178)&&(Pen_Point.x0<194))&&(Pen_Point.y0>140)&&(Pen_Point.y0<151))key_sta=6;//日下
else if(Is_In_Area(110,157,126,167))key_sta=7;//((Pen_Point.x0>110)&&(Pen_Point.x0<126))&&(Pen_Point.y0>157)&&(Pen_Point.y0<167))key_sta=7;//時上
else if(Is_In_Area(110,184,126,195))key_sta=8;//((Pen_Point.x0>110)&&(Pen_Point.x0<126))&&(Pen_Point.y0>184)&&(Pen_Point.y0<195))key_sta=8;//時下
else if(Is_In_Area(138,157,154,167))key_sta=9;//((Pen_Point.x0>138)&&(Pen_Point.x0<154))&&(Pen_Point.y0>157)&&(Pen_Point.y0<167))key_sta=9;//分上
else if(Is_In_Area(138,184,154,195))key_sta=10;//((Pen_Point.x0>138)&&(Pen_Point.x0<154))&&(Pen_Point.y0>184)&&(Pen_Point.y0<195))key_sta=10;//分下
else if(Is_In_Area(166,157,182,167))key_sta=11;//((Pen_Point.x0>166)&&(Pen_Point.x0<182))&&(Pen_Point.y0>157)&&(Pen_Point.y0<167))key_sta=11;//秒上
else if(Is_In_Area(166,184,182,195))key_sta=12;//((Pen_Point.x0>166)&&(Pen_Point.x0<182))&&(Pen_Point.y0>184)&&(Pen_Point.y0<195))key_sta=12;//秒下
else if(Is_In_Area(20,202,68,226))key_sta=13;//((Pen_Point.x0>20)&&(Pen_Point.x0<68))&&(Pen_Point.y0>202)&&(Pen_Point.y0<226))key_sta=13;//確定
else if(Is_In_Area(172,202,220,226))key_sta=14;//((Pen_Point.x0>172)&&(Pen_Point.x0<220))&&(Pen_Point.y0>202)&&(Pen_Point.y0<226))key_sta=14;//取消
else key_sta=0;
//顯示按鍵狀態
if(key_sta==1)
{
Button_Up(117,113,131,123,PRESS);
year++;
if(year>2100)year=2000;
}else Button_Up(117,113,131,123,UNPRESS);
if(key_sta==2)
{
Button_Down(117,140,131,151,PRESS);
year--;
if(year<2000)year=2100;
}else Button_Down(117,140,131,151,UNPRESS);
if(key_sta==3)
{
Button_Up(150,113,166,123,PRESS);
month++;
if(month>12)month=1;
}else Button_Up(150,113,166,123,UNPRESS);
if(key_sta==4)
{
Button_Down(150,140,166,151,PRESS);
month--;
if(month<1)month=12;
}else Button_Down(150,140,166,151,UNPRESS);
if(key_sta==5)
{
Button_Up(178,113,194,123,PRESS);
day++;
if(day>28)
{
if(runnian(year))
{
if(month==2)
{
if(day>(mon_date[month-1]+1))day=1;
}
else if(day>mon_date[month-1])day=1;
}
else if(day>mon_date[month-1])day=1;
}
}else Button_Up(178,113,194,123,UNPRESS);
if(key_sta==6)
{
Button_Down(178,140,194,151,PRESS);
day--;
if(day<1)
{
if(runnian(year))
{
if(month==2)day=29;
else day=mon_date[month-1];
}
else day=mon_date[month-1];
}
}else Button_Down(178,140,194,151,UNPRESS);
if(key_sta==7)
{
Button_Up(110,157,126,167,PRESS);
hour++;
if(hour>23)hour=0;
}else Button_Up(110,157,126,167,UNPRESS);
if(key_sta==8)
{
Button_Down(110,184,126,195,PRESS);
hour--;
if(hour>23)hour=23;
}else Button_Down(110,184,126,195,UNPRESS);
if(key_sta==9)
{
Button_Up(138,157,154,167,PRESS);
minutes++;
if(minutes>59)minutes=0;
}else Button_Up(138,157,154,167,UNPRESS);
if(key_sta==10)
{
Button_Down(138,184,154,195,PRESS);
minutes--;
if(minutes>59)minutes=59;
}else Button_Down(138,184,154,195,UNPRESS);
if(key_sta==11)
{
Button_Up(166,157,182,167,PRESS);
secon++;
if(secon>59)secon=0;
}else Button_Up(166,157,182,167,UNPRESS);
if(key_sta==12)
{
Button_Down(166,184,182,195,PRESS);
secon--;
if(secon>59)secon=59;
}else Button_Down(166,184,182,195,UNPRESS);
if(key_sta==13)Button(20,202,68,226,PRESS,"確定",24,12);//顯示是按鈕
else Button(20,202,68,226,UNPRESS,"確定",24,12);//顯示是按鈕
if(key_sta==14)Button(172,202,220,226,PRESS,"取消",24,12);//顯示否按鈕
else Button(172,202,220,226,UNPRESS,"取消",24,12);//顯示否按鈕
//進入延時循環之前先刷新一次顯示,避免還沒進入延時循環就松開筆
//刷新顯示
clear(112,127,136,137,color(255,255,255));//年孔
show_nums(112,127,year,4,12,color(0,0,0),0);
clear(152,127,164,137,color(255,255,255));//月孔
show_nums(152,127,month,2,12,color(0,0,0),0);
clear(180,127,192,137,color(255,255,255));//日孔
show_nums(180,127,day,2,12,color(0,0,0),0);
clear(112,171,124,181,color(255,255,255));//時孔
show_nums(112,171,hour,2,12,color(0,0,0),0);
clear(140,171,152,181,color(255,255,255));//分孔
show_nums(140,171,minutes,2,12,color(0,0,0),0);
clear(168,171,180,181,color(255,255,255));//秒孔
show_nums(168,171,secon,2,12,color(0,0,0),0);
while(T_PEN==0)//還在按下
{
if(count<300000)
{
Delay_us(1);//遞加延時設置
count++;
}
else
{
Delay_ms(100);
switch(key_sta)
{
case 1:
{
year++;
if(year>2100)year=2000;
}break;
case 2:
{
year--;
if(year<2000)year=2100;
}break;
case 3:
{
month++;
if(month>12)month=1;
}break;
case 4:
{
month--;
if(month<1)month=12;
}break;
case 5:
{
day++;
if(day>28)
{
if(runnian(year))
{
if(month==2)
{
if(day>(mon_date[month-1]+1))day=1;
}
else if(day>mon_date[month-1])day=1;
}
else if(day>mon_date[month-1])day=1;
}
}break;
case 6:
{
day--;
if(day<1)
{
if(runnian(year))
{
if(month==2)day=29;
else day=mon_date[month-1];
}
else day=mon_date[month-1];
}
}break;
case 7:
{
hour++;
if(hour>23)hour=0;
}break;
case 8:
{
hour--;
if(hour>23)hour=23;
}break;
case 9:
{
minutes++;
if(minutes>59)minutes=0;
}break;
case 10:
{
minutes--;
if(minutes>59)minutes=59;
}break;
case 11:
{
secon++;
if(secon>59)secon=0;
}break;
case 12:
{
secon--;
if(secon>59)secon=59;
}break;
}
//刷新顯示
clear(112,127,136,137,color(255,255,255));//年孔
show_nums(112,127,year,4,12,color(0,0,0),0);
clear(152,127,164,137,color(255,255,255));//月孔
show_nums(152,127,month,2,12,color(0,0,0),0);
clear(180,127,192,137,color(255,255,255));//日孔
show_nums(180,127,day,2,12,color(0,0,0),0);
clear(112,171,124,181,color(255,255,255));//時孔
show_nums(112,171,hour,2,12,color(0,0,0),0);
clear(140,171,152,181,color(255,255,255));//分孔
show_nums(140,171,minutes,2,12,color(0,0,0),0);
clear(168,171,180,181,color(255,255,255));//秒孔
show_nums(168,171,secon,2,12,color(0,0,0),0);
}
}
//刷新顯示時鐘
clear(20,114,101,195,color(0xd4,0xd0,0xc8));//清除時鐘位置
show_clock_app(61,155,40,hour,minutes,secon,color(255,255,255));
show_clock_app(60,154,40,hour,minutes,secon,color(0x40,0x40,0x40));
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
count=0;
//還原按鍵
//顯示按鈕(日期)
Button_Up(117,113,131,123,UNPRESS);
Button_Up(150,113,166,123,UNPRESS);
Button_Up(178,113,194,123,UNPRESS);
Button_Down(117,140,131,151,UNPRESS);
Button_Down(150,140,166,151,UNPRESS);
Button_Down(178,140,194,151,UNPRESS);
//顯示按鈕(時間)
Button_Up(110,157,126,167,UNPRESS);
Button_Up(138,157,154,167,UNPRESS);
Button_Up(166,157,182,167,UNPRESS);
Button_Down(110,184,126,195,UNPRESS);
Button_Down(138,184,154,195,UNPRESS);
Button_Down(166,184,182,195,UNPRESS);
//顯示按鈕確定,取消
Button(20,202,68,226,UNPRESS,"確定",24,12);//顯示是按鈕
Button(172,202,220,226,UNPRESS,"取消",24,12);//顯示否按鈕
}
}
if(key_sta==13)Time_Set(year,month,day,hour,minutes,secon);//按下確定則設置時間
}
//格式化SD卡
void Format_SD(void)
{
u8 key=0;
Pen_Point.x0=0;
Pen_Point.y0=0;
Windows(9,110,229,208,"格式化SD卡……",12);//顯示窗體
show_ico(19,136,51,168,question.addr,question.size);
show_string(59,140,160,"警告:格式化操作將刪除SD卡中的所有數據,是否繼續?",12,color(0,0,0));
Button(19,176,67,200,UNPRESS,"是(Y)",30,12);//顯示是按鈕
Button(171,176,219,200,UNPRESS,"否(N)",30,12);//顯示否按鈕
while(key==0)
{
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(19,176,67,200))key=1;//((Pen_Point.x0>19)&&(Pen_Point.x0<67))&&((Pen_Point.y0>176)&&(Pen_Point.y0<200)))key=1;
else if(Is_In_Area(171,176,219,200))key=2;//((Pen_Point.x0>171)&&(Pen_Point.x0<219))&&((Pen_Point.y0>176)&&(Pen_Point.y0<200)))key=2;
else key=0;
if(key==1)Button(19,176,67,200,PRESS,"是(Y)",30,12);//顯示是按鈕
else Button(19,176,67,200,UNPRESS,"是(Y)",30,12);//顯示是按鈕
if(key==2)Button(171,176,219,200,PRESS,"否(N)",30,12);//顯示否按鈕
else Button(171,176,219,200,UNPRESS,"否(N)",30,12);//顯示否按鈕
Delay_us(50);
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
}
}
if(key==1)
{
key=0;
Windows(9,110,229,208,"格式化SD卡……",12);//顯示窗體
show_ico(19,136,51,168,sigh.addr,sigh.size);
show_string(59,136,160,"警告:正在格式化SD卡,請勿移除SD卡或者切斷電源,此過程大約持續1分鐘……",12,color(0,0,0));
Button(101,176,137,200,INVALID,"取消",24,12);//顯示取消按鈕,居中
if(f_mkfs(0,0,0)==FR_OK)
{
Windows(9,110,229,208,"格式化SD卡……",12);//顯示窗體
show_ico(19,136,51,168,right.addr,right.size);
show_string(59,146,160,"格式化成功!",12,color(0,0,0));
Button(101,176,137,200,UNPRESS,"確定",24,12);//顯示取消按鈕,居中
f_mount(0,NULL);
f_mount(0,&fatfs);
}
else
{
Windows(9,110,229,208,"格式化SD卡……",12);//顯示窗體
show_ico(19,136,51,168,wrong.addr,wrong.size);
show_string(59,146,160,"格式化失敗!",12,color(0,0,0));
Button(101,176,137,200,UNPRESS,"確定",24,12);//顯示取消按鈕,居中
}
while(key==0)
{
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(101,176,137,200))key=1;//((Pen_Point.x0>101)&&(Pen_Point.x0<137))&&((Pen_Point.y0>176)&&(Pen_Point.y0<200)))key=1;
else key=0;
if(key==1)Button(101,176,137,200,PRESS,"確定",24,12);//顯示取消按鈕,居中
else Button(101,176,137,200,UNPRESS,"確定",24,12);//顯示取消按鈕,居中
Delay_us(50);
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
}
}
}
}
//SD卡信息
const u8 sd_note[]={"SD卡沒檢測到,暫時無法顯示相關信息,請插入SD卡后再試!"};
void SD_Card(void)
{
FATFS *fs;
u8 key=0;
char temp[40];
u32 total_size=0;
u32 free_size=0;
u32 used_size=0;
u32 i;
BEGIN:
key=0;
Pen_Point.x0=0;
Pen_Point.y0=0;
if(Reflash_SD())
{
//獲取容量信息
f_getfree("0:",&free_size,&fs);//獲取可用容量
free_size=free_size*(fs->csize)*512;//得到可用容量
total_size=((fs->n_fatent-2)*fs->csize)*512;//得到總容量
used_size=total_size-free_size;//得到已用容量
Windows(0,0,239,319,"SD卡屬性",12);//顯示窗體
Button(221,3,235,16,UNPRESS,"×",12,12);//關閉按鈕
Button(20,269,104,293,UNPRESS,"格式化SD卡",60,12);//顯示是按鈕
Button(135,269,219,293,UNPRESS,"安全卸載SD卡",72,12);//顯示否按鈕
Hole(8,26,60,78);
show_ico(10,28,58,76,drive.addr,drive.size);//顯示驅動器圖標
show_string(68,36,200,"SD卡狀態:",12,color(0,0,0));
show_string(68,52,200,"已裝載!",12,color(0,0,0));
_line_(9,82,229,82,color(0x80,0x80,0x80));
strcpy(temp,"SD卡類型:");//復制SD卡類型
switch(SD_Type)
{
case SD_TYPE_ERR:strcat(temp,"未知類型");break;
case SD_TYPE_MMC:strcat(temp,"MMC卡");break;
case SD_TYPE_V1:strcat(temp,"SD 1.0卡");break;
case SD_TYPE_V2:strcat(temp,"SD 2.0卡");break;
case SD_TYPE_V2HC:strcat(temp,"SD 2.0高速卡");break;
}
show_string(10,86,220,(u8*)temp,12,color(0,0,0));//顯示SD卡類型
//顯示卡的文件系統類型
strcpy(temp,"文件系統類型:");
switch(fs->fs_type)
{
case 0:strcat(temp,"未知類型");break;
case FS_FAT12:strcat(temp,"FAT12");break;
case FS_FAT16:strcat(temp,"FAT16");break;
case FS_FAT32:strcat(temp,"FAT32");break;
}
show_string(10,102,220,(u8*)temp,12,color(0,0,0));
//顯示容量
_line_(9,118,229,118,color(0x80,0x80,0x80));
//顯示卡的已用容量信息
show_string(10,122,60,"已用容量:",12,color(0,0,0));
i=show_nums(70,122,used_size,10,12,color(0,0,0),1);
show_string((10+60+i*6),122,24,"字節",12,color(0,0,0));
//顯示卡的未用容量信息
show_string(10,138,60,"可用容量:",12,color(0,0,0));
i=show_nums(70,138,free_size,10,12,color(0,0,0),1);
show_string((10+60+i*6),138,24,"字節",12,color(0,0,0));
//顯示總容量
_line_(9,154,229,154,color(0x80,0x80,0x80));
show_string(10,158,48,"總容量:",12,color(0,0,0));
i=show_nums(58,158,total_size,10,12,color(0,0,0),1);
show_string((10+48+i*6),158,24,"字節",12,color(0,0,0));
//顯示進度條百分比UI
show_string(10,174,48,"已使用:",12,color(0,0,0));
Progress_Bar(9,190,220,used_size,total_size,1);
show_string(10,208,48,"剩余:",12,color(0,0,0));
Progress_Bar(9,224,220,free_size,total_size,1);
while(key==0)
{
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(20,269,104,293))key=1;//((Pen_Point.x0>20)&&(Pen_Point.x0<104))&&((Pen_Point.y0>269)&&(Pen_Point.y0<293)))key=1;
else if(Is_In_Area(135,269,219,293))key=2;//((Pen_Point.x0>135)&&(Pen_Point.x0<219))&&((Pen_Point.y0>269)&&(Pen_Point.y0<293)))key=2;
else if(Is_In_Area(221,3,235,16))key=3;//((Pen_Point.x0>221)&&(Pen_Point.x0<235))&&((Pen_Point.y0>3)&&(Pen_Point.y0<16)))key=3;
else key=0;
if(key==3)Button(221,3,235,16,PRESS,"×",12,12);//關閉按鈕
else Button(221,3,235,16,UNPRESS,"×",12,12);//關閉按鈕
if(key==1)Button(20,269,104,293,PRESS,"格式化SD卡",60,12);//顯示是按鈕
else Button(20,269,104,293,UNPRESS,"格式化SD卡",60,12);//顯示是按鈕
if(key==2)Button(135,269,219,293,PRESS,"安全卸載SD卡",72,12);//顯示否按鈕
else Button(135,269,219,293,UNPRESS,"安全卸載SD卡",72,12);//顯示否按鈕
Delay_us(50);
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
}
}
if(key==1)
{
key=0;
goto FORMAT;
}
if(key==2)
{
key=0;
Pen_Point.x0=0;
Pen_Point.y0=0;
goto UNMOUNT;
}
if(key==3)goto OUT;
FORMAT: Format_SD();
goto BEGIN;
UNMOUNT:
if(f_mount(0,NULL)==FR_OK)
{
Windows(9,110,229,208,"安全卸載SD卡",12);//顯示窗體
show_ico(19,136,51,168,right.addr,right.size);
show_string(59,146,160,"請拔出SD卡!",12,color(0,0,0));
Button(101,176,137,200,UNPRESS,"確定",24,12);//顯示取消按鈕,居中
while(key==0)
{
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(101,176,137,200))key=1;//((Pen_Point.x0>101)&&(Pen_Point.x0<137))&&((Pen_Point.y0>176)&&(Pen_Point.y0<200)))key=1;
else key=0;
if(key==1)Button(101,176,137,200,PRESS,"確定",24,12);//顯示取消按鈕,居中
else Button(101,176,137,200,UNPRESS,"確定",24,12);//顯示取消按鈕,居中
Delay_us(50);
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
}
}
if(key)
{
key=0;
Pen_Point.x0=0;
Pen_Point.y0=0;
SD_Sta=0;//標記SD卡移除標志
goto BEGIN1;
}
}
}
else
{
BEGIN1:
Windows(0,0,239,319,"SD卡屬性",12);//顯示窗體
Button(221,3,235,16,UNPRESS,"×",12,12);//關閉按鈕
Hole(8,26,60,78);
show_ico(10,28,58,76,drive.addr,drive.size);//顯示驅動器圖標
show_string(68,36,200,"SD卡狀態:",12,color(0,0,0));
show_string(68,52,200,"未裝載!",12,color(0,0,0));
_line_(9,82,229,82,color(0x80,0x80,0x80));
show_string(9,86,216,"請插入SD卡以獲取相關信息!",16,color(0,0,0));
Button(89,269,149,293,UNPRESS,"加載SD卡",48,12);
while(key==0)
{
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(89,269,149,293))key=1;//((Pen_Point.x0>89)&&(Pen_Point.x0<149))&&((Pen_Point.y0>269)&&(Pen_Point.y0<293)))key=1;
else if(Is_In_Area(221,3,235,16))key=2;//((Pen_Point.x0>221)&&(Pen_Point.x0<235))&&((Pen_Point.y0>3)&&(Pen_Point.y0<16)))key=2;
else key=0;
if(key==1)Button(89,269,149,293,PRESS,"加載SD卡",48,12);
else Button(89,269,149,293,UNPRESS,"加載SD卡",48,12);
if(key==2)Button(221,3,235,16,PRESS,"×",12,12);//關閉按鈕
else Button(221,3,235,16,UNPRESS,"×",12,12);//關閉按鈕
Delay_us(50);
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
}
}
if(key==1)goto BEGIN;
if(key==2)goto OUT;
}
OUT:
Pen_Point.x0=0;
Pen_Point.y0=0;
}
//關于
extern u16 DeviceCode;
extern u8 opera_s,opera_m,opera_h;//引用開機時間統計
extern u8 reflash;//引用rtc更新標志
void About(void)
{
u8 key=0;
float temp;
u8 lon;
Windows(0,0,239,319,"系統屬性",12);
Button(221,3,235,16,UNPRESS,"×",12,12);//關閉按鈕
//顯示控制器信息
_line_(9,26,229,26,color(0x80,0x80,0x80));
_line_(9,26,9,134,color(0x80,0x80,0x80));
_line_(9,134,229,134,color(0x80,0x80,0x80));
_line_(229,26,229,134,color(0x80,0x80,0x80));
clear(19,20,55,32,color(0xd4,0xd0,0xc8));
show_string(19,20,200,"控制器",12,color(0,0,0));
show_string(19,36,200,"控制器型號:STM32F103RBT6",12,color(0,0,0));
show_string(19,52,200,"內核:Cortex-M3",12,color(0,0,0));
show_string(19,68,200,"主頻:72MHz",12,color(0,0,0));
show_string(19,84,200,"RAM:20KB",12,color(0,0,0));
show_string(19,100,200,"ROM:128KB",12,color(0,0,0));
show_string(19,116,200,"控制器溫度:",12,color(0,0,0));
//顯示顯示器信息
_line_(9,146,229,146,color(0x80,0x80,0x80));
_line_(9,146,9,206,color(0x80,0x80,0x80));
_line_(9,206,229,206,color(0x80,0x80,0x80));
_line_(229,146,229,206,color(0x80,0x80,0x80));
clear(19,140,55,152,color(0xd4,0xd0,0xc8));
show_string(19,140,200,"顯示器",12,color(0,0,0));
show_string(19,156,200,"TFT LCD ID:",12,color(0,0,0));
show_nums(91,156,DeviceCode,10,12,color(0,0,0),1);
show_string(19,172,200,"有效色素:64K",12,color(0,0,0));
show_string(19,188,200,"像素:240×320",12,color(0,0,0));
//顯示顯示器信息
_line_(9,218,229,218,color(0x80,0x80,0x80));
_line_(9,218,9,278,color(0x80,0x80,0x80));
_line_(9,278,229,278,color(0x80,0x80,0x80));
_line_(229,218,229,278,color(0x80,0x80,0x80));
clear(19,212,115,224,color(0xd4,0xd0,0xc8));
show_string(19,212,200,"字庫、圖標儲存器",12,color(0,0,0));
show_string(19,228,200,"型號:Winbond 25Q64BVS1G-1022",12,color(0,0,0));
show_string(19,244,200,"容量:8MB",12,color(0,0,0));
show_string(19,260,200,"設備ID:",12,color(0,0,0));
show_nums(67,260,SPI_Flash_ReadID(),10,12,color(0,0,0),1);
//顯示開機時間
_line_(9,290,229,290,color(0x80,0x80,0x80));
_line_(9,290,9,314,color(0x80,0x80,0x80));
_line_(9,314,229,314,color(0x80,0x80,0x80));
_line_(229,290,229,314,color(0x80,0x80,0x80));
clear(19,280,67,294,color(0xd4,0xd0,0xc8));
show_string(19,284,200,"開機時間",12,color(0,0,0));
while(key==0)
{
if(reflash)
{
reflash=0;
temp=Get_Temp();
//顯示CPU溫度
clear(91,116,200,128,color(0xd4,0xd0,0xc8));
lon=show_nums(91,116,(u8)temp,10,12,color(0,0,0),1);
show_string((91+lon*6),116,6,".",12,color(0,0,0));
show_nums((97+lon*6),116,(u8)((temp-(u8)temp)*100),2,12,color(0,0,0),0);
show_string((97+lon*6+12),116,12,"℃",12,color(0,0,0));
//顯示開機時間
clear(19,297,73,309,color(0xd4,0xd0,0xc8));
show_string(19,297,200," : : ",12,color(0,0,0));
show_nums(19,297,opera_h,3,12,color(0,0,0),0);
show_nums(43,297,opera_m,2,12,color(0,0,0),0);
show_nums(61,297,opera_s,2,12,color(0,0,0),0);
}
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(221,3,235,16))key=1;//((Pen_Point.x0>221)&&(Pen_Point.x0<235))&&((Pen_Point.y0>3)&&(Pen_Point.y0<16)))key=1;
else key=0;
if(key)Button(221,3,235,16,PRESS,"×",12,12);//關閉按鈕
else Button(221,3,235,16,UNPRESS,"×",12,12);//關閉按鈕
Delay_us(50);
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
}
}
}
//屏保延時
u8 Scr_Delay=0;//屏保延時
u8 Scr_Count;//屏保計數
u8 Scr_Flag=0;//屏保啟動標志
void Screen_Saver_Delay(void)
{
u8 key=0;
u32 i=0;
u8 temp=Scr_Delay;
//記錄用
FIL fil;
UINT byteleft;
Windows(9,89,229,229,"屏保延時",12);
show_string(19,117,220,"請設定屏保啟動延時,0為不啟動屏保。",12,color(0,0,0));
show_string(19,155,220,"設定延時為:",12,color(0,0,0));
show_string(115,155,220,"秒",12,color(0,0,0));
Hole(91,153,113,169);
Button_Up(94,140,110,151,UNPRESS);
Button_Down(94,170,110,181,UNPRESS);
Button(19,195,67,219,UNPRESS,"確定",24,12);//顯示是按鈕
Button(171,195,219,219,UNPRESS,"取消",24,12);//顯示否按鈕
show_nums(93,155,temp,3,12,color(0,0,0),0);
BEGIN:
while(key==0)
{
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(94,140,110,169))key=1;
else if(Is_In_Area(94,170,110,181))key=2;
else if(Is_In_Area(19,195,67,219))key=3;
else if(Is_In_Area(171,195,219,219))key=4;
else key=0;
if(key==1)Button_Up(94,140,110,151,PRESS);
else Button_Up(94,140,110,151,UNPRESS);
if(key==2)Button_Down(94,170,110,181,PRESS);
else Button_Down(94,170,110,181,UNPRESS);
if(key==3)Button(19,195,67,219,PRESS,"確定",24,12);//顯示是按鈕
else Button(19,195,67,219,UNPRESS,"確定",24,12);//顯示是按鈕
if(key==4)Button(171,195,219,219,PRESS,"取消",24,12);//顯示否按鈕
else Button(171,195,219,219,UNPRESS,"取消",24,12);//顯示否按鈕
i=0;
while(T_PEN==0)
{
if(i<300000)
{
Delay_us(1);
i++;
}
else
{
if(key==1)temp++;
if(key==2)temp--;
clear(93,157,111,169,color(255,255,255));
show_nums(93,155,temp,3,12,color(0,0,0),0);
Delay_ms(100);
}
}
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
Button_Up(94,140,110,151,UNPRESS);
Button_Down(94,170,110,181,UNPRESS);
Button(19,195,67,219,UNPRESS,"確定",24,12);//顯示是按鈕
Button(171,195,219,219,UNPRESS,"取消",24,12);//顯示否按鈕
}
}
if((key==1)||(key==2))
{
if(key==1)temp++;
if(key==2)temp--;
key=0;
clear(93,157,111,169,color(255,255,255));
show_nums(93,155,temp,3,12,color(0,0,0),0);
goto BEGIN;
}
if(key==3)
{
Scr_Delay=temp;
Scr_Count=temp;
if(Reflash_SD())
{
if(f_open(&fil,"0:/setup.set",FA_OPEN_ALWAYS|FA_WRITE)==FR_OK)
{
f_lseek(&fil,19);
f_write(&fil,&Scr_Delay,1,&byteleft);
f_close(&fil);
}
}
}
}
//黑屏延時
u8 Blk_Delay=0;//黑屏延時
u8 Blk_Count;//黑屏計數
u8 Blk_Flag=1;//屏幕亮起標志
void Screen_Blockout_Delay(void)
{
u8 key=0;
u32 i=0;
u8 temp=Blk_Delay;
//記錄用
FIL fil;
UINT byteleft;
Windows(9,89,229,229,"黑屏延時",12);
show_string(19,117,220,"請設定進入黑屏延時,0為屏幕常亮。",12,color(0,0,0));
show_string(19,155,220,"設定延時為:",12,color(0,0,0));
show_string(115,155,220,"秒",12,color(0,0,0));
Hole(91,153,113,169);
Button_Up(94,140,110,151,UNPRESS);
Button_Down(94,170,110,181,UNPRESS);
Button(19,195,67,219,UNPRESS,"確定",24,12);//顯示是按鈕
Button(171,195,219,219,UNPRESS,"取消",24,12);//顯示否按鈕
show_nums(93,155,temp,3,12,color(0,0,0),0);
BEGIN:
while(key==0)
{
if(Pen_Point.Key_Sta==Key_Down)
{
Pen_Int_Set(0);//關閉中斷
Pen_Point.Key_Sta=Key_Up;
do//連續讀取數據
{
Convert_Pos();
if(Is_In_Area(94,140,110,169))key=1;
else if(Is_In_Area(94,170,110,181))key=2;
else if(Is_In_Area(19,195,67,219))key=3;
else if(Is_In_Area(171,195,219,219))key=4;
else key=0;
if(key==1)Button_Up(94,140,110,151,PRESS);
else Button_Up(94,140,110,151,UNPRESS);
if(key==2)Button_Down(94,170,110,181,PRESS);
else Button_Down(94,170,110,181,UNPRESS);
if(key==3)Button(19,195,67,219,PRESS,"確定",24,12);//顯示是按鈕
else Button(19,195,67,219,UNPRESS,"確定",24,12);//顯示是按鈕
if(key==4)Button(171,195,219,219,PRESS,"取消",24,12);//顯示否按鈕
else Button(171,195,219,219,UNPRESS,"取消",24,12);//顯示否按鈕
i=0;
while(T_PEN==0)
{
if(i<300000)
{
Delay_us(1);
i++;
}
else
{
if(key==1)temp++;
if(key==2)temp--;
clear(93,157,111,169,color(255,255,255));
show_nums(93,155,temp,3,12,color(0,0,0),0);
Delay_ms(100);
}
}
}while(T_PEN==0);
Pen_Int_Set(1);//開啟中斷
Button_Up(94,140,110,151,UNPRESS);
Button_Down(94,170,110,181,UNPRESS);
Button(19,195,67,219,UNPRESS,"確定",24,12);//顯示是按鈕
Button(171,195,219,219,UNPRESS,"取消",24,12);//顯示否按鈕
}
}
if((key==1)||(key==2))
{
if(key==1)temp++;
if(key==2)temp--;
key=0;
clear(93,157,111,169,color(255,255,255));
show_nums(93,155,temp,3,12,color(0,0,0),0);
goto BEGIN;
}
if(key==3)
{
Blk_Delay=temp;
Blk_Count=temp;
if(Reflash_SD())
{
if(f_open(&fil,"0:/setup.set",FA_OPEN_ALWAYS|FA_WRITE)==FR_OK)
{
f_lseek(&fil,21);
f_write(&fil,&Blk_Delay,1,&byteleft);
f_close(&fil);
}
}
}
}
//屏保程序
void Screen_Saver(void)
{
if(reflash)
{
show_clock(119,110,90,color(255,255,0),color(0,0,0));//這個里面已經把reflash還原了
Show_Digital_Clock(87,210,16,color(0,255,255),color(0,0,0));
if((time.week==0)||(time.week==6))Show_Digital_Week(95,230,16,color(255,0,0),color(0,0,0));
else Show_Digital_Week(95,230,16,color(0,255,0),color(0,0,0));
Show_Digital_Date(63,250,16,color(0,255,255),color(0,0,0));
}
}
|