public class Shift extends Object
WiringPi includes a shift library which more or less mimics the one in the Arduino system. This allows you to shift 8-bit data values out of the Pi, or into the Pi from devices such as shift-registers (e.g. 74,595) and so-on, although it can also be used in some bit-banging scenarios.
Before using the Pi4J library, you need to ensure that the Java VM in configured with access to the following system libraries:
This library depends on the wiringPi native system library. (developed by Gordon Henderson @ http://wiringpi.com)
Modifier and Type | Field and Description |
---|---|
static int |
LSBFIRST |
static int |
MSBFIRST |
Modifier and Type | Method and Description |
---|---|
static byte |
shiftIn(byte dPin,
byte cPin,
byte order)
uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order);
|
static void |
shiftOut(byte dPin,
byte cPin,
byte order,
byte val)
void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val);
|
public static final int LSBFIRST
public static final int MSBFIRST
public static byte shiftIn(byte dPin, byte cPin, byte order)
uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order);
This shifts an 8-bit data value in with the data appearing on the dPin and the clock being sent out on the cPin. Order is either LSBFIRST or MSBFIRST. The data is sampled after the cPin goes high. (So cPin high, sample data, cPin low, repeat for 8 bits) The 8-bit value is returned by the function.
dPin
- data pincPin
- clock pinorder
- order is either LSBFIRST or MSBFIRSTThe 8-bit shifted value is returned by the function.
public static void shiftOut(byte dPin, byte cPin, byte order, byte val)
void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val);
The shifts an 8-bit data value val out with the data being sent out on dPin and the clock being sent out on the cPin. order is as above. Data is clocked out on the rising or falling edge; ie. dPin is set, then cPin is taken high then low and repeated for the 8 bits.
dPin
- data pincPin
- clock pinorder
- order is either LSBFIRST or MSBFIRSTval
- 8-bit data valueCopyright © 2012–2021 Pi4J. All rights reserved.