基于STM32的可穿戴设备系统毕业论文 下载本文

函数名:State2_Stopwatch 形参:

返回值:要切换的状态值 函数功能:状态2,秒表界面

****************************************************/ u8 State2_Stopwatch(void) {

u8 j=0,y=140; u16 total_sec;

unsigned char time_save[10]; unsigned char time_save_small[10];

stopwatch_back=0; //进入主界面 ,后台运行暂停

Paint_Bmp_SPIFLASH(0,0,GIMAGE_MOKUAIJIEMIAN_BASE_ADD); GUI_CircleFill(45,99,25,BRRED); GUI_CircleFill(120,99,25,BRRED); GUI_CircleFill(195,99,25,BRRED);

GUI_RectangleFill(0, 280,240, 320, BRRED );

Draw_Text(198,290,BRRED ,WHITE ,\返回\ Draw_Text(29,91,BRRED ,WHITE ,\开始\ Draw_Text(104,91,BRRED ,WHITE ,\复位\ Draw_Text(179,91,BRRED ,WHITE ,\计次\

Imagedata_Addr=GIMAGE_MOKUAIJIEMIAN_BASE_ADD; //选中背景图为模块界面 Draw_text 调用的Show_xXx 用到 用于显示字体背景

while(1) {

if(sec_flag==1) { sec_flag=0; sec++; if(sec>59) { sec=0; min++; if(min>59)

- 59 -

{ min=0; hour++; if(hour==24) hour=0; }

}

}

/*************计算相对时间***************/ //用于相对时间显示

total_sec=hour*3600+min*60+sec-hour_c*3600-min_c*60-sec_c+back_time;

hour_small=total_sec/3600;

min_small=(total_sec-hour_small*3600)/60; sec_small=total_sec-hour_small*3600-min_small*60; time_save[0]='0'+(hour/10); time_save[1]='0'+(hour); time_save[2]=':';

time_save[3]='0'+(min /10); time_save[4]='0'+(min); time_save[5]=':';

time_save[6]='0'+(sec /10); time_save[7]='0'+(sec);

time_save[8]='\\0'; time_save_small[0]='0'+(hour_small/10); time_save_small[1]='0'+(hour_small); time_save_small[2]=':';

time_save_small[3]='0'+(min_small /10); time_save_small[4]='0'+(min_small); time_save_small[5]=':';

time_save_small[6]='0'+(sec_small /10); time_save_small[7]='0'+(sec_small); time_save_small[8]='\\0';

Draw_Text(56,32,BLUE ,WHITE ,time_save,32,2); //显示总时间时间

- 60 -

Draw_Text(120,16,BLUE ,WHITE ,time_save_small,16,2); //显示相对时间

if(TPEN()==0) {

TP_Scan(0);//获取AD转换后的物理坐标值 while(!TPEN()); //松手检测 if(Is_In_Area(20,74,70,124)) //启动 and 停止 {

if(s_t_flag) {

s_t_flag=0;

Draw_Text(29,91,BRRED ,WHITE ,\开始\1 ); //切换按钮显示

}

else

{

TIM_Cmd(TIM2, ENABLE); /* 开启定时器 */ s_t_flag=1;

Draw_Text( 29,91,BRRED ,WHITE ,\暂停\1 ); //切换按钮显示

} }

else if(Is_In_Area(170,74,220,124)) //计次

{

if(j<8&&s_t_flag ==1) //s_t_flag为1才能计次 J为记的时间总个数不超过8个

{

big_time_save();

Draw_Text(88,y,BLUE,RED,time_save_small,16,2); //按顺序打印小时间

j++;

- 61 -

y+=16;

} }

else if(Is_In_Area(95,74,145,124)) // 复位

{

TIM_Cmd(TIM2, DISABLE); stopwatch_back=0; back_time=0; SecCounter_Init(); small_time_clear(); hour_c=0; min_c=0; sec_c=0; j=0;

y=140; //计次的初始位置

Draw_Text(56,32,BLUE ,WHITE ,\ //显示总时间

Draw_Text(120,16,BLUE ,WHITE ,\ Draw_Text( 29,91,BRRED ,WHITE ,\开始\1 ); //切换按钮状态 并清零所有时间

Draw_Text(88,140,BLUE,WHITE,\ \ ); Draw_Text(88,156,BLUE,WHITE,\ \ ); Draw_Text( 88,172,BLUE,WHITE,\ \ ); Draw_Text( 88,188,BLUE,WHITE,\ \ ); Draw_Text(88,204,BLUE,WHITE,\ \ ); Draw_Text( 88,220,BLUE,WHITE,\ \ ); Draw_Text( 88,236,BLUE,WHITE,\ \ ); Draw_Text( 88,252,BLUE,WHITE,\ \ ); } else if(Is_In_Area(180,280,235,315)) {

stopwatch_back=1;

- 62 -

/* 关闭定时器 */

return 6; //返回 } } } }

六、画板状态部分源程序

/**************************************************** 函数名:State4_Drawing_Board 形参:

返回值:要切换的状态值 函数功能:状态4,画板界面

****************************************************/ u8 State4_Drawing_Board(void) {

u8 i,j=1;

POINT_COLOR=BLACK ; //默认画笔颜色 BACK_COLOR=WHITE ; //默认背景色 LCD_Clear(BACK_COLOR); //清屏为白色

GUI_RectangleFill(0, 280,240, 320, BRRED ); //加载工具条底色 Draw_Text(14,292,BRRED,WHITE,\取色\ //加载工具条字体 Draw_Text(74,292,BRRED,WHITE,\橡皮\ //加载工具条字体 Draw_Text(134,292,BRRED,WHITE,\清除\ //加载工具条字体 Draw_Text(194,292,BRRED,WHITE,\返回\ //加载工具条字体 while(1) {

if(TPEN()==0) {

TP_Scan(0);//获取AD转换后的物理坐标值 /**********工具条区域和画板区域用不同的扫描方式**********************/

if(tp_dev.y<279)

- 63 -