public class PiconZero extends AbstractDeviceFactory implements GpioDeviceFactoryInterface, PwmOutputDeviceFactoryInterface, AnalogInputDeviceFactoryInterface, AnalogOutputDeviceFactoryInterface
Modifier and Type | Class and Description |
---|---|
static class |
PiconZero.InputConfig |
static class |
PiconZero.OutputConfig |
static class |
PiconZero.PiconZeroAnalogInputDevice |
static class |
PiconZero.PiconZeroAnalogOutputDevice |
static class |
PiconZero.PiconZeroBoardPinInfo |
static class |
PiconZero.PiconZeroDigitalInputDevice |
static class |
PiconZero.PiconZeroDigitalOutputDevice |
static class |
PiconZero.PiconZeroPwmOutputDevice |
Modifier and Type | Field and Description |
---|---|
static int |
ALL_PIXELS |
static float |
MAX_ANALOG_INPUT_VALUE |
static int |
MAX_MOTOR_VALUE |
static int |
MAX_OUTPUT_VALUE |
static int |
MIN_MOTOR_VALUE |
static int |
NUM_INPUT_CHANNELS |
static int |
NUM_MOTORS |
static int |
NUM_OUTPUT_CHANNELS |
static int |
SERVO_CENTRE |
closed, deviceStates
Constructor and Description |
---|
PiconZero() |
PiconZero(int controller,
int address) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
closeChannel(int channel) |
AnalogInputDeviceInterface |
createAnalogInputDevice(String key,
PinInfo pinInfo) |
AnalogOutputDeviceInterface |
createAnalogOutputDevice(String key,
PinInfo pinInfo) |
GpioDigitalInputDeviceInterface |
createDigitalInputDevice(String key,
PinInfo pinInfo,
GpioPullUpDown pud,
GpioEventTrigger trigger) |
GpioDigitalInputOutputDeviceInterface |
createDigitalInputOutputDevice(String key,
PinInfo pinInfo,
DeviceMode mode) |
GpioDigitalOutputDeviceInterface |
createDigitalOutputDevice(String key,
PinInfo pinInfo,
boolean initialValue) |
PwmOutputDeviceInterface |
createPwmOutputDevice(String key,
PinInfo pinInfo,
int pwmFrequency,
float initialValue) |
BoardPinInfo |
getBoardPinInfo() |
int |
getBoardPwmFrequency() |
int |
getInputValue(int channel)
Read input value in PiconZero range
|
float |
getMotor(int motor)
Get motor output value (normalised to range -1..1)
|
int |
getMotorValue(int motor)
Get the current motor speed (PiconZero range -128..127)
|
String |
getName() |
byte[] |
getRevision()
Get the board revision details
|
float |
getValue(int channel)
Read input value in normalised range (0..1)
|
float |
getVRef() |
AnalogInputDeviceInterface |
provisionAnalogInputDevice(int gpio) |
void |
reset()
Reset the board.
|
void |
setAllPixels(int red,
int green,
int blue,
boolean update)
Sets all pixels with the selected red, green and blue values (0 to 255) [Available from firmware revision 07]
|
void |
setBoardPwmFrequency(int pwmFrequency) |
void |
setBrightness(int brightness) |
void |
setInputConfig(int channel,
PiconZero.InputConfig config)
Set configuration of selected input channel
|
void |
setMotor(int motor,
float speed)
Set motor output value (normalised to range -1..1)
|
void |
setMotorValue(int motor,
int speed)
Set motor output value (PiconZero range -128..127)
|
void |
setOutputConfig(int channel,
PiconZero.OutputConfig config)
Set configuration of selected output
|
void |
setOutputValue(int channel,
int value)
Set output data for selected output channel in PiconZero range.
|
void |
setPixel(int pixel,
int red,
int green,
int blue,
boolean update)
Set the colour of an individual pixel (always output channel 5)
|
void |
setValue(int channel,
boolean value) |
void |
setValue(int channel,
float value)
Set output value for the specified channel (normalised).
|
void |
updatePixels() |
createPinKey, deviceClosed, deviceOpened, getDevice, isClosed, isDeviceOpened
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
provisionDigitalInputDevice, provisionDigitalInputOutputDevice, provisionDigitalOutputDevice
provisionPwmOutputDevice
provisionAnalogOutputDevice
createPinKey, deviceClosed, deviceOpened, isClosed, isDeviceOpened
public static final int ALL_PIXELS
public static final int MAX_OUTPUT_VALUE
public static final int NUM_MOTORS
public static final int NUM_INPUT_CHANNELS
public static final int NUM_OUTPUT_CHANNELS
public static final float MAX_ANALOG_INPUT_VALUE
public static final int MAX_MOTOR_VALUE
public static final int MIN_MOTOR_VALUE
public static final int SERVO_CENTRE
public PiconZero()
public PiconZero(int controller, int address)
public float getVRef()
getVRef
in interface AnalogInputDeviceFactoryInterface
public void reset()
public byte[] getRevision()
public void setInputConfig(int channel, PiconZero.InputConfig config)
channel
- Input channel (0..3)config
- Input configuration (0: Digital, 1: Analog, 2: DS18B20)public void setOutputConfig(int channel, PiconZero.OutputConfig config)
channel
- Output channel (0..5)config
- Output configuration (0: Digital, 1: PWM, 2: Servo, 3: Neopixel WS2812B)public void setMotor(int motor, float speed)
motor
- Motor number (0 or 1)speed
- Must be in range -1..1public float getMotor(int motor)
motor
- Motor number (0 or 1)public void setMotorValue(int motor, int speed)
motor
- Motor number (0 or 1)speed
- Must be in range -128..127public int getMotorValue(int motor)
motor
- Motor number (0 or 1)public float getValue(int channel)
channel
- Input to readpublic void setValue(int channel, float value)
Set output value for the specified channel (normalised).
* Don't use this method if the output mode is WS2812B.
channel
- 0..5value
- Normalised output value:
Mode Name Type Values 0 On/Off Byte 0 is OFF, 1 is ON 1 PWM Byte 0 to 1 percentage of ON time 2 Servo Byte -1 to + 1 Position in degrees (0 is centre) 3* WS2812B 4 Bytes 0:Pixel ID, 1:Red, 2:Green, 3:Blue
public void setValue(int channel, boolean value)
public int getInputValue(int channel)
channel
- Input to readpublic void setOutputValue(int channel, int value)
channel
- 0..5value
- output value:
Mode Name Type Values 0 On/Off Byte 0 is OFF, 1 is ON 1 PWM Byte 0 to 100 percentage of ON time 2 Servo Byte Position in degrees with 90 as the mid point 3* WS2812B 4 Bytes 0:Pixel ID, 1:Red, 2:Green, 3:Blue* Don't use this method if the output mode is WS2812B.
public void setPixel(int pixel, int red, int green, int blue, boolean update)
pixel
- 0..63red
- 0..255green
- 0..255blue
- 0..255update
- update the pixel now if truepublic void setAllPixels(int red, int green, int blue, boolean update)
red
- 0..255green
- 0..255blue
- 0..255update
- update the pixel now if truepublic void updatePixels()
public void setBrightness(int brightness)
public String getName()
getName
in interface DeviceFactoryInterface
public int getBoardPwmFrequency()
getBoardPwmFrequency
in interface PwmOutputDeviceFactoryInterface
public void setBoardPwmFrequency(int pwmFrequency)
setBoardPwmFrequency
in interface PwmOutputDeviceFactoryInterface
public BoardPinInfo getBoardPinInfo()
getBoardPinInfo
in interface DeviceFactoryInterface
public GpioDigitalInputDeviceInterface createDigitalInputDevice(String key, PinInfo pinInfo, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException
createDigitalInputDevice
in interface GpioDeviceFactoryInterface
RuntimeIOException
public GpioDigitalOutputDeviceInterface createDigitalOutputDevice(String key, PinInfo pinInfo, boolean initialValue) throws RuntimeIOException
createDigitalOutputDevice
in interface GpioDeviceFactoryInterface
RuntimeIOException
public GpioDigitalInputOutputDeviceInterface createDigitalInputOutputDevice(String key, PinInfo pinInfo, DeviceMode mode) throws RuntimeIOException
createDigitalInputOutputDevice
in interface GpioDeviceFactoryInterface
RuntimeIOException
public PwmOutputDeviceInterface createPwmOutputDevice(String key, PinInfo pinInfo, int pwmFrequency, float initialValue) throws RuntimeIOException
createPwmOutputDevice
in interface PwmOutputDeviceFactoryInterface
RuntimeIOException
public AnalogInputDeviceInterface createAnalogInputDevice(String key, PinInfo pinInfo)
createAnalogInputDevice
in interface AnalogInputDeviceFactoryInterface
public AnalogOutputDeviceInterface createAnalogOutputDevice(String key, PinInfo pinInfo) throws RuntimeIOException
createAnalogOutputDevice
in interface AnalogOutputDeviceFactoryInterface
RuntimeIOException
public AnalogInputDeviceInterface provisionAnalogInputDevice(int gpio) throws RuntimeIOException
provisionAnalogInputDevice
in interface AnalogInputDeviceFactoryInterface
RuntimeIOException
public void closeChannel(int channel)
public void close() throws RuntimeIOException
close
in interface DeviceFactoryInterface
close
in interface Closeable
close
in interface AutoCloseable
close
in class AbstractDeviceFactory
RuntimeIOException
Copyright © 2016–2017 mattjlewis. All rights reserved.