BobbyMi / ds1307new

Automatically exported from code.google.com/p/ds1307new
0 stars 0 forks source link

Extend Libary with new functions #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, I extended you libary a bit with couple new things and wanted to share them 
with you.
Daystamp: Calculate Seconds of the day, great for matching times in code with 
current time (if 10:37 do something):
.h -> line 77
.ccp -> line 207 and 524
I'm using a function in code to match times, but maybe this can be integrated 
as well:
float get_ts(int h, int m, int s){
  float r;
  uint32_t t;
  t = h;
  t *= 60;
  t += m;
  t *= 60;
  t += s;
  r=float(t);
  return r;
}

Automaticly set Clock from System time on upload (Seen on RTClib):
.h -> line 31
.ccp -> line 41 to 141 and 225
use:
  if (TimeIsSet != 0xaa55){
    RTC.stopClock();    
    // Uhr Automatisch setzen nach PC Zeit    
    RTC.setTime(DateTime(__DATE__, __TIME__));
    TimeIsSet = 0xaa55;
    RTC.setRAM(54, (uint8_t *)&TimeIsSet, sizeof(uint16_t));
    RTC.startClock();
  }

Hope it will help somebody. ;)

Original issue reported on code.google.com by mstraven...@gmail.com on 3 Apr 2013 at 8:58

Attachments:

GoogleCodeExporter commented 9 years ago
thanks for sharing!

Oliver

Original comment by olikr...@gmail.com on 3 Apr 2013 at 11:16