001package com.pi4j.io.gpio; 002 003/* 004 * #%L 005 * ********************************************************************** 006 * ORGANIZATION : Pi4J 007 * PROJECT : Pi4J :: Java Library (Core) 008 * FILENAME : GpioController.java 009 * 010 * This file is part of the Pi4J project. More information about 011 * this project can be found here: http://www.pi4j.com/ 012 * ********************************************************************** 013 * %% 014 * Copyright (C) 2012 - 2015 Pi4J 015 * %% 016 * This program is free software: you can redistribute it and/or modify 017 * it under the terms of the GNU Lesser General Public License as 018 * published by the Free Software Foundation, either version 3 of the 019 * License, or (at your option) any later version. 020 * 021 * This program is distributed in the hope that it will be useful, 022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 024 * GNU General Lesser Public License for more details. 025 * 026 * You should have received a copy of the GNU General Lesser Public 027 * License along with this program. If not, see 028 * <http://www.gnu.org/licenses/lgpl-3.0.html>. 029 * #L% 030 */ 031 032import com.pi4j.io.gpio.event.GpioPinListener; 033import com.pi4j.io.gpio.trigger.GpioTrigger; 034 035import java.util.Collection; 036 037/** 038 * Gpio controller interface. This interface describes all operations over GPIO. 039 * 040 * @author Robert Savage (<a 041 * href="http://www.savagehomeautomation.com">http://www.savagehomeautomation.com</a>) 042 */ 043@SuppressWarnings("unused") 044public interface GpioController { 045 046 void export(PinMode mode, PinState defaultState, GpioPin... pin); 047 void export(PinMode mode, GpioPin... pin); 048 boolean isExported(GpioPin... pin); 049 void unexport(GpioPin... pin); 050 void unexportAll(); 051 052 void setMode(PinMode mode, GpioPin... pin); 053 PinMode getMode(GpioPin pin); 054 boolean isMode(PinMode mode, GpioPin... pin); 055 056 void setPullResistance(PinPullResistance resistance, GpioPin... pin); 057 PinPullResistance getPullResistance(GpioPin pin); 058 boolean isPullResistance(PinPullResistance resistance, GpioPin... pin); 059 060 void high(GpioPinDigitalOutput... pin); 061 boolean isHigh(GpioPinDigital... pin); 062 063 void low(GpioPinDigitalOutput... pin); 064 boolean isLow(GpioPinDigital... pin); 065 066 void setState(PinState state, GpioPinDigitalOutput... pin); 067 void setState(boolean state, GpioPinDigitalOutput... pin); 068 boolean isState(PinState state, GpioPinDigital... pin); 069 PinState getState(GpioPinDigital pin); 070 071 void toggle(GpioPinDigitalOutput... pin); 072 void pulse(long milliseconds, GpioPinDigitalOutput... pin); 073 074 void setValue(double value, GpioPinAnalogOutput... pin); 075 double getValue(GpioPinAnalog pin); 076 077 void addListener(GpioPinListener listener, GpioPinInput... pin); 078 void addListener(GpioPinListener[] listeners, GpioPinInput... pin); 079 void removeListener(GpioPinListener listener, GpioPinInput... pin); 080 void removeListener(GpioPinListener[] listeners, GpioPinInput... pin); 081 void removeAllListeners(); 082 083 void addTrigger(GpioTrigger trigger, GpioPinInput... pin); 084 void addTrigger(GpioTrigger[] triggers, GpioPinInput... pin); 085 void removeTrigger(GpioTrigger trigger, GpioPinInput... pin); 086 void removeTrigger(GpioTrigger[] triggers, GpioPinInput... pin); 087 void removeAllTriggers(); 088 089 GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(GpioProvider provider, Pin pin, String name, PinMode mode, PinPullResistance resistance); 090 GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(GpioProvider provider, Pin pin, PinMode mode, PinPullResistance resistance); 091 GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(GpioProvider provider, Pin pin, String name, PinMode mode); 092 GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(GpioProvider provider, Pin pin, PinMode mode); 093 GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(Pin pin, String name, PinMode mode, PinPullResistance resistance); 094 GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(Pin pin, PinMode mode, PinPullResistance resistance); 095 GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(Pin pin, String name, PinMode mode); 096 GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(Pin pin, PinMode mode); 097 098 GpioPinDigitalInput provisionDigitalInputPin(GpioProvider provider, Pin pin, String name, PinPullResistance resistance); 099 GpioPinDigitalInput provisionDigitalInputPin(GpioProvider provider, Pin pin, PinPullResistance resistance); 100 GpioPinDigitalInput provisionDigitalInputPin(GpioProvider provider, Pin pin, String name); 101 GpioPinDigitalInput provisionDigitalInputPin(GpioProvider provider, Pin pin); 102 GpioPinDigitalInput provisionDigitalInputPin(Pin pin, String name, PinPullResistance resistance); 103 GpioPinDigitalInput provisionDigitalInputPin(Pin pin, PinPullResistance resistance); 104 GpioPinDigitalInput provisionDigitalInputPin(Pin pin, String name); 105 GpioPinDigitalInput provisionDigitalInputPin(Pin pin); 106 107 GpioPinDigitalOutput provisionDigitalOutputPin(GpioProvider provider, Pin pin, String name, PinState defaultState); 108 GpioPinDigitalOutput provisionDigitalOutputPin(GpioProvider provider, Pin pin, PinState defaultState); 109 GpioPinDigitalOutput provisionDigitalOutputPin(GpioProvider provider, Pin pin, String name); 110 GpioPinDigitalOutput provisionDigitalOutputPin(GpioProvider provider, Pin pin); 111 GpioPinDigitalOutput provisionDigitalOutputPin(Pin pin, String name, PinState defaultState); 112 GpioPinDigitalOutput provisionDigitalOutputPin(Pin pin, PinState defaultState); 113 GpioPinDigitalOutput provisionDigitalOutputPin(Pin pin, String name); 114 GpioPinDigitalOutput provisionDigitalOutputPin(Pin pin); 115 116 GpioPinAnalogInput provisionAnalogInputPin(GpioProvider provider, Pin pin, String name); 117 GpioPinAnalogInput provisionAnalogInputPin(GpioProvider provider, Pin pin); 118 GpioPinAnalogInput provisionAnalogInputPin(Pin pin, String name); 119 GpioPinAnalogInput provisionAnalogInputPin(Pin pin); 120 121 GpioPinAnalogOutput provisionAnalogOutputPin(GpioProvider provider, Pin pin, String name, double defaultValue); 122 GpioPinAnalogOutput provisionAnalogOutputPin(GpioProvider provider, Pin pin, double defaultValue); 123 GpioPinAnalogOutput provisionAnalogOutputPin(GpioProvider provider, Pin pin, String name); 124 GpioPinAnalogOutput provisionAnalogOutputPin(GpioProvider provider, Pin pin); 125 GpioPinAnalogOutput provisionAnalogOutputPin(Pin pin, String name, double defaultValue); 126 GpioPinAnalogOutput provisionAnalogOutputPin(Pin pin, double defaultValue); 127 GpioPinAnalogOutput provisionAnalogOutputPin(Pin pin, String name); 128 GpioPinAnalogOutput provisionAnalogOutputPin(Pin pin); 129 130 GpioPinPwmOutput provisionPwmOutputPin(GpioProvider provider, Pin pin, String name, int defaultValue); 131 GpioPinPwmOutput provisionPwmOutputPin(GpioProvider provider, Pin pin, int defaultValue); 132 GpioPinPwmOutput provisionPwmOutputPin(GpioProvider provider, Pin pin, String name); 133 GpioPinPwmOutput provisionPwmOutputPin(GpioProvider provider, Pin pin); 134 GpioPinPwmOutput provisionPwmOutputPin(Pin pin, String name, int defaultValue); 135 GpioPinPwmOutput provisionPwmOutputPin(Pin pin, int defaultValue); 136 GpioPinPwmOutput provisionPwmOutputPin(Pin pin, String name); 137 GpioPinPwmOutput provisionPwmOutputPin(Pin pin); 138 139 GpioPin provisionPin(GpioProvider provider, Pin pin, String name, PinMode mode, PinState defaultState); 140 GpioPin provisionPin(GpioProvider provider, Pin pin, String name, PinMode mode); 141 GpioPin provisionPin(GpioProvider provider, Pin pin, PinMode mode); 142 GpioPin provisionPin(Pin pin, String name, PinMode mode); 143 GpioPin provisionPin(Pin pin, PinMode mode); 144 145 void setShutdownOptions(GpioPinShutdown options, GpioPin... pin); 146 void setShutdownOptions(Boolean unexport, GpioPin... pin); 147 void setShutdownOptions(Boolean unexport, PinState state, GpioPin... pin); 148 void setShutdownOptions(Boolean unexport, PinState state, PinPullResistance resistance, GpioPin... pin); 149 void setShutdownOptions(Boolean unexport, PinState state, PinPullResistance resistance, PinMode mode, GpioPin... pin); 150 151 Collection<GpioPin> getProvisionedPins(); 152 153 void unprovisionPin(GpioPin... pin); 154 boolean isShutdown(); 155 void shutdown(); 156}