Beispiel #1
0
struct time elapsedTime(struct time t1,struct time t2)
{
  struct time timeDifference;
  long int totalSeconds1,totalSeconds2;
  totalSeconds1=timeToSeconds(t1);
  totalSeconds2=timeToSeconds(t2);
  timeDifference=secondsToTime(totalSeconds2-totalSeconds1);
  return timeDifference;
}
Beispiel #2
0
void drawTime(int seconds)
{
	int newSeconds;
	int newMinutes;

	secondsToTime(seconds,&newSeconds,&newMinutes);

	drawNum(newSeconds/10, 926, 35);
	drawNum(newSeconds%10, 938, 35);
	vg_draw("/usr/src/drivers/proj/images/image_10.mg", 22, 8, 950, 35);
	drawNum(newMinutes/10, 958, 35);
	drawNum(newMinutes%10, 970, 35);
}
Beispiel #3
0
int
main (void)
{
 trace_puts (PROJNAME);

 initIO();
 initIRQ();
 initDWT();
 initSPI();

 PCD8544_Init (0x38);

 char buf[25];
 struct time_types tm;
 uint8_t x, y;

 PCD8544_GotoXY (0, 0);
 PCD8544_Puts ("SirVolta's", PCD8544_Pixel_Set, PCD8544_FontSize_5x7);
 PCD8544_GotoXY (0, PCD8544_GetX_Y(PCD8544_Pos_Y) + PCD8544_CHAR5x7_HEIGHT + 1);
 PCD8544_Puts ("Library", PCD8544_Pixel_Set, PCD8544_FontSize_5x7);
 PCD8544_GotoXY (0, PCD8544_GetX_Y(PCD8544_Pos_Y) + (PCD8544_CHAR5x7_HEIGHT * 2) + 1);
 PCD8544HorizontalLine(PCD8544_GetX_Y(PCD8544_Pos_Y) - (PCD8544_CHAR5x7_HEIGHT  / 2));
 PCD8544HorizontalLine(PCD8544_GetX_Y(PCD8544_Pos_Y) + (PCD8544_CHAR5x7_HEIGHT + 3));

 for (uint8_t i = 10; i > 2; i -= 2)
  PCD8544_DrawCircle(65, 10, i, PCD8544_Pixel_Set);
 PCD8544_DrawFilledCircle(65, 10, 2, PCD8544_Pixel_Set);

 PCD8544_Refresh ();

 PCD8544_GetXY(&x, &y);
 while (1)
  {
   GPIO_ToggleBits(LEDPORT, LEDPIN);
   delayMs(1000);

   tm.seconds = (uint32_t)(uptime_ms / 1000);
   secondsToTime(&tm);
   sprintf(buf, "%.2lud%.2luh%.2lum%.2lus\n", tm.days, tm.hours, tm.minutes, tm.seconds);


   //clear line of text, then print it to display
   PCD8544_DrawFilledRectangle(x, y, x + PCD8544_WIDTH, y + PCD8544_CHAR5x7_HEIGHT, PCD8544_Pixel_Clear);
   PCD8544_GotoXY (x, y);
   PCD8544_Puts (buf, PCD8544_Pixel_Set, PCD8544_FontSize_5x7);
   PCD8544_Refresh ();
  }
}
Beispiel #4
0
double
CInterval::
interval(int i) const
{
  if       (isDate()) {
    if      (timeType_ == TimeType::YEARS) {
      return yearsToTime(startTime_.year + i*calcIncrement());
    }
    else if (timeType_ == TimeType::MONTHS) {
      return monthsToTime(startTime_, startTime_.month + i*calcIncrement());
    }
    else if (timeType_ == TimeType::DAYS) {
      return daysToTime(startTime_, startTime_.day + i*calcIncrement());
    }
    else {
      return 0;
    }
  }
  else if (isTime()) {
    if      (timeType_ == TimeType::HOURS) {
      return hoursToTime(startTime_, startTime_.hour + i*calcIncrement());
    }
    else if (timeType_ == TimeType::MINUTES) {
      return minutesToTime(startTime_, startTime_.minute + i*calcIncrement());
    }
    else if (timeType_ == TimeType::SECONDS) {
      return secondsToTime(startTime_, startTime_.second + i*calcIncrement());
    }
    else {
      return 0;
    }
  }
  else {
    return valueStart() + i*calcIncrement();
  }
}