@ Override public void increase ( final int steps ) throws IOException { int maxValue = getMaxValue ( ) ; if ( currentValue == maxValue ) { return ; } if ( steps < 0 ) { throw new RuntimeException ( "only positive values for parameter 'steps' allowed!" ) ; } if ( getNonVolatileMode ( ) != MicrochipPotentiometerNonVolatileMode . VOLATILE_ONLY ) { throw new RuntimeException ( "'increase' is only valid for NonVolatileMode.VOLATILE_ONLY!" ) ; } // check boundaries final int actualSteps ; if ( ( steps + currentValue ) > maxValue ) { actualSteps = maxValue - currentValue ; } else { actualSteps = steps ; } int newValue = currentValue + actualSteps ; // if upper-boundary then set value in device to ensure sync // and for a large number of steps it is better to set a new value if ( ( newValue == maxValue ) || ( steps > 5 ) ) { setCurrentValue ( newValue ) ; } // for a small number of step simply repeat 'increase'-commands else { controller . increase ( DeviceControllerChannel . valueOf ( channel ) , actualSteps ) ; currentValue = newValue ; } }
Increases the wiper s value for n steps .