@Override public void valueChanged(DigitalInputEvent event) { event.setActiveHigh(activeHigh); if (activatedAction != null && event.isActive()) { activatedAction.action(); } if (deactivatedAction != null && !event.isActive()) { deactivatedAction.action(); } super.valueChanged(event); }
public TB6612FNGDualMotorDriver(int leftMotorClockwiseControlGpio, int leftMotorCounterClockwiseControlGpio, int leftMotorPwmGpio, int rightMotorClockwiseControlGpio,int rightMotorCounterClockwiseControlGpio, int rightMotorPwmGpio) throws RuntimeIOException { this(new DigitalOutputDevice(leftMotorClockwiseControlGpio), new DigitalOutputDevice(leftMotorCounterClockwiseControlGpio), new PwmOutputDevice(leftMotorPwmGpio), new DigitalOutputDevice(rightMotorClockwiseControlGpio), new DigitalOutputDevice(rightMotorCounterClockwiseControlGpio), new PwmOutputDevice(rightMotorPwmGpio)); }
private void scanKeys() { for (byte c=0; c<cols.length; c++) { // Begin column pulse output. cols[c].on(); for (byte r=0; r<rows.length; r++) { // keypress is active low so invert to high. values[r][c] = rows[r].isActive(); } // Set pin to high impedance input. Effectively ends column pulse. cols[c].off(); } } }
@Override public void valueChanged(AnalogInputEvent event) { event.setRange(range); super.valueChanged(event); }
/** * Represents the speed of the motor as a floating point value between -1 * (full speed backward) and 1 (full speed forward) * @throws RuntimeIOException if an I/O error occurs */ @Override public float getValue() throws RuntimeIOException { float speed = motorPwmControl.getValue(); return motorForwardControlPin.isOn() ? speed : -speed; }
public SsdOled(int controller, int chipSelect, DigitalOutputDevice dcPin, DigitalOutputDevice resetPin, int width, int height, int imageType) { spiDevice = new SpiDevice(controller, chipSelect, SPI_FREQUENCY, SpiClockMode.MODE_0, false); this.dcPin = dcPin; this.resetPin = resetPin; this.width = width; this.height = height; this.imageType = imageType; }
@Override protected void writeByte(int register, byte value) { byte[] tx = new byte[3]; tx[0] = (byte) (boardAddress | WRITE_FLAG); tx[1] = (byte) register; tx[2] = value; device.write(tx); } }
/** * 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); }
@Override protected void writeByte(int register, byte value) { device.writeByte(register, value); } }
@Override public void close() { device.close(); } }
/** * @param deviceFactory Device factory to use to construct the device. * @param gpio GPIO to which the device is connected. * @param pud Pull up/down configuration, values: NONE, PULL_UP, PULL_DOWN. * @param trigger Event trigger configuration, values: NONE, RISING, FALLING, BOTH. * @throws RuntimeIOException If an I/O error occurred. */ public WaitableDigitalInputDevice(GpioDeviceFactoryInterface deviceFactory, int gpio, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException { super(deviceFactory, gpio, pud, trigger); enableDeviceListener(); }
/** * Wait indefinitely for the device state to go inactive. * @return False if timed out waiting for the specified value, otherwise true. * @throws InterruptedException If interrupted while waiting.- */ public boolean waitForInactive() throws InterruptedException { return waitForInactive(0); }
/** * Get the tap duration in milliseconds * @return Tap duration (milliseconds) */ public float getTapDuration() { return device.readUByte(TAP_DUR) * TAP_DURATION_MS_LSB; }
public TB6612FNGDualMotorDriver(PwmOutputDeviceFactoryInterface pwmDeviceFactory, int leftMotorClockwiseControlGpio, int leftMotorCounterClockwiseControlGpio, int leftMotorPwmGpio, int rightMotorClockwiseControlGpio,int rightMotorCounterClockwiseControlGpio, int rightMotorPwmGpio) throws RuntimeIOException { this(new DigitalOutputDevice(leftMotorClockwiseControlGpio), new DigitalOutputDevice(leftMotorCounterClockwiseControlGpio), new PwmOutputDevice(pwmDeviceFactory, leftMotorPwmGpio, 0), new DigitalOutputDevice(rightMotorClockwiseControlGpio), new DigitalOutputDevice(rightMotorCounterClockwiseControlGpio), new PwmOutputDevice(pwmDeviceFactory, rightMotorPwmGpio, 0)); }