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

Placexh=Placexh+1; Placeyh=Placeyh+1; Set_Color(GUI_GREEN); //显示下一时的 Draw_Line(x_line,y_line,*Placexh,*Placeyh); if(Placexh==&SpaceXH[12]&&Placeyh==&SpaceYH[12]) { Placexh=&SpaceXH[0]; Placeyh=&SpaceYH[0]; } }

void Shouw_Cricle() // 整 点 { Set_Color(GUI_YELLOW);

Fill_Circle (160, 30,2); // 12点(x,y,r) Fill_Circle (135, 35,2); // 11 点(x,y,r) Fill_Circle (115, 55,2); // 10 点(x,y,r) Fill_Circle (110, 80,2); // 9 点(x,y,r) Fill_Circle (115, 105,2); // 8 点(x,y,r) Fill_Circle (135, 125,2); // 7 点(x,y,r) Fill_Circle (160, 130,2); // 6 点(x,y,r) Fill_Circle (185, 125,2); // 5 点(x,y,r) Fill_Circle (205, 105,2); // 4 点(x,y,r) Fill_Circle (210, 80,2); // 3 点(x,y,r) Fill_Circle (205, 55,2); // 2点(x,y,r) Fill_Circle (185, 35,2); // 1点(x,y,r) }

void Delay(int time);

void ChangeForm(char Time[],char time) {

Time[0] = time / 10 + 48; Time[1] = time % 10 + 48; Time[2] = '\\0'; }

void Display_Time(char x,char y) {

ChangeForm(Hour, hour); ChangeForm(Min, min); ChangeForm(Sec, sec); ChangeForm(MON, mon); ChangeForm(DAY, day); ChangeForm(YEA1, yea1); ChangeForm(YEA2, yea2); Disp_String (Hour,x,160); Disp_String (\ Disp_String (Min,x + 24,160); Disp_String (\ Disp_String (Sec,x + 48,160);

Disp_String (YEA1,x , 180); Disp_String (YEA2,x +16,180); Disp_String (\ Disp_String (MON,x + 40,180); Disp_String (\ Disp_String (DAY,x + 64,180); }

void Display_xh1(char xx1,char yy1)//孙维广学号

- 20 -

{ ChangeForm(XH0, xh0); ChangeForm(XH1, xh1); ChangeForm(XH2, xh2); ChangeForm(XH3, xh3); Disp_String (XH0,xx1,yy1); Disp_String (XH1,xx1+16,yy1); Disp_String (XH2,xx1+32,yy1); Disp_String (XH3,xx1+48,yy1); }

void Display_xh2(char xx2,char yy2)//陶贵华学号 { ChangeForm(XH0, xh0); ChangeForm(XH1, xh1); ChangeForm(XH2, xh2); ChangeForm(XH4, xh4); Disp_String (XH0,xx2,yy2); Disp_String (XH1,xx2+16,yy2); Disp_String (XH2,xx2+32,yy2); Disp_String (XH4,xx2+48,yy2); }

void Display_xh3(char xx3,char yy3)//严维锋学号 { ChangeForm(XH0, xh0); ChangeForm(XH1, xh1); ChangeForm(XH2, xh2); ChangeForm(XH5, xh5); Disp_String (XH0,xx3,yy3); Disp_String (XH1,xx3+16,yy3); Disp_String (XH2,xx3+32,yy3); Disp_String (XH5,xx3+48,yy3); }

void Show_Color() { Set_Color( GUI_BLUE ); Fill_Rect(0,0,319,239);

Set_Color(GUI_RED); Set_BkColor (GUI_BLUE); Fill_Rect(0,0,319,2); Fill_Rect(0,0,2,239); Fill_Rect(0,237,319,239); Fill_Rect(317,0,319,239); Set_Color(GUI_RED);

Set_Font (&CHINESE_FONT16);

Disp_String (CN_start\姓名:\ Disp_String (CN_start\学号:\ Set_Color(GUI_WHITE ); Fill_Rect (79,17,242,20); //上线(x0,y0,x1,y1) Fill_Rect (79,20,82,202); //左线(x0,y0,x1,y1) Fill_Rect (238,20,242,202); //右线(x0,y0,x1,y1) Fill_Rect (79,199,242,202); //下线(x0,y0,x1,y1) Set_Color(GUI_LIGHTRED); Fill_Rect (83,21,237,198); }

/*分配各任务的堆栈容量

- 21 -

*/

OS_STK Stack_Task_1[STACKSIZE]; OS_STK Stack_Task_2[STACKSIZE*3]; /*

void Task_3(I8 s) { I8 display; for(;;) {

Delay(100); display++;

Set_Color(GUI_RED); Display_xh1(5,180); if(display==1000) { display=0; } } } /*

- 函数名称 : Task_2(void *pdata) - 函数说明 : GUI任务,优先级为9 - 输入参数 : pdata - 输出参数 : 无 */

void Task_2(void *pdata) {

for(;;) { Show_Color(); Shouw_Cricle(); Set_Color(GUI_RED); sec = 0; Set_Color(GUI_YELLOW); //显示

Draw_Line(x_line,y_line,*Placex,*Placey); Display_Time(130, 160);//时间 do { Delay(1200); sec++; Shows(); if (sec >= 60) { sec = 0; min++; Showm(); if (min >= 60) { min = 0; hour++; Showh(); if (hour >= 23) { hour = 0; day++; if(day >=32)

- 22 -

{ day = 1; mon++; if(mon >= 13) { mon = 1; yea1++; } } } } } Display_Time(130, 160);//时间 日期 }while(1); } }

void Task_1(void *pdata) {

Rtc_Tick_Init(); //打开时钟节拍,让操作系统跑起来 OSTaskCreate(Task_2, (void *)0, (OS_STK *)&Stack_Task_2[(STACKSIZE*3) - 1], 9); for(;;) {

OSTimeDly(50); //时钟屏幕显示 } }

void Main(void) {

Target_Init(); // ARMII实验系统的初始化,包括CPU板 GUI_Init(); OSInit();

OSTaskCreate(Task_1, (void *)0, (OS_STK *)&Stack_Task_1[STACKSIZE - 1], 5); //创建任务一

OSStart(); }

- 23 -

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