1-Wire API for .NET Version 4.00
|
Inherits com::dalsemi::onewire::container::OneWireContainer, com::dalsemi::onewire::container::ADContainer, and com::dalsemi::onewire::container::TemperatureContainer.
Public Member Functions | |
OneWireContainer30 () | |
Default constructor. | |
OneWireContainer30 (DSPortAdapter sourceAdapter, byte[] newAddress) | |
Creates a container with a provided adapter object and the address of this 1-Wire device. | |
OneWireContainer30 (DSPortAdapter sourceAdapter, long newAddress) | |
Creates a container with a provided adapter object and the address of this 1-Wire device. | |
OneWireContainer30 (DSPortAdapter sourceAdapter, String newAddress) | |
Creates a container with a provided adapter object and the address of this 1-Wire device. | |
String | getName () |
Returns the Maxim Integrated Products part number of this 1-Wire device as a string. | |
String | getAlternateNames () |
Returns the alternate Maxim Integrated Products part number or name. | |
String | getDescription () |
Returns a short description of the function of this 1-Wire device type. | |
Enumeration | getMemoryBanks () |
Get an enumeration of memory bank instances that implement one or more of the following interfaces: MemoryBank, PagedMemoryBank, and OTPMemoryBank. | |
synchronized void | setResistorInternal () |
Sets the DS2760 to use its internal .025 ohm resistor for measurements. | |
synchronized void | setResistorExternal (double Rsens) |
Sets the DS2760 to use an external, user-selectable resistance. | |
byte | readByte (int memAddr) throws OneWireIOException, OneWireException |
Reads a register byte from the memory of the DS2760. | |
void | readBytes (int memAddr, byte[] buffer, int start, int len) throws OneWireIOException, OneWireException |
Reads bytes from the DS2760. | |
void | writeByte (int memAddr, byte data) throws OneWireIOException, OneWireException |
Writes a register byte to the memory of the DS2760. | |
byte[] | readEEPROMBlock (int blockNumber) throws OneWireIOException, OneWireException |
Reads a 16 byte data block from one of the user EEPROM blocks. | |
void | writeEEPROMBlock (int blockNumber, byte[] data) throws OneWireIOException, OneWireException |
Writes a 16 byte data block to one of the user blocks. | |
void | lockBlock (int blockNumber) throws OneWireIOException, OneWireException |
Permanently write-protects one of the user blocks of EEPROM. | |
boolean | getFlag (int memAddr, byte flagToGet) throws OneWireIOException, OneWireException |
Checks the specified flag in the specified register. | |
void | setFlag (int memAddr, byte flagToSet, boolean flagValue) throws OneWireIOException, OneWireException |
Sets one of the flags in one of the registers. | |
double | getCurrent (byte[] state) throws OneWireIOException, OneWireException |
Gets the instantaneous current. | |
void | setRemainingCapacity (double remainingCapacity) throws OneWireIOException, OneWireException |
Allows user to set the remaining capacity. | |
double | getRemainingCapacity (byte[] state) throws OneWireIOException, OneWireException |
Calculates the remaining capacity in mAHours from the current Accumulator. | |
void | setLatchState (boolean on) throws OneWireIOException, OneWireException |
Sets the state for the Programmable Input/Output pin. | |
boolean | getLatchState () throws OneWireIOException, OneWireException |
Returns the latch state of the Programmable Input/Ouput pin on the DS2760. | |
void | clearConditions () throws OneWireIOException, OneWireException |
Clears the overvoltage, undervoltage, charge overcurrent, and discharge overcurrent flags. | |
int | getNumberADChannels () |
Queries to get the number of channels supported by this A/D device. | |
boolean | hasADAlarms () |
Queries to see if this A/D measuring device has high/low alarms. | |
double[] | getADRanges (int channel) |
Queries to get an array of available ranges for the specified A/D channel. | |
double[] | getADResolutions (int channel, double range) |
Queries to get an array of available resolutions based on the specified range on the specified A/D channel. | |
boolean | canADMultiChannelRead () |
Queries to see if this A/D device supports doing multiple voltage conversions at the same time. | |
void | doADConvert (int channel, byte[] state) throws OneWireIOException, OneWireException |
Performs voltage conversion on the specified channel. | |
void | doADConvert (boolean[] doConvert, byte[] state) throws OneWireIOException, OneWireException |
Performs voltage conversion on all specified channels. | |
double[] | getADVoltage (byte[] state) throws OneWireIOException, OneWireException |
Reads the voltage values. | |
double | getADVoltage (int channel, byte[] state) throws OneWireIOException, OneWireException |
Reads a channel voltage value. | |
double | getADAlarm (int channel, int alarmType, byte[] state) throws OneWireException |
Extracts the alarm voltage value of the specified channel from the provided state buffer. | |
boolean | getADAlarmEnable (int channel, int alarmType, byte[] state) throws OneWireException |
Extracts the alarm enable value of the specified channel from the provided state buffer. | |
boolean | hasADAlarmed (int channel, int alarmType, byte[] state) throws OneWireException |
Checks the A/D alarm event value of the specified channel from the provided state buffer. | |
double | getADResolution (int channel, byte[] state) |
Extracts the A/D conversion resolution of the specified channel from the provided state buffer expressed in volts. | |
double | getADRange (int channel, byte[] state) |
Extracts the A/D input voltage range of the specified channel from the provided state buffer. | |
void | setADAlarm (int channel, int alarmType, double alarm, byte[] state) throws OneWireException |
Sets the A/D alarm voltage value of the specified channel in the provided state buffer. | |
void | setADAlarmEnable (int channel, int alarmType, boolean alarmEnable, byte[] state) throws OneWireException |
Sets the A/D alarm enable value of the specified channel in the provided state buffer. | |
void | setADResolution (int channel, double resolution, byte[] state) |
Sets the A/D conversion resolution value for the specified channel in the provided state buffer. | |
void | setADRange (int channel, double range, byte[] state) |
Sets the A/D input range for the specified channel in the provided state buffer. | |
boolean | hasTemperatureAlarms () |
Queries to see if this temperature measuring device has high/low trip alarms. | |
boolean | hasSelectableTemperatureResolution () |
Queries to see if this device has selectable temperature resolution. | |
double[] | getTemperatureResolutions () |
Queries to get an array of available temperature resolutions in degrees C. | |
double | getTemperatureAlarmResolution () throws OneWireException |
Queries to get the high/low temperature alarm resolution in degrees C. | |
double | getMaxTemperature () |
Queries to get the maximum temperature in degrees C. | |
double | getMinTemperature () |
Queries to get the minimum temperature in degrees C. | |
void | doTemperatureConvert (byte[] state) throws OneWireIOException, OneWireException |
Performs a temperature conversion. | |
double | getTemperature (byte[] state) |
Extracts the temperature value in degrees C from the state data retrieved from the readDevice() method. | |
double | getTemperatureAlarm (int alarmType, byte[] state) throws OneWireException |
Extracts the specified temperature alarm value in degrees C from the state data retrieved from the readDevice() method. | |
double | getTemperatureResolution (byte[] state) |
Extracts the current temperature resolution in degrees C from the state data retrieved from the readDevice() method. | |
void | setTemperatureAlarm (int alarmType, double alarmValue, byte[] state) throws OneWireException, OneWireIOException |
Sets the temperature alarm value in degrees C in the provided state data. | |
void | setTemperatureResolution (double resolution, byte[] state) throws OneWireException, OneWireIOException |
Sets the current temperature resolution in degrees C in the provided state data. | |
byte[] | readDevice () throws OneWireIOException, OneWireException |
Retrieves the 1-Wire device sensor state. | |
void | writeDevice (byte[] state) throws OneWireIOException, OneWireException |
Writes the 1-Wire device sensor state that have been changed by the 'set' methods. | |
Static Public Attributes | |
static final byte | PROTECTION_REGISTER = 0 |
Address of the Protection Register. | |
static final byte | STATUS_REGISTER = 1 |
Address of the Status Register. | |
static final byte | EEPROM_REGISTER = 7 |
Address of the EEPROM Register. | |
static final byte | SPECIAL_FEATURE_REGISTER = 8 |
Address of the Special Feature Register (SFR). | |
static final byte | OVERVOLTAGE_FLAG = ( byte ) 128 |
PROTECTION REGISTER FLAG: When this flag is true , it indicates that the battery pack has experienced an overvoltage condition. | |
static final byte | UNDERVOLTAGE_FLAG = 64 |
PROTECTION REGISTER FLAG: When this flag is true , the battery pack has experienced an undervoltage. | |
static final byte | CHARGE_OVERCURRENT_FLAG = 32 |
PROTECTION REGISTER FLAG: When this flag is true the battery has experienced a charge-direction overcurrent condition. | |
static final byte | DISCHARGE_OVERCURRENT_FLAG = 16 |
PROTECTION REGISTER FLAG: When this flag is true the battery has experienced a discharge-direction overcurrent condition. | |
static final byte | CC_PIN_STATE_FLAG = 8 |
PROTECTION REGISTER FLAG: Mirrors the !CC output pin. | |
static final byte | DC_PIN_STATE_FLAG = 4 |
PROTECTION REGISTER FLAG: Mirrors the !DC output pin. | |
static final byte | CHARGE_ENABLE_FLAG = 2 |
PROTECTION REGISTER FLAG: Reseting this flag will disable charging regardless of cell or pack conditions. | |
static final byte | DISCHARGE_ENABLE_FLAG = 1 |
PROTECTION REGISTER FLAG: Reseting this flag will disable discharging. | |
static final byte | SLEEP_MODE_ENABLE_FLAG = 32 |
STATUS REGISTER FLAG: Enables/disables the DS2760 to enter sleep mode when the DQ line goes low for greater than 2 seconds. | |
static final byte | READ_NET_ADDRESS_OPCODE_FLAG = 16 |
STATUS REGISTER FLAG: If set, the opcode for the Read Net Address command will be set to 33h. | |
static final byte | EEPROM_COPY_FLAG = ( byte ) 128 |
EEPROM REGISTER FLAG: This flag will be true if the Copy Data Command is in progress. | |
static final byte | EEPROM_LOCK_ENABLE_FLAG = 64 |
EEPROM REGISTER FLAG: When this flag is true , the Lock Command is enabled. | |
static final byte | EEPROM_BLOCK_1_LOCK_FLAG = 2 |
EEPROM REGISTER FLAG: When this flag is true , Block 1 of the EEPROM (addresses 48-63) is read-only. | |
static final byte | EEPROM_BLOCK_0_LOCK_FLAG = 1 |
EEPROM REGISTER FLAG: When this flag is true , Block 0 of the EEPROM (addresses 32-47) is read-only. | |
static final byte | PS_PIN_STATE_FLAG = ( byte ) 128 |
SPECIAL FEATURE REGISTER FLAG: Mirrors the state of the !PS pin. | |
static final byte | PIO_PIN_SENSE_AND_CONTROL_FLAG = 64 |
SPECIAL FEATURE REGISTER FLAG: Mirrors/sets the state of the PIO pin. |
1-Wire® container that encapsulates the functionality of the 1-Wire family type 30 (hex), Maxim Integrated Products part number: DS2760, High Precision Li-ion Battery Monitor.
http://pdfserv.maxim-ic.com/arpdf/DS2760.pdf
Converted to use interfaces, general rework KLA
OneWireContainer30 | ( | DSPortAdapter | sourceAdapter, |
byte[] | newAddress | ||
) |
Creates a container with a provided adapter object and the address of this 1-Wire device.
sourceAdapter | adapter object required to communicate with this 1-Wire device |
newAddress | address of this 1-Wire device |
OneWireContainer30 | ( | DSPortAdapter | sourceAdapter, |
long | newAddress | ||
) |
Creates a container with a provided adapter object and the address of this 1-Wire device.
sourceAdapter | adapter object required to communicate with this 1-Wire device |
newAddress | address of this 1-Wire device |
OneWireContainer30 | ( | DSPortAdapter | sourceAdapter, |
String | newAddress | ||
) |
Creates a container with a provided adapter object and the address of this 1-Wire device.
sourceAdapter | adapter object required to communicate with this 1-Wire device |
newAddress | address of this 1-Wire device |
boolean canADMultiChannelRead | ( | ) |
Queries to see if this A/D device supports doing multiple voltage conversions at the same time.
true
if can do multi-channel voltage reads Implements ADContainer.
void clearConditions | ( | ) | throws OneWireIOException, OneWireException |
Clears the overvoltage, undervoltage, charge overcurrent, and discharge overcurrent flags.
Each time a violation occurs, these flags stay set until reset. This method resets all 4 flags.
OneWireIOException | Error writting data |
OneWireException | Could not find part |
void doADConvert | ( | int | channel, |
byte[] | state | ||
) | throws OneWireIOException, OneWireException |
Performs voltage conversion on the specified channel.
The method getADVoltage()
can be used to read the result of the conversion.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
state | current state of this device returned from readDevice() |
OneWireIOException | Error writting data |
OneWireException | Could not find device |
Implements ADContainer.
void doADConvert | ( | boolean[] | doConvert, |
byte[] | state | ||
) | throws OneWireIOException, OneWireException |
Performs voltage conversion on all specified channels.
The method getADVoltage()
can be used to read the result of the conversion. This A/D must support multi-channel read canMultiChannelRead()
if there are more than 1 channel is specified.
doConvert | channels to perform conversion on |
state | current state of the device returned from readDevice() |
OneWireIOException | Error writting data |
OneWireException | Device does not support multi-channel reading |
Implements ADContainer.
void doTemperatureConvert | ( | byte[] | state | ) | throws OneWireIOException, OneWireException |
Performs a temperature conversion.
state | device state |
OneWireIOException | Error writting data |
OneWireException | Could not find device |
Implements TemperatureContainer.
double getADAlarm | ( | int | channel, |
int | alarmType, | ||
byte[] | state | ||
) | throws OneWireException |
Extracts the alarm voltage value of the specified channel from the provided state buffer.
The state buffer is retrieved from the readDevice()
method.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
alarmType | desired alarm, ALARM_HIGH (1) or ALARM_LOW (0) |
state | current state of the device returned from readDevice() |
OneWireException | Device does not support A/D alarms |
Implements ADContainer.
boolean getADAlarmEnable | ( | int | channel, |
int | alarmType, | ||
byte[] | state | ||
) | throws OneWireException |
Extracts the alarm enable value of the specified channel from the provided state buffer.
The state buffer is retrieved from the readDevice()
method.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
alarmType | desired alarm, ALARM_HIGH (1) or ALARM_LOW (0) |
state | current state of the device returned from readDevice() |
true
if specified alarm is enabledOneWireException | Device does not support A/D alarms |
Implements ADContainer.
double getADRange | ( | int | channel, |
byte[] | state | ||
) |
Extracts the A/D input voltage range of the specified channel from the provided state buffer.
The state buffer is retrieved from the readDevice()
method.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
state | current state of the device returned from readDevice() |
Implements ADContainer.
double [] getADRanges | ( | int | channel | ) |
Queries to get an array of available ranges for the specified A/D channel.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
Implements ADContainer.
double getADResolution | ( | int | channel, |
byte[] | state | ||
) |
Extracts the A/D conversion resolution of the specified channel from the provided state buffer expressed in volts.
The state is retrieved from the readDevice()
method.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
state | current state of the device returned from readDevice() |
Implements ADContainer.
double [] getADResolutions | ( | int | channel, |
double | range | ||
) |
Queries to get an array of available resolutions based on the specified range on the specified A/D channel.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
range | range of channel specified in channel parameter |
Implements ADContainer.
double getADVoltage | ( | int | channel, |
byte[] | state | ||
) | throws OneWireIOException, OneWireException |
Reads a channel voltage value.
Must be used after a doADConvert()
method call. Also must include the last valid state from the readDevice()
method. Note, if more than one channel is to be read then it is more efficient to use the getADVoltage(byte[])
method that returns all channel values.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
state | current state of the device returned from readDevice() |
OneWireIOException | Error reading data |
OneWireException | Could not find device |
Implements ADContainer.
double [] getADVoltage | ( | byte[] | state | ) | throws OneWireIOException, OneWireException |
Reads the voltage values.
Must be used after a doADConvert()
method call. Also must include the last valid state from the readDevice()
method and this A/D must support multi-channel read canMultiChannelRead()
if there are more than 1 channel.
state | current state of the device returned from readDevice() |
OneWireIOException | Error writting data |
OneWireException | Device does not support multi-channel reading |
Implements ADContainer.
String getAlternateNames | ( | ) |
Returns the alternate Maxim Integrated Products part number or name.
ie. Smart Battery Monitor
Reimplemented from OneWireContainer.
double getCurrent | ( | byte[] | state | ) | throws OneWireIOException, OneWireException |
Gets the instantaneous current.
state | device state |
OneWireIOException | Error reading data |
OneWireException | Could not find part |
String getDescription | ( | ) |
Returns a short description of the function of this 1-Wire device type.
Reimplemented from OneWireContainer.
boolean getFlag | ( | int | memAddr, |
byte | flagToGet | ||
) | throws OneWireIOException, OneWireException |
Checks the specified flag in the specified register.
Valid registers are: PROTECTION_REGISTER
, STATUS_REGISTER
, EEPROM_REGISTER
and SPECIAL_FEATURE_REGISTER
.
memAddr | registers address. Pre-defined fields for each register are defined above. |
flagToGet | bitmask of desired flag, the acceptable parameters pertaining to each register are defined as constant fields above |
true
if flag is set (=1)OneWireIOException | Error reading data |
OneWireException | Could not find part |
boolean getLatchState | ( | ) | throws OneWireIOException, OneWireException |
Returns the latch state of the Programmable Input/Ouput pin on the DS2760.
OneWireIOException | Error reading data |
OneWireException | Could not find part |
double getMaxTemperature | ( | ) |
Queries to get the maximum temperature in degrees C.
Implements TemperatureContainer.
Enumeration getMemoryBanks | ( | ) |
Get an enumeration of memory bank instances that implement one or more of the following interfaces: MemoryBank, PagedMemoryBank, and OTPMemoryBank.
Enumeration
of memory banks Reimplemented from OneWireContainer.
double getMinTemperature | ( | ) |
Queries to get the minimum temperature in degrees C.
Implements TemperatureContainer.
String getName | ( | ) |
Returns the Maxim Integrated Products part number of this 1-Wire device as a string.
Reimplemented from OneWireContainer.
int getNumberADChannels | ( | ) |
Queries to get the number of channels supported by this A/D device.
Channel specific methods will use a channel number specified by an integer from [0 to (getNumberChannels() - 1)]
.
Implements ADContainer.
double getRemainingCapacity | ( | byte[] | state | ) | throws OneWireIOException, OneWireException |
Calculates the remaining capacity in mAHours from the current Accumulator.
Accurate to +/- .25 mAH.
state | device state |
OneWireIOException | Error reading data |
OneWireException | Could not find part |
double getTemperature | ( | byte[] | state | ) |
Extracts the temperature value in degrees C from the state data retrieved from the readDevice()
method.
state | device state |
doTemperatureConvert()
Implements TemperatureContainer.
double getTemperatureAlarm | ( | int | alarmType, |
byte[] | state | ||
) | throws OneWireException |
Extracts the specified temperature alarm value in degrees C from the state data retrieved from the readDevice()
method.
alarmType | trip type ALARM_HIGH (1) or ALARM_LOW (0) |
state | device state |
OneWireException | Device does not support temerature alarms |
Implements TemperatureContainer.
double getTemperatureAlarmResolution | ( | ) | throws OneWireException |
Queries to get the high/low temperature alarm resolution in degrees C.
OneWireException | Device does not support temperature alarms |
Implements TemperatureContainer.
double getTemperatureResolution | ( | byte[] | state | ) |
Extracts the current temperature resolution in degrees C from the state data retrieved from the readDevice()
method.
state | device state |
Implements TemperatureContainer.
double [] getTemperatureResolutions | ( | ) |
Queries to get an array of available temperature resolutions in degrees C.
Implements TemperatureContainer.
boolean hasADAlarmed | ( | int | channel, |
int | alarmType, | ||
byte[] | state | ||
) | throws OneWireException |
Checks the A/D alarm event value of the specified channel from the provided state buffer.
The state buffer is retrieved from the readDevice()
method.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
alarmType | desired alarm, ALARM_HIGH (1) or ALARM_LOW (0) |
state | current state of the device returned from readDevice() |
true
if specified alarm occurredOneWireException | Device does not support A/D alarms |
Implements ADContainer.
boolean hasADAlarms | ( | ) |
Queries to see if this A/D measuring device has high/low alarms.
true
if has high/low trips Implements ADContainer.
boolean hasSelectableTemperatureResolution | ( | ) |
Queries to see if this device has selectable temperature resolution.
true
if has selectable temperature resolution Implements TemperatureContainer.
boolean hasTemperatureAlarms | ( | ) |
Queries to see if this temperature measuring device has high/low trip alarms.
true
if has high/low temperature trip alarms Implements TemperatureContainer.
void lockBlock | ( | int | blockNumber | ) | throws OneWireIOException, OneWireException |
Permanently write-protects one of the user blocks of EEPROM.
blockNumber | block number to permanently write protect, acceptable parameters are 0 and 1. |
OneWireIOException | Error locking block |
OneWireException | Could not find part |
byte readByte | ( | int | memAddr | ) | throws OneWireIOException, OneWireException |
Reads a register byte from the memory of the DS2760.
Note that there is no error checking as the DS2760 performs no CRC on the data.
Note: This function should only be used when reading the register memory of the DS2760. The EEPROM blocks (addresses 32-64) should be accessed with writeBlock/readBlock.
memAddr | the address to read (0-255) |
OneWireIOException | Error reading data |
OneWireException | Could not find part |
void readBytes | ( | int | memAddr, |
byte[] | buffer, | ||
int | start, | ||
int | len | ||
) | throws OneWireIOException, OneWireException |
Reads bytes from the DS2760.
Note that there is no error-checking as the DS2760 does not perform a CRC on the data.
Note: This function should only be used when reading the register memory of the DS2760. The EEPROM blocks (addresses 32-64) should be accessed with writeBlock/readBlock.
memAddr | the address to read (0-255) |
buffer | buffer to receive data |
start | start position within buffer to place data |
len | length of buffer |
OneWireIOException | Error reading data |
OneWireException | Could not find part |
byte [] readDevice | ( | ) | throws OneWireIOException, OneWireException |
Retrieves the 1-Wire device sensor state.
This state is returned as a byte array. Pass this byte array to the static query and set methods. If the device state needs to be changed then call the writeDevice()
to finalize the one or more change. With the DS2760, there are no CRC checks on data. To ensure the integrity of this data, call twice and make sure only fields expected to change have changed. This method returns bytes 0 to 31 of the memory. Many applications will not need to worry about the lack of CRC checks.
OneWireIOException | Error reading data |
OneWireException | Could not find device |
Implements OneWireSensor.
byte [] readEEPROMBlock | ( | int | blockNumber | ) | throws OneWireIOException, OneWireException |
Reads a 16 byte data block from one of the user EEPROM blocks.
Note that there is no error-checking as the DS2760 performs no CRCs.
blockNumber | the EEPROM block number to read, acceptable parameters are 0 and 1 |
OneWireIOException | Error reading data |
OneWireException | Could not find part |
void setADAlarm | ( | int | channel, |
int | alarmType, | ||
double | alarm, | ||
byte[] | state | ||
) | throws OneWireException |
Sets the A/D alarm voltage value of the specified channel in the provided state buffer.
The state buffer is retrieved from the readDevice()
method. The method writeDevice()
must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice()
.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
alarmType | desired alarm, ALARM_HIGH (1) or ALARM_LOW (0) |
alarm | A/D alarm value (will be reduced to 8 bit resolution) |
state | current state of the device returned from readDevice() |
OneWireException | Device does not support A/D alarms |
Implements ADContainer.
void setADAlarmEnable | ( | int | channel, |
int | alarmType, | ||
boolean | alarmEnable, | ||
byte[] | state | ||
) | throws OneWireException |
Sets the A/D alarm enable value of the specified channel in the provided state buffer.
The state buffer is retrieved from the readDevice()
method. The method writeDevice()
must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice()
.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
alarmType | desired alarm, ALARM_HIGH (1) or ALARM_LOW (0) |
alarmEnable | A/D alarm enable value |
state | current state of the device returned from readDevice() |
OneWireException | Device does not support A/D alarms |
Implements ADContainer.
void setADRange | ( | int | channel, |
double | range, | ||
byte[] | state | ||
) |
Sets the A/D input range for the specified channel in the provided state buffer.
The state buffer is retrieved from the readDevice()
method. The method writeDevice()
must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice()
.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
range | max A/D volt range, use getRanges() method to get available ranges |
state | current state of the device returned from readDevice() |
Implements ADContainer.
void setADResolution | ( | int | channel, |
double | resolution, | ||
byte[] | state | ||
) |
Sets the A/D conversion resolution value for the specified channel in the provided state buffer.
The state buffer is retrieved from the readDevice()
method. The method writeDevice()
must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice()
.
channel | channel in the range [0 to (getNumberChannels() - 1)] |
resolution | A/D resolution in volts |
state | current state of the device returned from readDevice() |
Implements ADContainer.
void setFlag | ( | int | memAddr, |
byte | flagToSet, | ||
boolean | flagValue | ||
) | throws OneWireIOException, OneWireException |
Sets one of the flags in one of the registers.
Valid registers are: PROTECTION_REGISTER
, STATUS_REGISTER
, EEPROM_REGISTER
and SPECIAL_FEATURE_REGISTER
.
memAddr | register address, these addresses are predefined above |
flagToSet | bitmask of flag to set, valid parameters pertaining to each register are defined as constant fields above |
flagValue | value to set the flag to |
OneWireIOException | Error setting flag |
OneWireException | Could not find part |
void setLatchState | ( | boolean | on | ) | throws OneWireIOException, OneWireException |
Sets the state for the Programmable Input/Output pin.
In order to operate as a switch, PIO must be tied to a pull-up resistor to VDD.
on | state of the PIO pin to set |
OneWireIOException | Error writting data |
OneWireException | Could not find part |
void setRemainingCapacity | ( | double | remainingCapacity | ) | throws OneWireIOException, OneWireException |
Allows user to set the remaining capacity.
Good for accurate capacity measurements using temperature and battery life.
By measuring the battery's current and voltage when it is fully charged and when it is empty, the voltage corresponding to an empty battery and the current corresponding to a full one can be derived. These values can be detected in user program and the remaining capacity can be set to the empty/full levels accordingly for nice accuracy.
remainingCapacity | remaining capacity in mAH |
OneWireIOException | Error reading data |
OneWireException | Could not find part |
synchronized void setResistorExternal | ( | double | Rsens | ) |
Sets the DS2760 to use an external, user-selectable resistance.
This Resistance should be wired directly to the VSS (negative terminal of the cell).
Rsens | resistance in ohms |
synchronized void setResistorInternal | ( | ) |
Sets the DS2760 to use its internal .025 ohm resistor for measurements.
This should only be enabled if there is NO external resistor physically attached to the device.
void setTemperatureAlarm | ( | int | alarmType, |
double | alarmValue, | ||
byte[] | state | ||
) | throws OneWireException, OneWireIOException |
Sets the temperature alarm value in degrees C in the provided state data.
Use the method writeDevice()
with this data to finalize the change to the device.
alarmType | trip type ALARM_HIGH (1) or ALARM_LOW (0) |
alarmValue | high/low temperature trip value in degrees C |
state | device state |
OneWireIOException | Error writting data |
OneWireException | Device does not support temperature alarms |
Implements TemperatureContainer.
void setTemperatureResolution | ( | double | resolution, |
byte[] | state | ||
) | throws OneWireException, OneWireIOException |
Sets the current temperature resolution in degrees C in the provided state data.
Use the method writeDevice()
with this data to finalize the change to the device.
resolution | temperature resolution in degrees C |
state | device state |
OneWireIOException | Error writting data |
OneWireException | Could not find device |
Implements TemperatureContainer.
void writeByte | ( | int | memAddr, |
byte | data | ||
) | throws OneWireIOException, OneWireException |
Writes a register byte to the memory of the DS2760.
Note that the DS2760 does not make any use of cyclic redundancy checks (error-checking). To ensure error free transmission, double check write operation.
Note: This method should only be used when writing to the register memory of the DS2760. The EEPROM blocks (addresses 32-64) require special treatment and thus the writeBlock/readBlock functions should be used for those.
memAddr | address to write (0-255) |
data | data byte to write to memory |
OneWireIOException | Error writing data |
OneWireException | Could not find part |
void writeDevice | ( | byte[] | state | ) | throws OneWireIOException, OneWireException |
Writes the 1-Wire device sensor state that have been changed by the 'set' methods.
It knows which registers have changed by looking at the bitmap fields appended to the state data.
state | device state |
OneWireIOException | Error writting data |
OneWireException | Could not find device |
Implements OneWireSensor.
void writeEEPROMBlock | ( | int | blockNumber, |
byte[] | data | ||
) | throws OneWireIOException, OneWireException |
Writes a 16 byte data block to one of the user blocks.
The block may be rewritten at any time, except after it is locked with lockBlock()
. This method performs error checking by verifying data written.
blockNumber | block to write, acceptable parameters are 0 and 1 |
data | 16 bytes of data to write |
OneWireIOException | Error writing data |
OneWireException | Could not find part |
final byte CC_PIN_STATE_FLAG = 8 [static] |
PROTECTION REGISTER FLAG: Mirrors the !CC output pin.
Accessed with getFlag()
final byte CHARGE_ENABLE_FLAG = 2 [static] |
PROTECTION REGISTER FLAG: Reseting this flag will disable charging regardless of cell or pack conditions.
Accessed with getFlag()/setFlag()
.
final byte CHARGE_OVERCURRENT_FLAG = 32 [static] |
PROTECTION REGISTER FLAG: When this flag is true
the battery has experienced a charge-direction overcurrent condition.
This flag must be reset! Accessed with getFlag()
final byte DC_PIN_STATE_FLAG = 4 [static] |
PROTECTION REGISTER FLAG: Mirrors the !DC output pin.
Accessed with getFlag()
final byte DISCHARGE_ENABLE_FLAG = 1 [static] |
PROTECTION REGISTER FLAG: Reseting this flag will disable discharging.
Accessed with getFlag()/setFlag()
.
final byte DISCHARGE_OVERCURRENT_FLAG = 16 [static] |
PROTECTION REGISTER FLAG: When this flag is true
the battery has experienced a discharge-direction overcurrent condition.
This flag must be reset()
! Accessed with getFlag()
final byte EEPROM_BLOCK_0_LOCK_FLAG = 1 [static] |
EEPROM REGISTER FLAG: When this flag is true
, Block 0 of the EEPROM (addresses 32-47) is read-only.
Accessed with getFlag()
.
final byte EEPROM_BLOCK_1_LOCK_FLAG = 2 [static] |
EEPROM REGISTER FLAG: When this flag is true
, Block 1 of the EEPROM (addresses 48-63) is read-only.
Accessed with getFlag()
.
final byte EEPROM_COPY_FLAG = ( byte ) 128 [static] |
EEPROM REGISTER FLAG: This flag will be true
if the Copy Data Command is in progress.
Data may be written to EEPROM when this reads false
. Accessed with getFlag()/setFlag()
.
final byte EEPROM_LOCK_ENABLE_FLAG = 64 [static] |
EEPROM REGISTER FLAG: When this flag is true
, the Lock Command is enabled.
The lock command is used to make memory permanently read only. Accessed with getFlag()/setFlag()
.
final byte EEPROM_REGISTER = 7 [static] |
Address of the EEPROM Register.
Used to set/check flags with setFlag()/getFlag()
.
final byte OVERVOLTAGE_FLAG = ( byte ) 128 [static] |
PROTECTION REGISTER FLAG: When this flag is true
, it indicates that the battery pack has experienced an overvoltage condition.
This flag must be reset! Accessed with getFlag()
.
final byte PIO_PIN_SENSE_AND_CONTROL_FLAG = 64 [static] |
SPECIAL FEATURE REGISTER FLAG: Mirrors/sets the state of the PIO pin.
The PIO pin can be used as an output; resetting this flag disables the PIO output driver. Accessed with getFlag()/setFlag()
.
final byte PROTECTION_REGISTER = 0 [static] |
Address of the Protection Register.
Used to set/check flags with setFlag()/getFlag()
.
final byte PS_PIN_STATE_FLAG = ( byte ) 128 [static] |
SPECIAL FEATURE REGISTER FLAG: Mirrors the state of the !PS pin.
Accessed with getFlag()
.
final byte READ_NET_ADDRESS_OPCODE_FLAG = 16 [static] |
STATUS REGISTER FLAG: If set, the opcode for the Read Net Address command will be set to 33h.
If it is not set the opcode is set to 39h. Accessed with getFlag()/setFlag()
.
final byte SLEEP_MODE_ENABLE_FLAG = 32 [static] |
STATUS REGISTER FLAG: Enables/disables the DS2760 to enter sleep mode when the DQ line goes low for greater than 2 seconds.
Accessed with getFlag()/setFlag()
.
final byte SPECIAL_FEATURE_REGISTER = 8 [static] |
Address of the Special Feature Register (SFR).
Used to check flags with getFlag()
.
final byte STATUS_REGISTER = 1 [static] |
Address of the Status Register.
Used to set/check flags with setFlag()/getFlag()
.
final byte UNDERVOLTAGE_FLAG = 64 [static] |
PROTECTION REGISTER FLAG: When this flag is true
, the battery pack has experienced an undervoltage.
This flag must be reset! Accessed with getFlag()