001package com.pi4j.io.gpio;
002
003import java.util.EnumSet;
004
005/*
006 * #%L
007 * **********************************************************************
008 * ORGANIZATION  :  Pi4J
009 * PROJECT       :  Pi4J :: Java Library (Core)
010 * FILENAME      :  PinPullResistance.java  
011 * 
012 * This file is part of the Pi4J project. More information about 
013 * this project can be found here:  http://www.pi4j.com/
014 * **********************************************************************
015 * %%
016 * Copyright (C) 2012 - 2013 Pi4J
017 * %%
018 * Licensed under the Apache License, Version 2.0 (the "License");
019 * you may not use this file except in compliance with the License.
020 * You may obtain a copy of the License at
021 * 
022 *      http://www.apache.org/licenses/LICENSE-2.0
023 * 
024 * Unless required by applicable law or agreed to in writing, software
025 * distributed under the License is distributed on an "AS IS" BASIS,
026 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
027 * See the License for the specific language governing permissions and
028 * limitations under the License.
029 * #L%
030 */
031
032/**
033 * Pin pull up/down resistance definition.
034 *
035 * @author Robert Savage (<a
036 *         href="http://www.savagehomeautomation.com">http://www.savagehomeautomation.com</a>)
037 */
038public enum PinPullResistance {
039
040    OFF(0, "off"),
041    PULL_DOWN(1, "down"),
042    PULL_UP(2, "up"); 
043
044    private final int value;
045    private final String name;
046
047    private PinPullResistance(int value, String name) {
048        this.value = value;
049        this.name = name;
050    }
051
052    public int getValue() {
053        return value;
054    }
055
056    public String getName() {
057        return name;
058    }
059    
060    @Override
061    public String toString() {
062        return name.toUpperCase();        
063    }    
064    
065    public static EnumSet<PinPullResistance> all() {
066        return EnumSet.of(PinPullResistance.OFF, 
067                          PinPullResistance.PULL_DOWN,
068                          PinPullResistance.PULL_UP);
069    }     
070}