|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlejos.nxt.I2CSensor
lejos.nxt.addon.RealTimeClock
public class RealTimeClock
Mindsensors Real-Time Clock www.mindsensors.com
Field Summary | |
---|---|
static int |
DEFAULT_RTC_ADDRESS
|
Fields inherited from class lejos.nxt.I2CSensor |
---|
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION |
Fields inherited from interface lejos.nxt.SensorConstants |
---|
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, GREEN, GREEN_INDEX, MAX_AD_RAW, MAX_TYPE, MIN_TYPE, MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW |
Constructor Summary | |
---|---|
RealTimeClock(I2CPort p)
Constructor |
|
RealTimeClock(I2CPort p,
int address)
Constructor |
Method Summary | |
---|---|
String |
getAMPM()
Get RTC AM/PM indication as String. |
byte |
getByte(int loc)
Retrieves RTC RAM byte; can retrieve clock bytes (0-7) |
int |
getCanonicalHour()
Get RTC hour as int. |
Date |
getDate()
Get RTC date and time as a Date object |
String |
getDateString()
Retrieve RTC date as String in mm/dd/yyyy format |
String |
getDateString(boolean usePadding,
boolean dayFirst)
Retrieve RTC date as String |
int |
getDay()
Get RTC day of month as int |
int |
getDayOfWeek()
Get RTC day of week as int |
int |
getHour()
Get RTC hour as int. |
int |
getMinute()
Get RTC minute as int |
int |
getMonth()
Get RTC month as int |
int |
getSecond()
Get RTC second as int |
String |
getTimeString()
Get RTC time as String |
int |
getYear()
Get RTC year as int |
boolean |
isPM()
Get RTC AM/PM indication as boolean flag. |
void |
setByte(int loc,
byte b)
Sets RTC RAM byte to new value |
void |
setDate(int m,
int d,
int y)
Set RTC date to m/d/y. |
void |
setDay(int d)
Set RTC day of month. |
void |
setDayOfWeek(int d)
Set RTC day of week. |
void |
setHour(int h)
Set RTC hour. |
void |
setHour(int h,
boolean isPM)
Set RTC hour using AM/PM format. |
void |
setHourMode(boolean use24h)
Reset RTC hour mode. |
void |
setMinute(int m)
Set RTC minute |
void |
setMonth(int m)
Set RTC month. |
void |
setSecond(int s)
Set RTC seconds |
void |
setTime(int h,
int m,
int s)
Set RTC time. |
void |
setYear(int y)
Set RTC year. |
Methods inherited from class lejos.nxt.I2CSensor |
---|
fetchString, getAddress, getData, getData, getPort, getProductID, getVendorID, getVersion, sendData, sendData, sendData, setAddress |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_RTC_ADDRESS
Constructor Detail |
---|
public RealTimeClock(I2CPort p, int address)
p
- Port used by RTCaddress
- I2C address of the RTCpublic RealTimeClock(I2CPort p)
p
- Port used by RTCMethod Detail |
---|
public int getYear() throws IOException
getYear
in interface Clock
IOException
- if communication to RTC failspublic int getMonth() throws IOException
getMonth
in interface Clock
IOException
- if communication to RTC failspublic int getDay() throws IOException
getDay
in interface Clock
IOException
- if communication to RTC failspublic int getDayOfWeek() throws IOException
getDayOfWeek
in interface Clock
IOException
- if communication to RTC failspublic int getHour() throws IOException
getHour
in interface Clock
IOException
- if communication to RTC failspublic int getCanonicalHour() throws IOException
IOException
- if communication to RTC failspublic boolean isPM() throws IOException
IOException
- if communication to RTC failspublic int getMinute() throws IOException
getMinute
in interface Clock
IOException
- if communication to RTC failspublic int getSecond() throws IOException
getSecond
in interface Clock
IOException
- if communication to RTC failspublic Date getDate() throws IOException
IOException
- if communication to RTC failspublic String getDateString(boolean usePadding, boolean dayFirst) throws IOException
usePadding
- True = always use two digits for day and monthdayFirst
- True = dd/mm/yyyy, false = mm/dd/yyyy
IOException
- if communication to RTC failspublic String getDateString() throws IOException
getDateString
in interface Clock
IOException
- if communication to RTC failspublic String getTimeString() throws IOException
getTimeString
in interface Clock
IOException
- if communication to RTC failspublic String getAMPM() throws IOException
getAMPM
in interface Clock
IOException
- if communication to RTC failspublic void setHour(int h) throws IllegalArgumentException, IOException
h
- New hour count
IllegalArgumentException
- if h < 0 or h > 23
IOException
- if communication to RTC failspublic void setHour(int h, boolean isPM) throws IllegalArgumentException, IOException
h
- Current hour (1-12)isPM
- True = PM; false = AM
IllegalArgumentException
- if h < 1 or h > 12
IOException
- if communication to RTC failspublic void setMinute(int m) throws IllegalArgumentException, IOException
m
- New minute count
IllegalArgumentException
- if m < 0 or m > 59
IOException
- if communication to RTC failspublic void setSecond(int s) throws IllegalArgumentException, IOException
s
- New second count
IllegalArgumentException
- if s < 0 or s > 59
IOException
- if communication to RTC failspublic void setTime(int h, int m, int s) throws IllegalArgumentException, IOException
setTime
in interface Clock
h
- New hourm
- New minutes
- New second
IllegalArgumentException
- if h, m or s are out of bounds
IOException
- if communication to RTC failspublic void setMonth(int m) throws IllegalArgumentException, IOException
m
- New month
IllegalArgumentException
- if m < 1 or m > 12
IOException
- if communication to RTC failspublic void setDay(int d) throws IllegalArgumentException, IOException
d
- New day of month
IllegalArgumentException
- if d is an invalid day of current month
IOException
- if communication to RTC failspublic void setYear(int y) throws IllegalArgumentException, IOException
y
- New year to use
IllegalArgumentException
- if y < 0 or y > 99
IOException
- if communication to RTC failspublic void setDayOfWeek(int d) throws IllegalArgumentException, IOException
d
- New day of week
IllegalArgumentException
- if d < 1 or d > 7
IOException
- if communication to RTC failspublic void setDate(int m, int d, int y) throws IllegalArgumentException, IOException
setDate
in interface Clock
m
- New monthd
- New day of monthy
- New year
IllegalArgumentException
- if m, d or y is invalid
IOException
- if communication to RTC failspublic void setHourMode(boolean use24h) throws IOException
setHourMode
in interface Clock
use24h
- True = use 24-hour format; false = use 12-hour format.
IOException
- if communication to RTC failspublic byte getByte(int loc) throws IndexOutOfBoundsException, IOException
getByte
in interface Clock
loc
- Byte to retrieve, 0 <= loc <= 0x3f
IndexOutOfBoundsException
- if loc < 0 or loc > 63 (0x3f)
IOException
- if communication to RTC failspublic void setByte(int loc, byte b) throws IndexOutOfBoundsException, IOException
setByte
in interface Clock
loc
- Byte to set, 0x08 <= loc <= 0x3fb
- New value of byte
IndexOutOfBoundsException
- if loc < 8 or loc > 63 (0x3f)
IOException
- if communication to RTC fails
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |