Package com.dalsemi.onewire.container
Class OneWireContainer2C
- java.lang.Object
-
- com.dalsemi.onewire.container.OneWireContainer
-
- com.dalsemi.onewire.container.OneWireContainer2C
-
- All Implemented Interfaces:
OneWireSensor
,PotentiometerContainer
public class OneWireContainer2C extends OneWireContainer implements PotentiometerContainer
1-Wire® container that encapsulates the functionality of the 1-Wire family type 2C (hex), Maxim Integrated Products part number: DS2890, 1-Wire Digital Potentiometer.
Features
- Single element 256-position linear taper potentiometer
- Supports potentiometer terminal working voltages up to 11V
- Potentiometer terminal voltage independent of supply voltage
- 100k Ohm resistor element value
- Operating temperature range from -40@htmlonly °C @endhtmlonly to +85@htmlonly °C @endhtmlonly
- 2.8V - 6.0V operating voltage range
Data sheet
http://pdfserv.maxim-ic.com/arpdf/DS2890.pdf
-
-
Field Summary
-
Fields inherited from class com.dalsemi.onewire.container.OneWireContainer
adapter, address, speed, speedFallBackOK
-
-
Constructor Summary
Constructors Constructor Description OneWireContainer2C()
Default constructorOneWireContainer2C(DSPortAdapter sourceAdapter, byte[] newAddress)
Creates a container with a provided adapter object and the address of the 1-Wire device.OneWireContainer2C(DSPortAdapter sourceAdapter, long newAddress)
Creates a container with a provided adapter object and the address of this 1-Wire device.OneWireContainer2C(DSPortAdapter sourceAdapter, java.lang.String newAddress)
Creates a container with a provided adapter object and the address of this 1-Wire device.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
decrement()
Decrements the wiper position after selecting the part.int
decrement(boolean reselect)
Decrements the wiper position.java.lang.String
getAlternateNames()
Retrieves the alternate Maxim Integrated Products part numbers or names.int
getCurrentWiperNumber(byte[] state)
Gets the currently selected wiper number.java.lang.String
getDescription()
Retrieves a short description of the function of this 1-Wire Device.int
getMaxSpeed()
Gets the maximum speed this 1-Wire device can communicate at.java.lang.String
getName()
Retrieves the Maxim Integrated Products part number of this 1-Wire device as a string.int
getWiperPosition()
Gets the current wiper position of this device.int
increment()
Increments the wiper position after selecting the part.int
increment(boolean reselect)
Increments the wiper position.boolean
isChargePumpOn(byte[] state)
Determines if this device's charge pump is enabled.boolean
isLinear(byte[] state)
Queries to see if this Potentiometer One Wire Device has linear potentiometer element(s) or logarithmic potentiometer element(s).int
numberOfPotentiometers(byte[] state)
Queries to see how many potentiometers this Potentiometer One Wire Device has.int
numberOfWiperSettings(byte[] state)
Queries to find the number of wiper settings that any wiper on this Potentiometer One Wire Device can have.int
potentiometerResistance(byte[] state)
Queries to find the resistance value of the potentiometer.byte[]
readDevice()
Retrieves the 1-Wire device sensor state.void
setChargePump(boolean charge_pump_on, byte[] state)
Sets this device's charge pump.void
setCurrentWiperNumber(int wiper_number, byte[] state)
Sets the currently selected wiper number.boolean
setWiperPosition(int position)
Sets the wiper position for the potentiometer.boolean
wiperSettingsAreVolatile(byte[] state)
Queries to see if this 1-Wire Potentiometer device's wiper settings are volatile or non-volatile.void
writeDevice(byte[] state)
Writes the 1-Wire device sensor state that have been changed by the 'set' methods.-
Methods inherited from class com.dalsemi.onewire.container.OneWireContainer
doSpeed, equals, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMemoryBanks, hashCode, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer, toString
-
-
-
-
Constructor Detail
-
OneWireContainer2C
public OneWireContainer2C()
Default constructor
-
OneWireContainer2C
public OneWireContainer2C(DSPortAdapter sourceAdapter, byte[] newAddress)
Creates a container with a provided adapter object and the address of the 1-Wire device.- Parameters:
sourceAdapter
- adapter object required to communicate with this 1-Wire devicenewAddress
- address of this 1-Wire device
-
OneWireContainer2C
public OneWireContainer2C(DSPortAdapter sourceAdapter, long newAddress)
Creates a container with a provided adapter object and the address of this 1-Wire device.- Parameters:
sourceAdapter
- adapter object required to communicate with this 1-Wire devicenewAddress
- address of this 1-Wire device
-
OneWireContainer2C
public OneWireContainer2C(DSPortAdapter sourceAdapter, java.lang.String newAddress)
Creates a container with a provided adapter object and the address of this 1-Wire device.- Parameters:
sourceAdapter
- adapter object required to communicate with this 1-Wire devicenewAddress
- address of this 1-Wire device
-
-
Method Detail
-
getName
public java.lang.String getName()
Retrieves the Maxim Integrated Products part number of this 1-Wire device as a string. For example 'DS2890'.- Overrides:
getName
in classOneWireContainer
- Returns:
- representation of this 1-Wire devices name
-
getAlternateNames
public java.lang.String getAlternateNames()
Retrieves the alternate Maxim Integrated Products part numbers or names. A family of MicroLan devices may have more than one part number depending on packaging.- Overrides:
getAlternateNames
in classOneWireContainer
- Returns:
- representation of the alternate names
-
getDescription
public java.lang.String getDescription()
Retrieves a short description of the function of this 1-Wire Device.- Overrides:
getDescription
in classOneWireContainer
- Returns:
- representation of the function description
-
getMaxSpeed
public int getMaxSpeed()
Gets the maximum speed this 1-Wire device can communicate at.- Overrides:
getMaxSpeed
in classOneWireContainer
- Returns:
- maximum speed this device can communicate at
- See Also:
DSPortAdapter.setSpeed(int)
-
isLinear
public boolean isLinear(byte[] state)
Queries to see if this Potentiometer One Wire Device has linear potentiometer element(s) or logarithmic potentiometer element(s).- Specified by:
isLinear
in interfacePotentiometerContainer
- Parameters:
state
- state buffer of the Potentiometer One Wire Device (returned byreadDevice()
)- Returns:
true
if this device has linear potentiometer element(s);false
if this device has logarithmic potentiometer element(s)
-
wiperSettingsAreVolatile
public boolean wiperSettingsAreVolatile(byte[] state)
Queries to see if this 1-Wire Potentiometer device's wiper settings are volatile or non-volatile.- Specified by:
wiperSettingsAreVolatile
in interfacePotentiometerContainer
- Parameters:
state
- state buffer of the 1-Wire Potentiometer device (returned byreadDevice()
)- Returns:
true
if the wiper settings are volatile;false
if the wiper settings are non-volatile
-
numberOfPotentiometers
public int numberOfPotentiometers(byte[] state)
Queries to see how many potentiometers this Potentiometer One Wire Device has.- Specified by:
numberOfPotentiometers
in interfacePotentiometerContainer
- Parameters:
state
- state buffer of this 1-Wire Potentiometer device (returned byreadDevice()
)- Returns:
- the number of potentiometers on this device
-
numberOfWiperSettings
public int numberOfWiperSettings(byte[] state)
Queries to find the number of wiper settings that any wiper on this Potentiometer One Wire Device can have.- Specified by:
numberOfWiperSettings
in interfacePotentiometerContainer
- Parameters:
state
- state buffer of this 1-Wire Potentiometer device (returned byreadDevice()
)- Returns:
- number of wiper positions available
-
potentiometerResistance
public int potentiometerResistance(byte[] state)
Queries to find the resistance value of the potentiometer.- Specified by:
potentiometerResistance
in interfacePotentiometerContainer
- Parameters:
state
- state buffer of this 1-Wire Potentiometer device (returned byreadDevice()
)- Returns:
- the resistance value in k-Ohms
-
getCurrentWiperNumber
public int getCurrentWiperNumber(byte[] state)
Gets the currently selected wiper number. All wiper actions affect this wiper. The number of wipers is the same asnumberOfPotentiometers()
.- Specified by:
getCurrentWiperNumber
in interfacePotentiometerContainer
- Parameters:
state
- state buffer of this 1-Wire Potentiometer device (returned byreadDevice()
)- Returns:
- the current wiper number
-
setCurrentWiperNumber
public void setCurrentWiperNumber(int wiper_number, byte[] state)
Sets the currently selected wiper number. All wiper actions affect this wiper. The number of wipers is the same asnumberOfPotentiometers()
.- Specified by:
setCurrentWiperNumber
in interfacePotentiometerContainer
- Parameters:
wiper_number
- wiper number to select for communication. Valid choices are 0 to 3state
- state buffer of this 1-Wire Potentiometer device (returned byreadDevice()
)
-
isChargePumpOn
public boolean isChargePumpOn(byte[] state)
Determines if this device's charge pump is enabled.- Specified by:
isChargePumpOn
in interfacePotentiometerContainer
- Parameters:
state
- state buffer of this Potentiometer One Wire Device (returned byreadDevice()
)- Returns:
true
if it is enabled;false
if not
-
setChargePump
public void setChargePump(boolean charge_pump_on, byte[] state)
Sets this device's charge pump. This decreases the wiper's resistance, but increases the power consumption by the part. Vdd must be connected to use the charge pump (see the DS2890 datasheet for more information at www.dalsemi.com)- Specified by:
setChargePump
in interfacePotentiometerContainer
- Parameters:
charge_pump_on
-true
if you want to enable the charge pumpstate
- state buffer of this Potentiometer One Wire Device (returned byreadDevice()
)
-
getWiperPosition
public int getWiperPosition() throws OneWireIOException, OneWireException
Gets the current wiper position of this device. The wiper position is between 0 and 255, and describes the voltage output. The output lies between RH and RL.- Specified by:
getWiperPosition
in interfacePotentiometerContainer
- Returns:
- the wiper position between 0 and 255
- Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
setWiperPosition
public boolean setWiperPosition(int position) throws OneWireIOException, OneWireException
Sets the wiper position for the potentiometer.- Specified by:
setWiperPosition
in interfacePotentiometerContainer
- Parameters:
position
- the position to set the wiper. This value will be cast to a byte, only the 8 least significant bits matter.- Returns:
true
if the operation was successful;false
otherwise- Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
increment
public int increment(boolean reselect) throws OneWireIOException, OneWireException
Increments the wiper position.- Specified by:
increment
in interfacePotentiometerContainer
- Parameters:
reselect
- increment/decrement can be called without resetting the part if the last call was an increment/decrement.true
if you want to select the part (you must call withtrue
after any other one-wire method)- Returns:
- the new position of the wiper (0-255)
- Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
decrement
public int decrement(boolean reselect) throws OneWireIOException, OneWireException
Decrements the wiper position.- Specified by:
decrement
in interfacePotentiometerContainer
- Parameters:
reselect
- increment/decrement can be called without resetting the part if the last call was an increment/decrement.true
if you want to select the part (you must call withtrue
after any other one-wire method)- Returns:
- the new position of the wiper (0-255)
- Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
increment
public int increment() throws OneWireIOException, OneWireException
Increments the wiper position after selecting the part.- Specified by:
increment
in interfacePotentiometerContainer
- Returns:
- the new position of the wiper (0-255)
- Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
decrement
public int decrement() throws OneWireIOException, OneWireException
Decrements the wiper position after selecting the part.- Specified by:
decrement
in interfacePotentiometerContainer
- Returns:
- the new position of the wiper (0-255)
- Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
readDevice
public 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 thewriteDevice
to finalize the one or more change.- Specified by:
readDevice
in interfaceOneWireSensor
- Returns:
- 1-Wire device sensor state
- Throws:
OneWireIOException
- Data was not read correctlyOneWireException
- Could not find device
-
writeDevice
public 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.- Specified by:
writeDevice
in interfaceOneWireSensor
- Parameters:
state
- byte array of clock register page contents- Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
-