com.pi4j.gpio.extension.pcf.PCF8574Pin Maven / Gradle / Ivy
package com.pi4j.gpio.extension.pcf;
/*
* #%L
* **********************************************************************
* ORGANIZATION : Pi4J
* PROJECT : Pi4J :: GPIO Extension
* FILENAME : PCF8574Pin.java
*
* This file is part of the Pi4J project. More information about
* this project can be found here: http://www.pi4j.com/
* **********************************************************************
* %%
* Copyright (C) 2012 - 2015 Pi4J
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.util.EnumSet;
import com.pi4j.io.gpio.Pin;
import com.pi4j.io.gpio.PinMode;
import com.pi4j.io.gpio.impl.PinImpl;
/**
*
* This GPIO provider implements the PCF8574 I2C GPIO expansion board as native Pi4J GPIO pins.
* More information about the board can be found here: *
* http://www.ti.com/lit/ds/symlink/pcf8574.pdf
*
*
*
* The PCF8574 is connected via I2C connection to the Raspberry Pi and provides
* 8 GPIO pins that can be used for either digital input or digital output pins.
*
*
* @author Robert Savage
*
*/
public class PCF8574Pin {
public static final Pin GPIO_00 = createDigitalPin(0, "GPIO 0");
public static final Pin GPIO_01 = createDigitalPin(1, "GPIO 1");
public static final Pin GPIO_02 = createDigitalPin(2, "GPIO 2");
public static final Pin GPIO_03 = createDigitalPin(3, "GPIO 3");
public static final Pin GPIO_04 = createDigitalPin(4, "GPIO 4");
public static final Pin GPIO_05 = createDigitalPin(5, "GPIO 5");
public static final Pin GPIO_06 = createDigitalPin(6, "GPIO 6");
public static final Pin GPIO_07 = createDigitalPin(7, "GPIO 7");
public static Pin[] ALL = { PCF8574Pin.GPIO_00, PCF8574Pin.GPIO_01, PCF8574Pin.GPIO_02, PCF8574Pin.GPIO_03,
PCF8574Pin.GPIO_04, PCF8574Pin.GPIO_05, PCF8574Pin.GPIO_06, PCF8574Pin.GPIO_07 };
private static Pin createDigitalPin(int address, String name) {
return new PinImpl(PCF8574GpioProvider.NAME, address, name,
EnumSet.of(PinMode.DIGITAL_INPUT, PinMode.DIGITAL_OUTPUT));
}
}