嵌入式课程设计-- 基于LCD的电子时钟实验 下载本文

内容发布更新时间 : 2024/12/24 3:56:35星期一 下面是文章的全部内容请认真阅读。

参考文献

【1】王勇,嵌入式系统原理与设计,浙江大学出版社,2007.

【2】谢自美,电子线路设计、实验、测试,华中理工大学出版社,2003。 【3】宋春荣,通用集成电路速查手册,山东科学技术出版社,1995。

【4】桑楠. 嵌入式系统原理及应用开发技术,北京:北京航空航天大学出版社, 2002

- 16 -

附 录

源程序:

#include \#define STACKSIZE 256 #define x_line 160 #define y_line 80 OS_STK_DATA stk;

extern GUI_FONT CHINESE_FONT12; extern GUI_FONT CHINESE_FONT16; extern GUI_FONT GUI_Font8x16; OS_EVENT * Send_LCD_Sem; OS_EVENT *Key_Mbox;

I8 Hour[3],Min[3],Sec[3];

I8 hour = 0, min = 0, sec = 0,ms; I8 YEA1[3],YEA2[3],MON[3],DAY[3];

int yea1 = 20,yea2=11, mon = 6, day = 29; I8 XH0[3],XH1[3],XH2[3],XH3[3]; I8 XH4[3],XH5[3];

char xh0=01,xh1=62,xh2=51,xh3=01; char xh4=27,xh5=28,xh6=29; //int TimeCount = 0;

int SpaceXS[61]={160,165,170,175,180,185, 189,193,197,201,205, 206,207,208,209,210, 209,208,207,206,205, 201,197,193,189,185, 180,175,170,165,160, 155,150,145,140,135, 131,127,123,119,115, 114,113,112,111,110, 111,112,113,114,115, 119,123,127,131,135, 140,145,150,155,160, }, SpaceYS[61]={30,31,32,33,34, 35,39,43,47,51, 55,60,65,70,75, 80,85,90,95,100, 105,109,113,117,121, 125,126,127,128,129, 130,129,128,127,126, 125,121,117,113,109, 105,100,95,90,85, 80,75,70,65,60, 55,51,47,43,39, 35,34,33,32,31,30}, SpaceXM[61]={160,164,168,172,176,180,183,186,189,192, 195,196,197,198,199,200,199,198,197,196, 195,192,189,186,183,180,176,172,168,164, 160,156,152,148,144,140,137,134,131,128, 125,124,123,122,121,120,121,122,123,124, 125,128,131,134,137,140,144,148,152,156, 160

- 17 -

}, SpaceYM[61]={40,41,42,43,44,45,48,51,54,57, 60,64,68,72,76,80,84,88,92,96, 100,103,106,109,112,115,116,117,118,119, 120,119,118,117,116,115,112,109,106,103, 100,96,92,88,84,80,76,72,68,64, 60,57,54,51,48,45,44,43,42,41, 40 }, SpaceXH[13]={160,175,185,190,185,175,160,145,135,130,135,145,160}, SpaceYH[13]={50,55,65,80,95,105,110,105,95,80,65,55,50}, *Placex=&SpaceXS[0],*Placey=&SpaceYS[0],*Placexm=&SpaceXM[0],*Placeym=&SpaceYM[0], *Placexh=&SpaceXH[0],*Placeyh=&SpaceYH[0]; void Display_xh1(char xx1,char yy1); void Display_xh2(char xx2,char yy2); void Display_xh3(char xx3,char yy3); void show(I8 s) { if(s%4==1) { Set_Color(GUI_RED); Set_Font (&CHINESE_FONT16); Disp_String (CN_start\孙维广\ Set_Font(&GUI_Font8x16); Set_Color(GUI_RED); Display_xh1(250,210); }

else if(s%4==2) { Set_Color(GUI_RED); Set_Font (&CHINESE_FONT16); Disp_String (CN_start\陶贵华\ Set_Color(GUI_RED);

Set_Font(&GUI_Font8x16); Display_xh2(250,210); }

else if(s%4==3) { Set_Color(GUI_RED); Set_Font (&CHINESE_FONT16); Disp_String (CN_start\严维锋\ Set_Color(GUI_RED); Set_Font(&GUI_Font8x16); Display_xh3(250,210); } }

void Shows() { show(sec);

Set_Color(GUI_GRAY); //擦除上一秒的 Draw_Line(x_line,y_line,*Placex,*Placey); Placex=Placex+1; Placey=Placey+1;

Set_Color(GUI_YELLOW); //显示下一秒的

- 18 -

Draw_Line(x_line,y_line,*Placex,*Placey);

Set_Color(GUI_RED); //显示下一分的

Draw_Line(x_line,y_line,*Placexm,*Placeym); Set_Color(GUI_GREEN); //显示下一时的 Draw_Line(x_line,y_line,*Placexh,*Placeyh);

if(Placex==&SpaceXS[60]&&Placey==&SpaceYS[60]) {

Placex=&SpaceXS[0]; Placey=&SpaceYS[0]; } }

void Showm() {

Set_Color(GUI_GREEN);

Fill_Circle (288, 50, 25); Set_Color(GUI_RED);

Fill_Circle (280, 50, 10); Fill_Circle (296, 50, 10); Fill_Circle (288, 40, 10); Fill_Circle (288, 60, 10); Set_Color(GUI_YELLOW); Fill_Circle (288, 50, 5); Set_Color(GUI_GRAY); //擦除上一分的 Draw_Line(x_line,y_line,*Placexm,*Placeym); Placexm=Placexm+1; Placeym=Placeym+1; Set_Color(GUI_RED); //显示下一分的 Draw_Line(x_line,y_line,*Placexm,*Placeym); Set_Color(GUI_GREEN); //显示下一时的 Draw_Line(x_line,y_line,*Placexh,*Placeyh); if(Placexm==&SpaceXM[60]&&Placeym==&SpaceYM[60]) { Placexm=&SpaceXM[0]; Placeym=&SpaceYM[0]; } }

void Showh() { Set_Color(GUI_YELLOW); Fill_Circle (288, 50, 25); Set_Color(GUI_GREEN);

Fill_Circle (280, 50, 10); Fill_Circle (296, 50, 10); Fill_Circle (288, 40, 10); Fill_Circle (288, 60, 10); Set_Color(GUI_RED);

Fill_Circle (288, 50, 5); Set_Color(GUI_GRAY); //擦除上一时的 Draw_Line(x_line,y_line,*Placexh,*Placeyh);

- 19 -