'/////////////////////////////////////////////////
'///////////////////    ZEGAREK    ///////////////
'/////////////////////////////////////////////////

Getdatetime
:                                                'odczytaj czas
 
I2cstart                                                  ' Generate start code
 
I2cwbyte Ds1307w                                          ' send address
 
I2cwbyte 0                                                ' start address in 1307

 
I2cstart                                                  ' Generate start code
 
I2cwbyte Ds1307r                                          ' send address
 
I2crbyte _sec , Ack
 
I2crbyte _min , Ack                                       ' MINUTES
 
I2crbyte _hour , Ack                                      ' Hours
 
I2crbyte Weekday , Ack                                    ' Day of Week
 
I2crbyte _day , Ack                                       ' Day of Month
 
I2crbyte _month , Ack                                     ' Month of Year
 
I2crbyte _year , Nack                                     ' Year
 
I2cstop
  _sec
= Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour) : Weekday = Makedec(weekday)
  _day
= Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year)
'  Reset Watchdog
Return

Setdate
:                                                    'ustaw datê
  _day
= Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year) : Weekday = Makebcd(weekday)       'przekonwertuj
 
I2cstart                                                  ' Generate start code
 
I2cwbyte Ds1307w
 
I2cwbyte 3
 
I2cwbyte Weekday                                          ' send address
 
I2cwbyte _day                                             ' starting address in 1307
 
I2cwbyte _month
 
I2cwbyte _year
 
I2cstop
'  Reset Watchdog
Return

Settime
:                                                    'ustaw czas
  _sec
= Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)
 
I2cstart                                                  ' Generate start code
 
I2cwbyte Ds1307w                                          ' send address
 
I2cwbyte 0                                                ' starting address in 1307
 
I2cwbyte _sec                                             ' Send Data to SECONDS
 
I2cwbyte _min                                             ' MINUTES
 
I2cwbyte _hour                                            ' Hours
 
I2cstop
'  Reset Watchdog
Return