com.pi4j.component.potentiometer.microchip.MCP4431 Maven / Gradle / Ivy
package com.pi4j.component.potentiometer.microchip;
import com.pi4j.component.potentiometer.microchip.impl.MicrochipPotentiometerBase;
import com.pi4j.io.i2c.I2CBus;
import java.io.IOException;
/*
* #%L
* **********************************************************************
* ORGANIZATION : Pi4J
* PROJECT : Pi4J :: Device Abstractions
* FILENAME : MCP4431.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%
*/
/**
* Pi4J-device for MCP4431.
*
* @author Raspelikan
*/
public class MCP4431 extends MicrochipPotentiometerBase implements MicrochipPotentiometer {
private static final MicrochipPotentiometerChannel[] supportedChannels = new MicrochipPotentiometerChannel[] {
MicrochipPotentiometerChannel.A, MicrochipPotentiometerChannel.B, MicrochipPotentiometerChannel.C, MicrochipPotentiometerChannel.D
};
/**
* Builds an instance which is ready to use.
*
* @param i2cBus The Pi4J-I2CBus to which the device is connected to
* @param pinA0 Whether the device's address pin A0 is high (true) or low (false)
* @param initialValue Initial value of wiper
* @throws IOException Thrown if communication fails or device returned a malformed result
*/
public MCP4431(final I2CBus i2cBus, final boolean pinA0,
final int initialValue) throws IOException {
super(i2cBus, pinA0, PIN_NOT_AVAILABLE, PIN_NOT_AVAILABLE,
MicrochipPotentiometerChannel.A, MicrochipPotentiometerNonVolatileMode.VOLATILE_ONLY, initialValue);
}
/**
* @return Whether device is capable of non volatile wipers (false for MCP4431)
*/
@Override
public boolean isCapableOfNonVolatileWiper() {
return false;
}
/**
* @return The maximal value at which a wiper can be (128 for MCP4431)
*/
@Override
public int getMaxValue() {
return maxValue();
}
/**
* @return The maximal value at which a wiper can be (128 for MCP4431)
*/
public static int maxValue() {
return 128;
}
/**
* @return Whether this device is a potentiometer or a rheostat (false for MCP4431)
*/
@Override
public boolean isRheostat() {
return false;
}
/**
* @return All channels supported by the underlying device (A, B, C and D for MCP4431)
*/
@Override
public MicrochipPotentiometerChannel[] getSupportedChannelsByDevice() {
return supportedChannels;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy