All Downloads are FREE. Search and download functionalities are using the official Maven repository.

missingOldImpl.LocalControl Maven / Gradle / Ivy

package berlin.yuna.tinkerforgesensor.model.missing;

import berlin.yuna.tinkerforgesensor.util.HumanInput;
import berlin.yuna.tinkerforgesensor.model.exception.NetworkConnectionException;
import berlin.yuna.tinkerforgesensor.model.sensor.Sensor;
import berlin.yuna.tinkerforgesensor.model.ValueType;
import com.tinkerforge.Device;
import com.tinkerforge.DummyDevice;

import static berlin.yuna.tinkerforgesensor.model.LedStatusType.LED_ON;
import static berlin.yuna.tinkerforgesensor.model.ValueType.CURSOR_CLICK_COUNT;
import static berlin.yuna.tinkerforgesensor.model.ValueType.CURSOR_MOVE_Y;
import static berlin.yuna.tinkerforgesensor.model.ValueType.KEY_CHAR;
import static berlin.yuna.tinkerforgesensor.model.ValueType.KEY_INPUT;

/**
 * 

{@link LocalControl}


* Displays a tiny human input board on activation
* *

Values

*
    *
  • {@link ValueType#KEY_PRESSED}
  • *
  • {@link ValueType#KEY_CHAR}
  • *
  • {@link ValueType#CURSOR_PRESSED}
  • *
  • {@link ValueType#CURSOR_CLICK_COUNT}
  • *
  • {@link ValueType#CURSOR_MOVE_X}
  • *
  • {@link ValueType#CURSOR_MOVE_Y}
  • *
* *

Technical Info

*
Activation
* sensor.ledAdditional_setOn() *
Key code
* sensor.values().keyCode() *
Readable Key Character
* Char char = (char) stack.values().keyChar().intValue() */ public class LocalControl extends Sensor { private static HumanInput humanInput; public LocalControl(final Device device, final String uid) throws NetworkConnectionException { super((DummyDevice) device, uid); } @Override protected Sensor initListener() { return this; } public boolean getIsKeyPressed() { return getValue(KEY_INPUT, -1, -1).intValue() == 1; } public Character getChar() { return (char) getValue(KEY_CHAR, -1, -1).intValue(); } public int getClickCount() { return getValue(CURSOR_CLICK_COUNT, -1, -1).intValue(); } public int getPosX() { return getValue(CURSOR_MOVE_Y, -1, -1).intValue(); } public int getPosY() { return getValue(CURSOR_MOVE_Y, -1, -1).intValue(); } @Override public Sensor send(final Object... valuesArray) { return this; } @Override public Sensor send(final Object value) { return send(new Object[]{value}); } @Override public Sensor setLedStatus(final Integer value) { return this; } @Override public Sensor ledAdditional(final Integer value) { if (LED_ON.bit == value) { start(); } return this; } public void start() { if (humanInput == null) { humanInput = new HumanInput(); humanInput.sensorEventConsumerList.add(this::sendEventUnchecked); } } @Override public Sensor refreshPeriod(final int milliseconds) { return this; } @Override public Sensor initLedConfig() { return this; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy