public class BrickletRealTimeClockV2 extends Device
Modifier and Type | Class and Description |
---|---|
class |
BrickletRealTimeClockV2.Alarm |
static interface |
BrickletRealTimeClockV2.AlarmListener
This listener is triggered every time the current date and time matches the
configured alarm (see
setAlarm(int, int, int, int, int, int, int) ). |
class |
BrickletRealTimeClockV2.DateTime |
static interface |
BrickletRealTimeClockV2.DateTimeListener
This listener is triggered periodically with the period that is set by
setDateTimeCallbackConfiguration(long) . |
class |
BrickletRealTimeClockV2.SPITFPErrorCount |
Device.Identity
Constructor and Description |
---|
BrickletRealTimeClockV2(java.lang.String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addAlarmListener(BrickletRealTimeClockV2.AlarmListener listener)
Adds a Alarm listener.
|
void |
addDateTimeListener(BrickletRealTimeClockV2.DateTimeListener listener)
Adds a DateTime listener.
|
BrickletRealTimeClockV2.Alarm |
getAlarm()
Returns the alarm configuration as set by
setAlarm(int, int, int, int, int, int, int) . |
int |
getBootloaderMode()
Returns the current bootloader mode, see
setBootloaderMode(int) . |
int |
getChipTemperature()
Returns the temperature as measured inside the microcontroller.
|
BrickletRealTimeClockV2.DateTime |
getDateTime()
Returns the current date (including weekday) and the current time of the
real-time.
|
long |
getDateTimeCallbackConfiguration()
Returns the period as set by
setDateTimeCallbackConfiguration(long) . |
Device.Identity |
getIdentity()
Returns the UID, the UID where the Bricklet is connected to,
the position, the hardware and firmware version as well as the
device identifier.
|
int |
getOffset()
Returns the offset as set by
setOffset(int) . |
BrickletRealTimeClockV2.SPITFPErrorCount |
getSPITFPErrorCount()
Returns the error count for the communication between Brick and Bricklet.
|
int |
getStatusLEDConfig()
Returns the configuration as set by
setStatusLEDConfig(int) |
long |
getTimestamp()
Returns the current date and the time of the real-time clock converted to
milliseconds.
|
long |
readUID()
Returns the current UID as an integer.
|
void |
removeAlarmListener(BrickletRealTimeClockV2.AlarmListener listener)
Removes a Alarm listener.
|
void |
removeDateTimeListener(BrickletRealTimeClockV2.DateTimeListener listener)
Removes a DateTime listener.
|
void |
reset()
Calling this function will reset the Bricklet.
|
void |
setAlarm(int month,
int day,
int hour,
int minute,
int second,
int weekday,
int interval)
Configures a repeatable alarm.
|
int |
setBootloaderMode(int mode)
Sets the bootloader mode and returns the status after the requested
mode change was instigated.
|
void |
setDateTime(int year,
int month,
int day,
int hour,
int minute,
int second,
int centisecond,
int weekday)
Sets the current date (including weekday) and the current time.
|
void |
setDateTimeCallbackConfiguration(long period)
Sets the period with which the
BrickletRealTimeClockV2.DateTimeListener listener is triggered
periodically. |
void |
setOffset(int offset)
Sets the offset the real-time clock should compensate for in 2.17 ppm steps
between -277.76 ppm (-128) and +275.59 ppm (127).
|
void |
setStatusLEDConfig(int config)
Sets the status LED configuration.
|
void |
setWriteFirmwarePointer(long pointer)
Sets the firmware pointer for
writeFirmware(int[]) . |
int |
writeFirmware(int[] data)
Writes 64 Bytes of firmware at the position as written by
setWriteFirmwarePointer(long) before. |
void |
writeUID(long uid)
Writes a new UID into flash.
|
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
public static final int DEVICE_IDENTIFIER
public static final java.lang.String DEVICE_DISPLAY_NAME
public static final byte FUNCTION_SET_DATE_TIME
public static final byte FUNCTION_GET_DATE_TIME
public static final byte FUNCTION_GET_TIMESTAMP
public static final byte FUNCTION_SET_OFFSET
public static final byte FUNCTION_GET_OFFSET
public static final byte FUNCTION_SET_DATE_TIME_CALLBACK_CONFIGURATION
public static final byte FUNCTION_GET_DATE_TIME_CALLBACK_CONFIGURATION
public static final byte FUNCTION_SET_ALARM
public static final byte FUNCTION_GET_ALARM
public static final byte FUNCTION_GET_SPITFP_ERROR_COUNT
public static final byte FUNCTION_SET_BOOTLOADER_MODE
public static final byte FUNCTION_GET_BOOTLOADER_MODE
public static final byte FUNCTION_SET_WRITE_FIRMWARE_POINTER
public static final byte FUNCTION_WRITE_FIRMWARE
public static final byte FUNCTION_SET_STATUS_LED_CONFIG
public static final byte FUNCTION_GET_STATUS_LED_CONFIG
public static final byte FUNCTION_GET_CHIP_TEMPERATURE
public static final byte FUNCTION_RESET
public static final byte FUNCTION_WRITE_UID
public static final byte FUNCTION_READ_UID
public static final byte FUNCTION_GET_IDENTITY
public static final int WEEKDAY_MONDAY
public static final int WEEKDAY_TUESDAY
public static final int WEEKDAY_WEDNESDAY
public static final int WEEKDAY_THURSDAY
public static final int WEEKDAY_FRIDAY
public static final int WEEKDAY_SATURDAY
public static final int WEEKDAY_SUNDAY
public static final int ALARM_MATCH_DISABLED
public static final int ALARM_INTERVAL_DISABLED
public static final int BOOTLOADER_MODE_BOOTLOADER
public static final int BOOTLOADER_MODE_FIRMWARE
public static final int BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
public static final int BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
public static final int BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
public static final int BOOTLOADER_STATUS_OK
public static final int BOOTLOADER_STATUS_INVALID_MODE
public static final int BOOTLOADER_STATUS_NO_CHANGE
public static final int BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT
public static final int BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT
public static final int BOOTLOADER_STATUS_CRC_MISMATCH
public static final int STATUS_LED_CONFIG_OFF
public static final int STATUS_LED_CONFIG_ON
public static final int STATUS_LED_CONFIG_SHOW_HEARTBEAT
public static final int STATUS_LED_CONFIG_SHOW_STATUS
public BrickletRealTimeClockV2(java.lang.String uid, IPConnection ipcon)
public void setDateTime(int year, int month, int day, int hour, int minute, int second, int centisecond, int weekday) throws TinkerforgeException
TinkerforgeException
public BrickletRealTimeClockV2.DateTime getDateTime() throws TinkerforgeException
TinkerforgeException
public long getTimestamp() throws TinkerforgeException
TinkerforgeException
public void setOffset(int offset) throws TinkerforgeException
TinkerforgeException
public int getOffset() throws TinkerforgeException
setOffset(int)
.TinkerforgeException
public void setDateTimeCallbackConfiguration(long period) throws TinkerforgeException
BrickletRealTimeClockV2.DateTimeListener
listener is triggered
periodically. A value of 0 turns the listener off.TinkerforgeException
public long getDateTimeCallbackConfiguration() throws TinkerforgeException
setDateTimeCallbackConfiguration(long)
.TinkerforgeException
public void setAlarm(int month, int day, int hour, int minute, int second, int weekday, int interval) throws TinkerforgeException
BrickletRealTimeClockV2.AlarmListener
listener is triggered if the
current date and time matches the configured alarm.
Setting a parameter to -1 means that it should be disabled and doesn't take part
in the match. Setting all parameters to -1 disables the alarm completely.
For example, to make the alarm trigger every day at 7:30 AM it can be
configured as (-1, -1, 7, 30, -1, -1, -1). The hour is set to match 7 and the
minute is set to match 30. The alarm is triggered if all enabled parameters
match.
The interval has a special role. It allows to make the alarm reconfigure itself.
This is useful if you need a repeated alarm that cannot be expressed by matching
the current date and time. For example, to make the alarm trigger every 23
seconds it can be configured as (-1, -1, -1, -1, -1, -1, 23). Internally the
Bricklet will take the current date and time, add 23 seconds to it and set the
result as its alarm. The first alarm will be triggered 23 seconds after the
call. Because the interval is not -1, the Bricklet will do the same again
internally, take the current date and time, add 23 seconds to it and set that
as its alarm. This results in a repeated alarm that triggers every 23 seconds.
The interval can also be used in combination with the other parameters. For
example, configuring the alarm as (-1, -1, 7, 30, -1, -1, 300) results in an
alarm that triggers every day at 7:30 AM and is then repeated every 5 minutes.TinkerforgeException
public BrickletRealTimeClockV2.Alarm getAlarm() throws TinkerforgeException
setAlarm(int, int, int, int, int, int, int)
.TinkerforgeException
public BrickletRealTimeClockV2.SPITFPErrorCount getSPITFPErrorCount() throws TinkerforgeException
TinkerforgeException
public int setBootloaderMode(int mode) throws TinkerforgeException
TinkerforgeException
public int getBootloaderMode() throws TinkerforgeException
setBootloaderMode(int)
.TinkerforgeException
public void setWriteFirmwarePointer(long pointer) throws TinkerforgeException
writeFirmware(int[])
. The pointer has
to be increased by chunks of size 64. The data is written to flash
every 4 chunks (which equals to one page of size 256).
This function is used by Brick Viewer during flashing. It should not be
necessary to call it in a normal user program.TinkerforgeException
public int writeFirmware(int[] data) throws TinkerforgeException
setWriteFirmwarePointer(long)
before. The firmware is written
to flash every 4 chunks.
You can only write firmware in bootloader mode.
This function is used by Brick Viewer during flashing. It should not be
necessary to call it in a normal user program.TinkerforgeException
public void setStatusLEDConfig(int config) throws TinkerforgeException
TinkerforgeException
public int getStatusLEDConfig() throws TinkerforgeException
setStatusLEDConfig(int)
TinkerforgeException
public int getChipTemperature() throws TinkerforgeException
TinkerforgeException
public void reset() throws TinkerforgeException
TinkerforgeException
public void writeUID(long uid) throws TinkerforgeException
TinkerforgeException
public long readUID() throws TinkerforgeException
TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addDateTimeListener(BrickletRealTimeClockV2.DateTimeListener listener)
public void removeDateTimeListener(BrickletRealTimeClockV2.DateTimeListener listener)
public void addAlarmListener(BrickletRealTimeClockV2.AlarmListener listener)
public void removeAlarmListener(BrickletRealTimeClockV2.AlarmListener listener)
Copyright © 2021 Tinkerforge GmbH. All rights reserved.