Module RTC_DS1307 :: Class RTC
[hide private]
[frames] | no frames]

Class RTC

source code

Instance Methods [hide private]
 
__init__(self, type=1, addr=0x68)
Creates a Real Time Clock abstraction using given SMBus type and I2C address
source code
 
_write(self, register, data) source code
 
_read(self, data) source code
 
getSeconds(self)
Returns current seconds.
source code
 
getMinutes(self)
Returns current minutes.
source code
 
getHours(self)
Returns current hours.
source code
 
getDow(self)
Returns current day of week.
source code
 
getDay(self)
Returns current day of month.
source code
 
getMonth(self)
Returns current month.
source code
 
getYear(self)
Returns current year.
source code
 
setDate(self, seconds=None, minutes=None, hours=None, dow=None, day=None, month=None, year=None)
Sets the current date/time.
source code
 
getDate(self)
Returns the current date/time.
source code
 
getDateStr(self)
Returns the current date/time.
source code
Class Variables [hide private]
  _REG_SECONDS = 0x00
  _REG_MINUTES = 0x01
  _REG_HOURS = 0x02
  _REG_DOW = 0x03
  _REG_DAY = 0x04
  _REG_MONTH = 0x05
  _REG_YEAR = 0x06
  _REG_CONTROL = 0x07
Method Details [hide private]

__init__(self, type=1, addr=0x68)
(Constructor)

source code 

Creates a Real Time Clock abstraction using given SMBus type and I2C address

Parameters:
  • type - 0 for RPi model A, 1 for higher versions (default: 1)
  • addr - I2C address (default: 0x68)

getSeconds(self)

source code 

Returns current seconds.

Returns:
seconds of current date/time (0..59)

getMinutes(self)

source code 

Returns current minutes.

Returns:
minutes of current date/time (0..59)

getHours(self)

source code 

Returns current hours.

Returns:
hours of current date/time (0..23)

getDow(self)

source code 

Returns current day of week.

Returns:
day number of current date/time (1..7, 1 for Monday)

getDay(self)

source code 

Returns current day of month.

Returns:
day of current date/time (1..31)

getMonth(self)

source code 

Returns current month.

Returns:
month of current date/time (1..12)

getYear(self)

source code 

Returns current year.

Returns:
year of current date/time (0..99)

setDate(self, seconds=None, minutes=None, hours=None, dow=None, day=None, month=None, year=None)

source code 

Sets the current date/time.
Range: seconds [0,59], minutes [0,59], hours [0,23],
       day_of_week [1,7], day [1-31], month [1-12], year [0-99].
If a parameter is None (default), the current value is unchanged

getDate(self)

source code 

Returns the current date/time.

Returns:
date/time in a tuple with order (year, month, day, dow, hours, minutes, seconds)

getDateStr(self)

source code 

Returns the current date/time.

Returns:
date/time in a string with format year-month-day hours:minutes:seconds