private void onOff(float onTime, float offTime) throws RuntimeIOException { setValueInternal(1); SleepUtil.sleepSeconds(onTime); setValueInternal(0); SleepUtil.sleepSeconds(offTime); }
/** * Turn off the device (same as {@code setValue(0)}). * * @throws RuntimeIOException * If an I/O error occurred. */ public void off() throws RuntimeIOException { stopLoops(); setValueInternal(0); }
/** * Set the PWM output value (0..1). * * @param value * New PWM output value. * @throws RuntimeIOException * If an I/O error occurred. */ @Override public void setValue(float value) throws RuntimeIOException { stopLoops(); setValueInternal(value); }
/** * Turn on the device (same as {@code setValue(1)}). * * @throws RuntimeIOException * If an I/O error occurred. */ public void on() throws RuntimeIOException { stopLoops(); setValueInternal(1); }
private void fadeInOut(float sleepTime, float delta) throws RuntimeIOException { float value = 0; while (value <= 1 && running.get()) { setValueInternal(value); SleepUtil.sleepSeconds(sleepTime); value += delta; } value = 1; while (value >= 0 && running.get()) { setValueInternal(value); SleepUtil.sleepSeconds(sleepTime); value -= delta; } }
/** * Toggle the state of the device (same as {@code setValue(1 - getvalue())} * ). * * @throws RuntimeIOException * If an I/O error occurred. */ public void toggle() throws RuntimeIOException { stopLoops(); setValueInternal(1 - device.getValue()); }