RPi::WiringPi::Util - Utility methods for RPi::WiringPi Raspberry Pi interface
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 module contains various utilities for RPi::WiringPi that don't necessarily fit anywhere else. It is a base class, and is not designed to be used independently.
Returns the current pin mapping in use. Returns "NULL" it has not yet been set, "WPI" if using wiringPi mapping, "BCM" for standard GPIO map and "PHYS" if using the physical pin map directly.
"NULL"
"WPI"
wiringPi
"BCM"
"PHYS"
Returns a hash reference in the following format:
$map => { phys_pin_num => gpio_pin_num, ... };
If no scheme is in place, return will be an empty hash reference.
Parameters:
Optional: By default, we'll check if you've already run a setup routine, and if so, we'll use the scheme currently in use. If one is not in use and no $scheme has been sent in, we'll use 'NULL', otherwise if a scheme is sent in, the return will be:
$scheme
'NULL'
For 'WPI' scheme (wiringPi's numbering scheme):
'WPI'
$map = { phys_pin_num => wiringPi_gpio_pin_num, .... };
For 'BCM' scheme (Broadcom's numbering scheme (printed on the board)):
'BCM'
$map = { phys_pin_num => Broadcom_gpio_pin_num, ... };
Converts the specified pin from the specified scheme (WPI, PHYS, BCM) to the BCM number format.
WPI
PHYS
BCM
If $scheme is not sent in, we'll attempt to fetch the scheme currently in use and use that.
Example:
my $num = pin_to_gpio(6, 'WPI');
That will understand the pin number 6 to be the wiringPi representation, and will return the BCM representation.
Exports a pin. Not needed if using the setup() initialization method.
setup()
Pin number must be the BCM pin number representation.
Unexports a pin.
Returns an array of RPi::WiringPi::Pin objects that are currently registered, and deemed to be in use.
Registers a GPIO pin within the system for error checking, and proper resetting of the pins in use when required.
Mandatory: An object instance of RPi::WiringPi::Pin class.
Exactly the opposite of register_pin().
register_pin()
There are certain environment variables available to aid in testing on non-Raspberry Pi boards.
Set to true, will bypass the wiringPi board checks. False will re-enable them.
new
$SIG{__DIE__}
$SIG{INT}
die()
exit()
fatal_exit
new()
Resets all registered pins back to default settings (off). It's important that this method be called in each application.
Steve Bertrand, <steveb@cpan.org>
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.
To install RPi::WiringPi, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RPi::WiringPi
CPAN shell
perl -MCPAN -e shell install RPi::WiringPi
For more information on module installation, please visit the detailed CPAN module installation guide.