upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

API for the DS1307 Real-Time CLock. More...

Detailed Description

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.

ds1307.jpg
// Instantiate a DS1037 on I2C bus 0
// always do this first
System.out.println("Loading the current time...");
if (!rtc.loadTime()) {
System.err.println("rtc->loadTime() failed.");
System.exit(-1);
}
printTime(rtc);
// set the year as an example
System.out.println("setting the year to 50");
rtc.setYear(50);
rtc.setTime();
// reload the time and print it
rtc.loadTime();
printTime(rtc);

Public Member Functions

synchronized void delete ()
 
 DS1307 (int bus)
 
boolean loadTime ()
 
boolean setTime ()
 
int enableClock ()
 
int disableClock ()
 
int writeBytes (short reg, byte[] buffer)
 
int readBytes (short reg, byte[] buffer)
 
long bcdToDec (short val)
 
short decToBcd (long val)
 
void setSeconds (long value)
 
long getSeconds ()
 
void setMinutes (long value)
 
long getMinutes ()
 
void setHours (long value)
 
long getHours ()
 
void setDayOfWeek (long value)
 
long getDayOfWeek ()
 
void setDayOfMonth (long value)
 
long getDayOfMonth ()
 
void setMonth (long value)
 
long getMonth ()
 
void setYear (long value)
 
long getYear ()
 
void setAmPmMode (boolean value)
 
boolean getAmPmMode ()
 
void setPm (boolean value)
 
boolean getPm ()
 

Constructor & Destructor Documentation

DS1307 ( int  bus)

DS1307 constructor

Parameters
busI2C bus to use

Member Function Documentation

long bcdToDec ( short  val)

Converts a BCD value into decimal

Parameters
valBCD value to convert
Returns
Converted decimal value
short decToBcd ( long  val)

Converts a decimal value into BCD

Parameters
valDecimal value to convert
Returns
Converted BCD value
int disableClock ( )

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
int enableClock ( )

Enables an oscillator on the clock.

Returns
0 (mraa::SUCCESS) if successful; non-zero otherwise
boolean loadTime ( )

Loads all the time values

Returns
True if time data loaded successfully
boolean setTime ( )

Sets the time. You should call loadTime() beforehand to maintain consistency

Returns
True if time is set successfully

The documentation for this class was generated from the following file: