NAME

    RPi::WiringPi - Perl interface to Raspberry Pi's board and GPIO pin
    functionality

SYNOPSIS

        use RPi::WiringPi;
        use RPi::WiringPi::Constant qw(:all);
    
        my $pi = RPi::WiringPi->new;
    
        my $board = $pi->board;
    
        print "Raspberry Pi board revision: ". $board->rev ."\n";
    
        my $gpio_pin_1 = $pi->pin(1);
        my $gpio_pin_2 = $pi->pin(2);
    
        $gpio_pin_1->mode(INPUT);
        $gpio_pin_2->mode(OUTPUT);
    
        my $pin1_on = $gpio_pin_1->read;
    
        if ($pin1_on){
            $gpio_pin_2->write(HIGH);
        }
    
        $pi->cleanup;

DESCRIPTION

    WARNING: Until version 1.00 is released, the API and other
    functionality of this module may change, and things may break from
    time-to-time.

    This is the root module for the RPi::WiringPi system. It interfaces to
    a Raspberry Pi board, its accessories and its GPIO pins via the
    wiringPi <http://wiringpi.com> library through the Perl wrapper
    RPi::WiringPi::Core <https://metacpan.org/pod/RPi::WiringPi::Core>
    module.

    There are a basic set of constants that can be imported. See
    RPi::WiringPi::Constant.

    wiringPi <http://wiringpi.com> must be installed prior to
    installing/using this module.

    By default, we use wiringPi's interpretation of GPIO pin mapping. See
    new method to change this behaviour.

OPERATIONAL METHODS

 new(%args)

    Returns a new RPi::WiringPi object.

    Parameters:

    setup => $value

      Optional. This option specifies which GPIO pin mapping (numbering
      scheme) to use. wiringPi for wiringPi's mapping, physical or system
      to use the pin numbers labelled on the board itself, or gpio use the
      Broadcom (BCM) pin numbers.

      See wiringPi setup reference <http://wiringpi.com/reference/setup>
      for important details on the differences.

    fatal_exit => $bool

      Optional: We trap all die() calls and clean up for safety reasons. If
      a call to die() is trapped, by default, we clean up, and then exit().
      Set fatal_exit to false (0) to perform the cleanup, and then continue
      running your script. This is for unit testing purposes only.

 board()

    Returns a RPi::WiringPi::Board object which has access to various
    attributes of the Raspberry Pi physical board itself.

 pin($pin_num)

    Returns a RPi::WiringPi::Pin object, mapped to a specified GPIO pin.

    Parameters:

    $pin_num

      Mandatory: The pin number to attach to.

 cleanup()

    Resets all registered pins back to default settings (off). It's
    important that this method be called in each application.

HELPER METHODS

    These methods aren't normally needed by end-users. They're available
    for those who want to write their own libraries.

 pin_map()

    Returns the current pin mapping in use. Returns "NULL" it has not yet
    been set.

 registered_pins()

    Returns an array of RPi::WiringPi::Pin objects that are currently
    registered, and deemed to be in use.

 register_pin($pin_obj)

    Registers a GPIO pin within the system for error checking, and proper
    resetting of the pins in use when required.

    Parameters:

    $pin_obj

      Mandatory: An object instance of RPi::WiringPi::Pin class.

 unregister_pin($pin_obj)

    Exactly the opposite of register_pin().

ENVIRONMENT VARIABLES

    There are certain environment variables available to aid in testing on
    non-Raspberry Pi boards.

 NO_BOARD

    Set to true, will bypass the wiringPi board checks. False will
    re-enable them.

IMPORTANT NOTES

    wiringPi <http://wiringpi.com> must be installed prior to
    installing/using this module.

    By default, we use wiringPi's interpretation of GPIO pin mapping. See
    new method to change this behaviour.

    This module hijacks fatal errors with $SIG{__DIE__}, as well as
    $SIG{INT}. This is so that in the case of a fatal error, the Raspberry
    Pi pins are never left in an inconsistent state. By default, we trap
    the die(), reset all pins to their default (INPUT, LOW), then we
    exit(). Look at the fatal_exit param in new() to change the behaviour.

AUTHOR

    Steve Bertrand, <steveb@cpan.org>

COPYRIGHT AND LICENSE

    Copyright (C) 2016 by Steve Bertrand

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself, either Perl version 5.18.2 or, at
    your option, any later version of Perl 5 you may have available.

