Beispiel #1
0
//show clock
int main()
{
	/* Setup the microcontroller system. Initialize the Embedded Flash Interface,
	 initialize the PLL and update the SystemFrequency variable. */
	xSysCtlClockSet(72000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
	xSysCtlDelay(10000);

	delay_init(72);
	Lcd_Init();
	Lcd_Clear(GRAY0);

	Gui_DrawFont_GBK16(30,50,BLUE,GRAY0,"Show Clock");
	Gui_DrawFont_GBK16(36,70,BLUE,GRAY0,"@ CooCox");
	delay_ms(2000);
	Lcd_Clear(GRAY0);

	while(1){
		Show_Clock();
	}
}
Beispiel #2
0
//更新表盘数据
void Update_Clock_Data(S_Show_Data *pDst, INT8U Area_No)
{
  S_Point P0;
  INT16S tmp;
  INT16U Width,Height;
  INT8U Font;
  INT16U StrWidth, StrHeight;
  time_t CurSec;
  S_Time sTime;
  struct tm tTime, *ptm;
  
  Width = Get_Area_Width(Area_No);
  Height = Get_Area_Height(Area_No);

  //是否需要调整时差
  if(Prog_Status.File_Para[Area_No].Clock_Para.Hour_Diff != 0 ||\
     Prog_Status.File_Para[Area_No].Clock_Para.Min_Diff != 0)
  {
    S_Time_2_tm(&Cur_Time, &tTime);
    CurSec = mktime(&tTime);
    
    if(Prog_Status.File_Para[Area_No].Clock_Para.Diff_Flag EQ 0) //增加
      CurSec += Prog_Status.File_Para[Area_No].Clock_Para.Hour_Diff*3600 +\
                Prog_Status.File_Para[Area_No].Clock_Para.Min_Diff*60;
    else
      CurSec -= Prog_Status.File_Para[Area_No].Clock_Para.Hour_Diff*3600 +\
                Prog_Status.File_Para[Area_No].Clock_Para.Min_Diff*60;
    
    ptm = localtime(&CurSec);
    tm_2_S_Time(ptm, &sTime); 
  }
  else
  {
    mem_cpy(&sTime, &Cur_Time, sizeof(Cur_Time), &sTime, sizeof(sTime)); 
  }
  
  /*
  //----------固定文本---------
  tmp = (INT16S)(Width * Prog_Status.File_Para[Area_No].Clock_Para.Text_X / 100) - (INT16S)Prog_Status.File_Para[Area_No].Clock_Para.Text_Width/2;
  if(tmp > 0)
    P0.X = (INT16U)tmp;
  else
    P0.X = 0;

  tmp = (INT16S)(Height * Prog_Status.File_Para[Area_No].Clock_Para.Text_Y / 100) - (INT16S)(Prog_Status.File_Para[Area_No].Clock_Para.Text_Height/2);
  if(tmp > 0)
    P0.Y = (INT16U)tmp;
  else
    P0.Y = 0;

  Copy_Filled_Rect(&Show_Data_Bak, Area_No, &P0, Prog_Status.File_Para[Area_No].Clock_Para.Text_Width, Prog_Status.File_Para[Area_No].Clock_Para.Text_Height, &Show_Data, &P0);//&Point);
*/
  //---------星期---------
  if(Prog_Status.File_Para[Area_No].Clock_Para.Week_Type > 0)
  {
      INT8U Font = Prog_Status.File_Para[Area_No].Clock_Para.Week_Font; //字体
      INT16U StrWidth = Get_WeekStr_Pix_Width(Prog_Status.File_Para[Area_No].Clock_Para.Week_Type - 1, Font, Cur_Time.Time[T_WEEK]);
      INT8U StrHeight = Get_Font_Height(Font);

      tmp = (INT16S)(Width*Prog_Status.File_Para[Area_No].Clock_Para.Week_X / 100) - (INT16S)StrWidth / 2;
      if(tmp > 0)
        P0.X = tmp;
      else
        P0.X = 0;

      tmp = (INT16S)Height * Prog_Status.File_Para[Area_No].Clock_Para.Week_Y / 100 - (INT16S)StrHeight/2;
      if(tmp > 0)
        P0.Y = tmp;
      else
        P0.Y = 0;

      Show_Week(pDst, Area_No, P0.X, P0.Y, &Cur_Time, Prog_Status.File_Para[Area_No].Clock_Para.Week_Type - 1, Prog_Status.File_Para[Area_No].Clock_Para.Week_Font, Prog_Status.File_Para[Area_No].Clock_Para.Week_Color);
   }

  //显示日期
  if(Prog_Status.File_Para[Area_No].Clock_Para.Date_Type > 0)
  {
      Font = Prog_Status.File_Para[Area_No].Clock_Para.Date_Font; //字体
      StrWidth = Get_DateStr_Pix_Width(Prog_Status.File_Para[Area_No].Clock_Para.Date_Type - 1,Font);
      StrHeight = Get_Font_Height(Font);

      tmp = Width*Prog_Status.File_Para[Area_No].Clock_Para.Date_X / 100 - StrWidth / 2;
      if(tmp > 0)
        P0.X = tmp;
      else
        P0.X = 0;

      tmp = Height * Prog_Status.File_Para[Area_No].Clock_Para.Date_Y / 100 - StrHeight/2;
      if(tmp > 0)
        P0.Y = tmp;
      else
        P0.Y = 0;

      Show_Date(pDst, Area_No, P0.X, P0.Y, &Cur_Time, Prog_Status.File_Para[Area_No].Clock_Para.Date_Type - 1, Prog_Status.File_Para[Area_No].Clock_Para.Date_Font, Prog_Status.File_Para[Area_No].Clock_Para.Date_Color);
   }
  
   Show_Clock(pDst, Area_No, &sTime, (S_Clock_Para *)&Prog_Status.File_Para[Area_No].Clock_Para);
}