Package com.dalsemi.onewire.container
Interface PotentiometerContainer
- All Superinterfaces:
OneWireSensor
- All Known Implementing Classes:
OneWireContainer2C
1-Wire® Potentiometer interface class for basic potentiometer operations.
This class should be implemented for each potentiometer type 1-Wire device.
Currently there is only the DS2890, but it appears that plans have been made
for more complex parts with more wipers, different possible number of wiper
positions, etc.
The PotentiometerContainer methods can be organized into the following categories:
- Information
- Options
- I/O
Usage
Display some features of PotentiometerContainer instance 'pc
':
byte[] state = pc.readDevice();
if (!(pc.isChargePumpOn()))
pc.setChargePump(true, state);
pc.writeDevice(state);
pc.setWiperPosition(127);
pc.increment();
pc.decrement();
-
Method Summary
Modifier and TypeMethodDescriptionint
Decrements the wiper position after selecting the part.int
decrement
(boolean reselect) Decrements the wiper position.int
getCurrentWiperNumber
(byte[] state) Gets the currently selected wiper number.int
Gets the current wiper position of the Potentiometer.int
Increments the wiper position after selecting the part.int
increment
(boolean reselect) Increments the wiper position by one.boolean
isChargePumpOn
(byte[] state) Determines if the Potentiometer's charge pump is enabled.boolean
isLinear
(byte[] state) Queries to see if this Potentiometer 1-Wire Device has linear potentiometer element(s) or logarithmic potentiometer element(s).int
numberOfPotentiometers
(byte[] state) Queries to see how many potentiometers this Potentiometer 1-Wire Device has.int
numberOfWiperSettings
(byte[] state) Queries to find the number of wiper settings that any wiper on this Potentiometer 1-Wire Device can have.int
potentiometerResistance
(byte[] state) Queries to find the resistance value of the potentiometer.void
setChargePump
(boolean charge_pump_on, byte[] state) Sets the state of the Potentiometer's charge pump.void
setCurrentWiperNumber
(int wiper_number, byte[] state) Sets the currently selected wiper number.boolean
setWiperPosition
(int position) Sets the wiper position of the potentiometer.boolean
wiperSettingsAreVolatile
(byte[] state) Queries to see if this Potentiometer 1-Wire Device's wiper settings are volatile or non-volatile.Methods inherited from interface com.dalsemi.onewire.container.OneWireSensor
readDevice, writeDevice
-
Method Details
-
isLinear
boolean isLinear(byte[] state) Queries to see if this Potentiometer 1-Wire Device has linear potentiometer element(s) or logarithmic potentiometer element(s).- Parameters:
state
- state buffer of the Potentiometer 1-Wire Device (returned byreadDevice()
)- Returns:
true
if this device has linear potentiometer element(s),false
if this device has logarithmic potentiometer element(s)
-
wiperSettingsAreVolatile
boolean wiperSettingsAreVolatile(byte[] state) Queries to see if this Potentiometer 1-Wire Device's wiper settings are volatile or non-volatile.- Parameters:
state
- state buffer of the Potentiometer 1-Wire Device (returned byreadDevice()
)- Returns:
true
if the wiper settings are volatile,false
if the wiper settings are non-volatile.
-
numberOfPotentiometers
int numberOfPotentiometers(byte[] state) Queries to see how many potentiometers this Potentiometer 1-Wire Device has.- Parameters:
state
- state buffer of the Potentiometer 1-Wire Device (returned byreadDevice()
)- Returns:
- number of potentiometers on this device
-
numberOfWiperSettings
int numberOfWiperSettings(byte[] state) Queries to find the number of wiper settings that any wiper on this Potentiometer 1-Wire Device can have.- Parameters:
state
- state buffer of the Potentiometer 1-Wire Device (returned byreadDevice()
)- Returns:
- number of wiper positions available
-
potentiometerResistance
int potentiometerResistance(byte[] state) Queries to find the resistance value of the potentiometer.- Parameters:
state
- state buffer of the Potentiometer 1-Wire Device (returned byreadDevice()
)- Returns:
- resistance value in k-Ohms
-
getCurrentWiperNumber
int getCurrentWiperNumber(byte[] state) Gets the currently selected wiper number. All wiper actions affect this wiper. The number of wipers is the same asnumberOfPotentiometers()
.- Parameters:
state
- state buffer of the Potentiometer 1-Wire Device (returned byreadDevice()
)- Returns:
- current wiper number
-
setCurrentWiperNumber
void setCurrentWiperNumber(int wiper_number, byte[] state) Sets the currently selected wiper number. All wiper actions will then affect this wiper. The number of wipers is the same asnumberOfPotentiometers()
.- Parameters:
wiper_number
- wiper number to select for communicationstate
- state buffer of the Potentiometer 1-Wire Device (returned byreadDevice()
)
-
isChargePumpOn
boolean isChargePumpOn(byte[] state) Determines if the Potentiometer's charge pump is enabled.- Parameters:
state
- state buffer of the Potentiometer 1-Wire Device (returned byreadDevice()
)- Returns:
true
if enabled,false
if not
-
setChargePump
void setChargePump(boolean charge_pump_on, byte[] state) Sets the state of the Potentiometer'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.- Parameters:
charge_pump_on
-true
to enable the charge pump,false
to disable charge pumpstate
- state buffer of the Potentiometer 1-Wire Device (returned byreadDevice()
)
-
getWiperPosition
Gets the current wiper position of the Potentiometer. The wiper position is between 0 andnumberOfWiperPositions()
, and describes the voltage output.- Returns:
- wiper position between 0 and
numberOfWiperPositions()
- Throws:
OneWireIOException
- Data was not read correctlyOneWireException
- Could not find device
-
setWiperPosition
Sets the wiper position of the potentiometer.- Parameters:
position
- position to set the wiper to- Returns:
true
if the operation was successful,false
otherwise- Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
increment
Increments the wiper position by one.- Parameters:
reselect
-increment()
can be called without resetting the part if the last call was anincrement()
ordecrement()
.true
if device is to be selected (must be called withtrue
after any other 1-wire method)- Returns:
- new position of wiper (0 to
numberOfWiperPositions()
) - Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
decrement
Decrements the wiper position.- Parameters:
reselect
-decrement()
can be called without resetting the part if the last call was anincrement()
ordecrement()
.true
if device is to be selected (must be called withtrue
after any other 1-wire method)- Returns:
- new position of wiper (0 to
numberOfWiperPositions()
). - Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
increment
Increments the wiper position after selecting the part.- Returns:
- new position of wiper (0 to
numberOfWiperPositions()
) - Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-
decrement
Decrements the wiper position after selecting the part.- Returns:
- new position of wiper (0 to
numberOfWiperPositions()
) - Throws:
OneWireIOException
- Data was not written correctlyOneWireException
- Could not find device
-