Class Shift


  • public class Shift
    extends Object

    WiringPi Shift Library

    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:

    • pi4j
    • wiringPi
    This library depends on the wiringPi native system library. (developed by Gordon Henderson @ http://wiringpi.com)

    Author:
    Robert Savage (http://www.savagehomeautomation.com)
    See Also:
    https://pi4j.com/, http://wiringpi.com/reference/shift-library/
    • Method Detail

      • shiftIn

        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.

        Parameters:
        dPin - data pin
        cPin - clock pin
        order - order is either LSBFIRST or MSBFIRST
        Returns:

        The 8-bit shifted value is returned by the function.

        See Also:
        http://wiringpi.com/reference/shift-library/
      • shiftOut

        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.

        Parameters:
        dPin - data pin
        cPin - clock pin
        order - order is either LSBFIRST or MSBFIRST
        val - 8-bit data value
        See Also:
        http://wiringpi.com/reference/shift-library/