Exemplo n.º 1
0
void halRtcGet(RTC_DATA* pRtcData)
{
  tWordByteUnion temp;
  temp.word = GetRTCYEAR();
  pRtcData->Year = temp.byte.b0 | (temp.byte.b1 << 8);
  pRtcData->Month = GetRTCMON();
  pRtcData->DayOfMonth = GetRTCDAY(); 
  pRtcData->DayOfWeek = GetRTCDOW();
  pRtcData->Hour = GetRTCHOUR();
  pRtcData->Minute = GetRTCMIN();
  pRtcData->Second = GetRTCSEC();

}
Exemplo n.º 2
0
void DisplayTime(void)
{
  unsigned char string[10]                           ;
  int hour,minute,second                             ;
  hour    = GetRTCHOUR()                             ;
  minute  = GetRTCMIN()                              ;
  second  = GetRTCSEC()                              ;
  sprintf((char *)string,"%02d-%02d-%02d",
           hour,minute,second             )          ;
  OS_Use(&SemaLCD)                                   ; 
  Color    = White                                   ;
  Color_BK = Blue                                    ;
  PutStringEN16(84,300,string)                       ;
  Color    = WINDOW_COLOR                            ;
  Color_BK = WINDOW_BK_COLOR                         ;
  OS_Unuse(&SemaLCD)                                 ; 
}
Exemplo n.º 3
0
void TimeFace::OnPaintAll(Bitmap *destination)
{
	int w = destination->Width();
	int h = destination->Height();
	int cx = w / 2;
	int cy = h / 2;

	destination->FillRect(0, 0, w, h, false);

	{
		char buf[10];
		int y = cy + 10;
		MetaWatch_Combined_8pt.Print(destination, 20, y, daysOfWeek[GetRTCDOW()]);
		goodsprintf(buf, "%i/%2i",
				GetRTCDAY(),
				GetRTCMON()
				);
		y += MetaWatch_Combined_8pt.Height();
		MetaWatch_Small_8pt.Print(destination, 20, y, buf);
		goodsprintf(buf, "%4i",
				GetRTCYEAR()
				);
		y += MetaWatch_Small_8pt.Height();
		MetaWatch_Small_8pt.Print(destination, 20, y, buf);
	}

	// Clock markings
	for (int i = 0; i < 12; i++)
		DrawHand(destination, cx, cy, htTick, GetRadians(i, 12));

	int hour = GetRTCHOUR() % 12;
	int minute = GetRTCMIN();
	int second = GetRTCSEC();

	// Hour
	int hourFull = (hour * 60) + minute;
	DrawHand(destination, cx, cy, htHour, GetRadians(hourFull, 12 * 60));

	// Minute
	int minuteFull = (minute * 60) + second;
	DrawHand(destination, cx, cy, htMinute, GetRadians(minuteFull, 60 * 60));

	// Second
	DrawHand(destination, cx, cy, htSecond, GetRadians(second, 60));
}
Exemplo n.º 4
0
static void DisplayAmPm(void)
{
  /* don't display am/pm in 24 hour mode */
  if ( GetTimeFormat() == TWELVE_HOUR )
  {
    int Hour = GetRTCHOUR();

    unsigned char const *pFoo;

    if ( Hour >= 12 )
    {
      pFoo = Pm;
    }
    else
    {
      pFoo = Am;
    }

    WriteFoo(pFoo,0,8);
  }

}
Exemplo n.º 5
0
void DrawIdleScreen(void)
{
  unsigned char msd;
  unsigned char lsd;

  unsigned char Row = 6;
  unsigned char Col = 0;

  int Minutes;

  /* display hour */
  int Hour = GetRTCHOUR();

  /* if required convert to twelve hour format */
  if ( GetTimeFormat() == TWELVE_HOUR )
  {
    if ( Hour == 0 )
    {
      Hour = 12;
    }
    else if ( Hour > 12 )
    {
      Hour -= 12;
    }
  }

  msd = Hour / 10;
  lsd = Hour % 10;

  /* if first digit is zero then leave location blank */
  if ( msd != 0 )
  {
    WriteTimeDigit(msd,Row,Col,LEFT_JUSTIFIED);
  }
  Col += 1;
  WriteTimeDigit(lsd,Row,Col,RIGHT_JUSTIFIED);
  Col += 2;

  /* the colon takes the first 5 bits on the byte*/
  WriteTimeColon(Row,Col,RIGHT_JUSTIFIED);
  Col+=1;

  /* display minutes */
  Minutes = GetRTCMIN();
  msd = Minutes / 10;
  lsd = Minutes % 10;
  WriteTimeDigit(msd,Row,Col,RIGHT_JUSTIFIED);
  Col += 2;
  WriteTimeDigit(lsd,Row,Col,LEFT_JUSTIFIED);

  if ( nvDisplaySeconds )
  {
    /* the final colon's spacing isn't quite the same */
    int Seconds = GetRTCSEC();
    msd = Seconds / 10;
    lsd = Seconds % 10;

    Col +=2;
    WriteTimeColon(Row,Col,LEFT_JUSTIFIED);
    Col += 1;
    WriteTimeDigit(msd,Row,Col,LEFT_JUSTIFIED);
    Col += 1;
    WriteTimeDigit(lsd,Row,Col,RIGHT_JUSTIFIED);

  }
  else /* now things starting getting fun....*/
  {
    DisplayAmPm();

    if ( QueryBluetoothOn() == 0 )
    {
      CopyColumnsIntoMyBuffer(pBluetoothOffIdlePageIcon,
                              IDLE_PAGE_ICON_STARTING_ROW,
                              IDLE_PAGE_ICON_SIZE_IN_ROWS,
                              IDLE_PAGE_ICON_STARTING_COL,
                              IDLE_PAGE_ICON_SIZE_IN_COLS);
    }
    else if ( QueryPhoneConnected() == 0 )
    {
      CopyColumnsIntoMyBuffer(pPhoneDisconnectedIdlePageIcon,
                              IDLE_PAGE_ICON_STARTING_ROW,
                              IDLE_PAGE_ICON_SIZE_IN_ROWS,
                              IDLE_PAGE_ICON_STARTING_COL,
                              IDLE_PAGE_ICON_SIZE_IN_COLS);
    }
    else
    {
      if ( QueryBatteryCharging() )
      {
        CopyColumnsIntoMyBuffer(pBatteryChargingIdlePageIconType2,
                                IDLE_PAGE_ICON2_STARTING_ROW,
                                IDLE_PAGE_ICON2_SIZE_IN_ROWS,
                                IDLE_PAGE_ICON2_STARTING_COL,
                                IDLE_PAGE_ICON2_SIZE_IN_COLS);
      }
      else
      {
        unsigned int bV = 3500;

        if ( bV < 3500 )
        {
          CopyColumnsIntoMyBuffer(pLowBatteryIdlePageIconType2,
                                  IDLE_PAGE_ICON2_STARTING_ROW,
                                  IDLE_PAGE_ICON2_SIZE_IN_ROWS,
                                  IDLE_PAGE_ICON2_STARTING_COL,
                                  IDLE_PAGE_ICON2_SIZE_IN_COLS);
        }
        else
        {
          DisplayDayOfWeek();
          DisplayDate();
        }
      }
    }
  }
}
Exemplo n.º 6
0
void DrawSimpleIdleScreen(void)
{
  unsigned char msd;
  unsigned char lsd;

  unsigned char Row = 6;
  unsigned char Col = 0;

  int Minutes;
  /* display hour */
  int Hour = GetRTCHOUR();
  if (Hour < 0 || Hour > 23) {
    Hour = 0;
  }

  /* if required convert to twelve hour format */
  if ( GetTimeFormat() == TWELVE_HOUR )
  {
    if ( Hour == 0 )
    {
      Hour = 12;
    }
    else if ( Hour > 12 )
    {
      Hour -= 12;
    }
  }

  msd = Hour / 10;
  lsd = Hour % 10;

  /* if first digit is zero then leave location blank */
  if ( msd != 0 )
  {
    WriteTimeDigit(msd, Row, Col, LEFT_JUSTIFIED);
  }
  Col += 1;
  WriteTimeDigit(lsd, Row, Col, RIGHT_JUSTIFIED);
  Col += 2;

  /* the colon takes the first 5 bits on the byte*/
  WriteTimeColon(Row,Col,RIGHT_JUSTIFIED);
  Col += 1;

  /* display minutes */
  Minutes = GetRTCMIN();
  if (Minutes < 0 || Minutes > 59) {
    Minutes = 0;
  }
  msd = Minutes / 10;
  lsd = Minutes % 10;

  WriteTimeDigit(msd, Row, Col, RIGHT_JUSTIFIED);
  Col += 2;
  WriteTimeDigit(lsd, Row, Col, LEFT_JUSTIFIED);

  if ( nvDisplaySeconds )
  {
    /* the final colon's spacing isn't quite the same */
    int Seconds = GetRTCSEC();

    msd = Seconds / 10;
    lsd = Seconds % 10;

    Col +=2;
    WriteTimeColon(Row,Col,LEFT_JUSTIFIED);
    Col += 1;
    WriteTimeDigit(msd,Row,Col,LEFT_JUSTIFIED);
    Col += 1;
    WriteTimeDigit(lsd,Row,Col,RIGHT_JUSTIFIED);

  }
  else
  {
    DisplayAmPm();
    DisplayDayOfWeek();
    DisplayDate();

  }

}
Exemplo n.º 7
0
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);
    }                                                   
  }
}
Exemplo n.º 8
0
static void SetTime(NumberEntry *timeEditor)
{
	timeEditor->SetRangeValueAt(0, 2, GetRTCHOUR());
	timeEditor->SetRangeValueAt(3, 2, GetRTCMIN());
	timeEditor->SetRangeValueAt(6, 2, GetRTCSEC());
}
Exemplo n.º 9
0
//---------------------------------------------------------------------------//
//                                                                           //
//函数: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                                        ;
}