コード例 #1
0
ファイル: hal_rtc.c プロジェクト: hlipka/MetaWatch-Gen2-hli
static void RestoreRtc(void)
{
  CheckResetCode();
  
  if (niReset == NORMAL_RESET_CODE &&
      BCD_H(RtcHour) >= 0 && BCD_H(RtcHour) <= 2 &&
      BCD_L(RtcHour) >= 0 && BCD_L(RtcHour) <= 9 &&
      BCD_H(RtcMin) >= 0 && BCD_H(RtcMin) <= 6 &&
      BCD_L(RtcMin) >= 0 && BCD_L(RtcMin) <= 9)
  {
    RTCYEAR = RtcYear;
    RTCMON = RtcMon;
    RTCDAY = RtcDay;
    RTCDOW = RtcDow;
    RTCHOUR = RtcHour;
    RTCMIN = RtcMin;
    RTCSEC = RtcSec;
  }
  else
  {
    RTCYEARH = 0x20;
    RTCYEARL = 0x13;
    RTCMON = 0x05;
    RTCDAY = 0x23;
    RTCDOW = 0x05;
    RTCHOUR = 0x11;
    RTCMIN = 0x58;
    RTCSEC = 0x0;
  }  
}
コード例 #2
0
ファイル: LcdBuffer.c プロジェクト: lwalkera/MetaWatch-Gen2
static void DrawMins(unsigned char Op)
{  
  char Min[3];
  Min[0] = BCD_H(RTCMIN) + ZERO;
  Min[1] = BCD_L(RTCMIN) + ZERO;
  Min[2] = NUL;
  DrawString(Min, Op);
}
コード例 #3
0
ファイル: hal_rtc.c プロジェクト: hlipka/MetaWatch-Gen2-hli
unsigned char To12H(unsigned char H24)
{
  unsigned char HH = BCD_H(H24);
  unsigned char HL = BCD_L(H24);

  if (HH == 1 && HL > 2) {HH = 0; HL -= 2;}
  else if (HH == 2) {HH = 0; HL += 8; if (HL > 9) {HL -= 10; HH ++;}}
  return (HH << 4) + HL;
}
コード例 #4
0
ファイル: LcdBuffer.c プロジェクト: lwalkera/MetaWatch-Gen2
static void DrawSecs(void)
{
  //Watch controls time - use default position
  gRow = DEFAULT_SECS_ROW;
  gColumn = DEFAULT_SECS_COL;
  gBitColumnMask = DEFAULT_SECS_COL_BIT;
  SetFont(DEFAULT_SECS_FONT);
  
  char Sec[4];
  Sec[0] = COLON;
  Sec[1] = BCD_H(RTCSEC) + ZERO;
  Sec[2] = BCD_L(RTCSEC) + ZERO;
  Sec[3] = NUL;
  DrawString(Sec, DRAW_OPT_BITWISE_OR);
}
コード例 #5
0
ファイル: LcdBuffer.c プロジェクト: lwalkera/MetaWatch-Gen2
void HourToString(char *Hour)
{
  Hour[0] = RTCHOUR;
  
  if (!GetProperty(PROP_24H_TIME_FORMAT))
  {
    Hour[0] = To12H(Hour[0]);
    if (Hour[0] == 0) Hour[0] = 0x12; // 0am -> 12am
  }

  Hour[1] = BCD_L(Hour[0]) + ZERO;

  Hour[0] = BCD_H(Hour[0]);
  if(!Hour[0]) Hour[0] = SPACE;
  else Hour[0] += ZERO;
}
コード例 #6
0
ファイル: LcdBuffer.c プロジェクト: lwalkera/MetaWatch-Gen2
static void DrawBatteryOnIdleScreen(unsigned char Row, unsigned char Col, etFontType Font)
{
  // Battery
  CopyColumnsIntoMyBuffer(GetBatteryIcon(ICON_SET_BATTERY_V), Row,
    IconInfo[ICON_SET_BATTERY_V].Height, Col, IconInfo[ICON_SET_BATTERY_V].Width);

  SetFont(Font);
  gRow = Row + (Font == MetaWatch7 ? 23 : 21); //29
  gColumn = Col - 1; //8
  gBitColumnMask = (Font == MetaWatch7) ? BIT4 : BIT7;

  unsigned char BattVal = BatteryPercentage();
  
  if (BattVal < 100)
  {
    BattVal = ToBCD(BattVal);
    DrawChar(BattVal > 9 ? BCD_H(BattVal) +ZERO : SPACE, DRAW_OPT_BITWISE_OR);
    DrawChar(BCD_L(BattVal) +ZERO, DRAW_OPT_BITWISE_OR);
  }
  else DrawString("100", DRAW_OPT_BITWISE_OR);

  DrawChar('%', DRAW_OPT_BITWISE_OR);
}
コード例 #7
0
ファイル: LcdBuffer.c プロジェクト: lwalkera/MetaWatch-Gen2
void DrawDateTime(void)
{
  // clean date&time area
  FillMyBuffer(STARTING_ROW, WATCH_DRAW_SCREEN_ROW_NUM, 0x00);

  SetFont(DEFAULT_HOURS_FONT);  
  gRow = DEFAULT_HOURS_ROW;
  gColumn = DEFAULT_HOURS_COL;
  gBitColumnMask = DEFAULT_HOURS_COL_BIT;
  DrawHours(DRAW_OPT_BITWISE_OR);

  gRow = DEFAULT_MINS_ROW;
  gColumn = DEFAULT_MINS_COL;
  gBitColumnMask = DEFAULT_MINS_COL_BIT;
  DrawMins(DRAW_OPT_BITWISE_OR);
  
  if (GetProperty(PROP_TIME_SECOND)) DrawSecs();
  else if (Charging()) DrawBatteryOnIdleScreen(3, 9, MetaWatch5);
  else
  {
    if (!GetProperty(PROP_24H_TIME_FORMAT))
    {
      gRow = DEFAULT_AM_PM_ROW;
      gColumn = DEFAULT_AM_PM_COL;
      gBitColumnMask = DEFAULT_AM_PM_COL_BIT;
      SetFont(DEFAULT_AM_PM_FONT);
      DrawString((RTCHOUR > 11) ? "PM" : "AM", DRAW_OPT_BITWISE_OR);
    }

    gRow = GetProperty(PROP_24H_TIME_FORMAT) ? DEFAULT_DOW_24HR_ROW : DEFAULT_DOW_12HR_ROW;
    gColumn = DEFAULT_DOW_COL;
    gBitColumnMask = DEFAULT_DOW_COL_BIT;
    SetFont(DEFAULT_DOW_FONT);
    DrawString((tString *)DaysOfTheWeek[LANG_EN][RTCDOW], DRAW_OPT_BITWISE_OR);

    //add year when time is in 24 hour mode
    if (GetProperty(PROP_24H_TIME_FORMAT))
    {
      gRow = DEFAULT_DATE_YEAR_ROW;
      gColumn = DEFAULT_DATE_YEAR_COL;
      gBitColumnMask = DEFAULT_DATE_YEAR_COL_BIT;
      SetFont(DEFAULT_DATE_YEAR_FONT);

      unsigned char Year = RTCYEARH;
      DrawChar(BCD_H(Year) + ZERO, DRAW_OPT_BITWISE_OR);
      DrawChar(BCD_L(Year) + ZERO, DRAW_OPT_BITWISE_OR);
      Year = RTCYEARL;
      DrawChar(BCD_H(Year) + ZERO, DRAW_OPT_BITWISE_OR);
      DrawChar(BCD_L(Year) + ZERO, DRAW_OPT_BITWISE_OR);
    }

    //Display month and day
    //Watch controls time - use default date position
    unsigned char DayFirst = GetProperty(PROP_DDMM_DATE_FORMAT);
    char Rtc[2];
    Rtc[DayFirst ? 0 : 1] = RTCDAY;
    Rtc[DayFirst ? 1 : 0] = RTCMON;

    gRow = DEFAULT_DATE_FIRST_ROW;
    gColumn = DEFAULT_DATE_FIRST_COL;
    gBitColumnMask = DEFAULT_DATE_FIRST_COL_BIT;
    SetFont(DEFAULT_DATE_MONTH_FONT);
    
    DrawChar(BCD_H(Rtc[0]) + ZERO, DRAW_OPT_BITWISE_OR);
    DrawChar(BCD_L(Rtc[0]) + ZERO, DRAW_OPT_BITWISE_OR);
    
    //Display separator
    SetFont(DEFAULT_DATE_SEPARATOR_FONT);
    DrawChar(DayFirst ? '.' : '/', DRAW_OPT_BITWISE_OR);
    
    //Display day second
    gRow = DEFAULT_DATE_SECOND_ROW;
    gColumn = DEFAULT_DATE_SECOND_COL;
    gBitColumnMask = DEFAULT_DATE_SECOND_COL_BIT;
    SetFont(DEFAULT_DATE_DAY_FONT);
    
    DrawChar(BCD_H(Rtc[1]) + ZERO, DRAW_OPT_BITWISE_OR);
    DrawChar(BCD_L(Rtc[1]) + ZERO, DRAW_OPT_BITWISE_OR);
  }
  
  SendMyBufferToLcd(STARTING_ROW, WATCH_DRAW_SCREEN_ROW_NUM);
}
コード例 #8
0
ファイル: DebugUart.c プロジェクト: fcengel/MetaWatch-Gen2
static void WriteTime(unsigned char Rtc, unsigned Separator)
{
  WRITE_UART(BCD_H(Rtc) + ZERO);
  WRITE_UART(BCD_L(Rtc) + ZERO);
  WRITE_UART(Separator);
}
コード例 #9
0
ファイル: hal_rtc.c プロジェクト: hlipka/MetaWatch-Gen2-hli
unsigned char ToBin(unsigned char Bcd)
{
 return (((BCD_H(Bcd) << 2) + BCD_H(Bcd)) << 1) + BCD_L(Bcd);
}