RPi::WiringPi::Interrupt - Raspberry Pi GPIO pin interrupts
use RPi::WiringPi::Interrupt; use RPi::WiringPi::Constant qw(:all); my $int = RPi::WiringPi::Interrupt->new; my $pin = 6; $int->set($pin, EDGE_HIGH, 'interrupt_handler'); sub interrupt_handler { print "in handler"; # turn a pin on, or do other things } $int->unset($pin);
This module allows you to set up, and un-set GPIO pin edge detection interrupts where you can supply the name of a Perl subroutine that you write that will act as the interrupt handler.
The backend is written in C and is threaded, so it doesn't block the main program thread from running while waiting for the interrupt to occur.
Returns a new RPi::WiringPi::Interrupt object.
RPi::WiringPi::Interrupt
Starts a new thread that waits for an interrupt on the specified pin, when the selected edge is triggered. The name of the Perl subroutine in $callback will be the code executed as the interrupt handler.
$callback
Parameters:
$pin
Mandatory: The pin number to set the interrupt on. We'll convert the pin number appropriately regardless of which pin mapping you're currently using.
$edge
Mandatory: One of 1 (LOW), 2 (HIGH) or 3 for both HIGH and LOW.
1
2
3
Mandatory: This is the name of a user-written Perl subroutine that contains the code you want to execute when the edge change is detected on the pin. (ie. the Interrupt Handler).
Terminates an interrupt thread, and stops monitoring for more.
Mandatory: The pin number. You can also send in 'all', which will disable all currently implemented interrupts.
'all'
Mandatory: see set() for details.
set()
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.