use of com.pi4j.io.gpio.GpioPin in project openhab1-addons by openhab.
the class MCP3424Binding method unBindGpioPin.
private void unBindGpioPin(MCP3424BindingProvider provider, String itemName) {
GpioPin pin = gpioPins.remove(itemName);
gpio.unprovisionPin(pin);
logger.debug("Unbound item {}", itemName);
}
use of com.pi4j.io.gpio.GpioPin in project openhab1-addons by openhab.
the class MCP23017Binding method unBindGpioPin.
private void unBindGpioPin(MCP23017BindingProvider provider, String itemName) {
GpioPin pin = gpioPins.remove(itemName);
gpio.unprovisionPin(pin);
logger.debug("Unbound item {}", itemName);
}
use of com.pi4j.io.gpio.GpioPin in project openhab1-addons by openhab.
the class MCP23017Binding method handleGpioPinDigitalStateChangeEvent.
/**
* @{inheritDoc}
*/
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
GpioPin pin = event.getPin();
// Assume we are high...
OpenClosedType state = OpenClosedType.CLOSED;
if (event.getState() == PinState.LOW) {
// To err is human...
state = OpenClosedType.OPEN;
}
this.eventPublisher.postUpdate(pin.getName(), state);
logger.debug("GPIO pin state change: {} = {}", pin, state);
}
use of com.pi4j.io.gpio.GpioPin in project openhab1-addons by openhab.
the class MCP3424Binding method handleGpioPinAnalogValueChangeEvent.
/**
* Function will be called by Pi4J, if new conversion result is available.
* On this time we can notify openhab, that something was changed.
**/
@Override
public void handleGpioPinAnalogValueChangeEvent(GpioPinAnalogValueChangeEvent event) {
GpioPin pin = event.getPin();
MCP3424GpioProvider provider = (MCP3424GpioProvider) pin.getProvider();
if (pin.getTag() instanceof NumberItem) {
double value = provider.getAnalogValue(pin.getPin());
try {
this.eventPublisher.postUpdate(pin.getName(), new DecimalType(value));
} catch (NumberFormatException exception) {
logger.warn("Unable to convert '{}' for item {} to number", String.valueOf(value), pin.getName());
}
logger.debug("GPIO channel change: {} = {}", pin, value);
} else if (pin.getTag() instanceof DimmerItem) {
double value = provider.getPercentValue(pin.getPin());
try {
this.eventPublisher.postUpdate(pin.getName(), new PercentType((int) value));
} catch (NumberFormatException e) {
logger.warn("Unable to convert '{}' for item {} to number", String.valueOf(value), pin.getName());
}
logger.debug("GPIO channel change: {} = {}", pin, value);
}
}
Aggregations