void Show_Clock(void) { unsigned int Hour ,Minute,Second; Hour = 9;//GetRTCHOUR(); while(Hour>=12) { Hour -= 12; } Minute = 0;//GetRTCMIN(); Second = 0;//GetRTCSEC(); Ini_Clock_Contex(); //ShowBMP240320(BMP_CLOCK); Gen_Hour_Hand(Hour*30+Minute/2); Save_Hour_Hand_BK(); Draw_Hour_Hand(POINTERCOLOR); Gen_Minu_Hand(Minute*6+Second/10); Save_Minu_Hand_BK(); Draw_Minu_Hand(POINTERCOLOR); Gen_Second_Hand(Second*6); Save_Second_Hand_BK(); Draw_Second_Hand(POINTERCOLOR); for(;;){ #if 0 if(Second==GetRTCSEC()) continue; Second = GetRTCSEC(); Minute = GetRTCMIN(); Hour = GetRTCHOUR(); #else delay_ms(1000); //delay 1s Second ++; if(Second >= 60){ Second = 0; Minute ++; if(Minute>=60) { Minute = 0; Hour ++; } } #endif while(Hour>=12) { Hour -= 12; } if(Minute%6==0&&Second==0) { Restore_Second_Hand_BK(); Restore_Minu_Hand_BK(); Restore_Hour_Hand_BK(); Gen_Hour_Hand(Hour*30+Minute/2); if(Second%10==0) Gen_Minu_Hand(Minute*6+Second/10); Gen_Second_Hand(Second*6); Save_Hour_Hand_BK(); Draw_Hour_Hand(POINTERCOLOR); Save_Minu_Hand_BK(); Draw_Minu_Hand(POINTERCOLOR); Save_Second_Hand_BK(); Draw_Second_Hand(POINTERCOLOR); } else if(Second%10==0) { Restore_Second_Hand_BK(); Restore_Minu_Hand_BK(); Gen_Minu_Hand(Minute*6+Second/10); Gen_Second_Hand(Second*6); Save_Minu_Hand_BK(); Draw_Minu_Hand(POINTERCOLOR); Save_Second_Hand_BK(); Draw_Second_Hand(POINTERCOLOR); } else { Restore_Second_Hand_BK(); Gen_Second_Hand(Second*6); Save_Second_Hand_BK(); Draw_Second_Hand(POINTERCOLOR); } } }
//---------------------------------------------------------------------------// // // //函数:char Proc_Show_Clock(char *NC) // //描述:电子时钟程序 // //参数:NC ——无意义 // // // //---------------------------------------------------------------------------// char Proc_Show_Clock(char *NC) { unsigned int temp[2] ; unsigned int Hour ,Minute,Second ; Hour = GetRTCHOUR() ; while(Hour>=12) { Hour -= 12 ; } Minute = GetRTCMIN() ; Second = GetRTCSEC() ; Ini_Clock_Contex() ; ShowBMP240320(BMP_CLOCK) ; Gen_Hour_Hand(Hour*30+Minute/2) ; Save_Hour_Hand_BK() ; Draw_Hour_Hand(White) ; Gen_Minu_Hand(Minute*6+Second/10) ; Save_Minu_Hand_BK() ; Draw_Minu_Hand(White) ; Gen_Second_Hand(Second*6) ; Save_Second_Hand_BK() ; Draw_Second_Hand(White) ; for(;;) { if(Second==GetRTCSEC()) continue ; Second = GetRTCSEC() ; Minute = GetRTCMIN() ; Hour = GetRTCHOUR() ; while(Hour>=12) { Hour -= 12 ; } if(Minute%6==0&&Second==0) // 时针转动 { Restore_Second_Hand_BK() ; Restore_Minu_Hand_BK() ; Restore_Hour_Hand_BK() ; Gen_Hour_Hand(Hour*30+Minute/2) ; if(Second%10==0) Gen_Minu_Hand(Minute*6+Second/10) ; Gen_Second_Hand(Second*6) ; Save_Hour_Hand_BK() ; Draw_Hour_Hand(White) ; Save_Minu_Hand_BK() ; Draw_Minu_Hand(White) ; Save_Second_Hand_BK() ; Draw_Second_Hand(White) ; } else if(Second%10==0) // 分针转动 { Restore_Second_Hand_BK() ; Restore_Minu_Hand_BK() ; Gen_Minu_Hand(Minute*6+Second/10) ; Gen_Second_Hand(Second*6) ; Save_Minu_Hand_BK() ; Draw_Minu_Hand(White) ; Save_Second_Hand_BK() ; Draw_Second_Hand(White) ; } else { Restore_Second_Hand_BK() ; Gen_Second_Hand(Second*6) ; Save_Second_Hand_BK() ; Draw_Second_Hand(White) ; } OS_Delay(100) ; if(Read_TP_Twice(&temp[0],&temp[1])) break ; } return 0x00 ; }