char* getDate(){
  char date[] = "00/00/00";
  short day=read_ds1307(4),month=read_ds1307(5),year=read_ds1307(6);
  date[0] = BCD2UpperCh(day);
  date[1] = BCD2LowerCh(day);
  date[3] = BCD2UpperCh(month);
  date[4] = BCD2LowerCh(month);
  date[6] = BCD2UpperCh(year);
  date[7] = BCD2LowerCh(year);
  return date;
}
Exemple #2
0
uint32_t read_unix_time()
{
	DS1307 time;
	read_ds1307(&time); 
	uint32_t unixtime = time2long(date2days(time.year, time.month, time.day), time.hour, time.minute, time.second);
	return unixtime + SECONDS_FROM_1970_TO_2000;
}
char* getTime(){
  char time[] = "00:00:00 AM";
  short fullHr = read_ds1307(2);
  short hr = fullHr & 0b00011111;
  short ap = fullHr & 0b00100000;
  short min = read_ds1307(1);
  short sec=read_ds1307(0);
  time[0] = BCD2UpperCh(hr);
  time[1] = BCD2LowerCh(hr);
  time[3] = BCD2UpperCh(min);
  time[4] = BCD2LowerCh(min);
  time[6] = BCD2UpperCh(sec);
  time[7] = BCD2LowerCh(sec);
  time[10] = 'M';
  if(ap)
    time[9] = 'P';
  else
    time[9] = 'A';
  return time;
}