DS1307 Class
- ID: ds1307
- Name: Real Time Clock (RTC) Module
- Other Names: DS1307 RTC
- Category: time
- Manufacturer: seeed
- Connection: i2c
- Link: https://www.maximintegrated.com/en/products/digital/real-time-clocks/DS1307.html
UPM module for the DS1307-based real-time clock. The clock can provide information about seconds, minutes, hours, day of the week, day of the month, month, and year. It can operate in either a 24-hour or a 12-hour format. This device can also output a square wave at 1Khz, 4Khz, 8Khz, and 32Khz. However, this capability is not implemented in this module.
Item Index
Methods
DS1307
-
bus
DS1307 constructor
Parameters:
-
bus
NumberI2C bus to use
Returns:
loadTime
()
Boolean
Loads all the time values
Returns:
True if time data loaded successfully
setTime
()
Boolean
Sets the time. You should call loadTime() beforehand to maintain consistency
Returns:
True if time is set successfully
enableClock
()
Mraa::Result
Enables an oscillator on the clock.
Returns:
0 (mraa::SUCCESS) if successful; non-zero otherwise
disableClock
()
Mraa::Result
Disables the oscillator on the clock. This prevents the clock from updating any time/date values
Returns:
0 (mraa::SUCCESS) if successful; non-zero otherwise
writeBytes
-
reg
-
buffer
-
len
Writes value(s) into registers
Parameters:
-
reg
NumberRegister location to start writing into
-
buffer
Uint8_t *Buffer for data storage
-
len
NumberNumber of bytes to write
Returns:
0 (mraa::SUCCESS) if successful; non-zero otherwise
readBytes
-
reg
-
buffer
-
len
Reads value(s) from registers
Parameters:
-
reg
NumberRegister location to start reading from
-
buffer
Uint8_t *Buffer for data storage
-
len
NumberNumber of bytes to read
Returns:
Number of bytes read
bcdToDec
-
val
Converts a BCD value into decimal
Parameters:
-
val
NumberBCD value to convert
Returns:
Converted decimal value
decToBcd
-
val
Converts a decimal value into BCD
Parameters:
-
val
NumberDecimal value to convert
Returns:
Converted BCD value
Properties
seconds
Number
Holds seconds
minutes
Number
Holds minutes
hours
Number
Holds hours; 1-12 in the am/pm format, 0-23 otherwise
dayOfWeek
Number
Holds a day of the week; 1-7, where 1 is Sunday
dayOfMonth
Number
Holds a day of the month, 1-31
month
Number
Holds a month, 1-12
year
Number
Holds a year, 0-99
amPmMode
Boolean
True if the am/pm format is used, false otherwise
pm
Boolean
For the am/pm format, it is true if it's pm, false otherwise