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

- 49 -

- 50 -

- 51 -

附录二:部分源程序

一、主函数源程序

#include \

u8 State_Machine = 6;//状态标志,初始化时自动跳转到桌面状态 void INIT_ALL(void);//硬件的所有初始化操作 u8 State6_zhuomian(void); int main(void) { INIT_ALL();

Acquisition_Calibration();//获得触摸屏校准参数 while(1) {

switch(State_Machine) {

case 0:State_Machine = State0_Calendar();//万年历

break;

case 1:State_Machine = State1_Clock();//闹钟

break;

case 2: State_Machine = State2_Stopwatch();//计时器

break;

case 3: State_Machine = State3_Map();//地图

break;

case 4: State_Machine = State4_Drawing_Board();//画板

break;

case 5: State_Machine = State5_Pedometer();//计步 break;

case 6: State_Machine = State6_zhuomian();//桌面

}

}

} 二、桌面状态源程序

- 52 -

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

返回值:要切换的状态值 函数功能:状态6,桌面界面

****************************************************/ u8 State6_zhuomian(void) {

Paint_Bmp_SPIFLASH(0,0,GIMAGE_ZHUOMIAN_BASE_ADD); //加载主界面

Clock_Face(); while(1) {

if(Time_1S==1)

{ RTC_Display();

Time_1S=0; //秒标志清零 Imagedata_Addr=GIMAGE_ZHUOMIAN_BASE_ADD; Clock_Display(); }

MPU_Get_Accelerometer( &Acc_x , &Acc_y , &Acc_z ); CountStep( Acc_x , Acc_y, Acc_z); Delay_ms(20); if(TPEN()==0) {

TP_Scan(0);//获取AD转换后的物理坐标值 while(!TPEN()); //松手检测

if(Is_In_Area(20,210,60,250)) return 3; else if(Is_In_Area(100,210,140,250))return 5; else if(Is_In_Area(180,210,220,250))return 4; else if(Is_In_Area(20,265,60,305))return 0; else if(Is_In_Area(100,265,140,305))return 2;

- 53 -

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4