line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
######################################################################################### |
2
|
|
|
|
|
|
|
# Package HiPi::Pin |
3
|
|
|
|
|
|
|
# Description: GPIO / Extender Pin |
4
|
|
|
|
|
|
|
# Copyright : Copyright (c) 2013-2017 Mark Dootson |
5
|
|
|
|
|
|
|
# License : This is free software; you can redistribute it and/or modify it under |
6
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
7
|
|
|
|
|
|
|
######################################################################################### |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package HiPi::Pin; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
######################################################################################### |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
1737
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
14
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
15
|
1
|
|
|
1
|
|
5
|
use parent qw( HiPi::Class ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
16
|
1
|
|
|
1
|
|
60
|
use HiPi qw( :rpi ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
796
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION ='0.80'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__PACKAGE__->create_ro_accessors( qw( pinid ) ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _open { |
23
|
0
|
|
|
0
|
|
|
my $class = shift; |
24
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
25
|
0
|
|
|
|
|
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub value { |
30
|
0
|
|
|
0
|
0
|
|
my($self, $newval) = @_; |
31
|
0
|
0
|
|
|
|
|
if(defined($newval)) { |
32
|
0
|
|
|
|
|
|
return $self->_do_setvalue($newval); |
33
|
|
|
|
|
|
|
} else { |
34
|
0
|
|
|
|
|
|
return $self->_do_getvalue(); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub mode { |
39
|
0
|
|
|
0
|
0
|
|
my($self, $newval) = @_; |
40
|
0
|
0
|
|
|
|
|
if(defined($newval)) { |
41
|
0
|
|
|
|
|
|
return $self->_do_setmode($newval); |
42
|
|
|
|
|
|
|
} else { |
43
|
0
|
|
|
|
|
|
return $self->_do_getmode(); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub set_pud { |
48
|
0
|
|
|
0
|
0
|
|
my($self, $newval) = @_; |
49
|
0
|
|
0
|
|
|
|
$newval //= RPI_PUD_OFF; |
50
|
0
|
|
|
|
|
|
my $rval; |
51
|
0
|
0
|
0
|
|
|
|
if( $newval == RPI_PUD_OFF || $newval == RPI_PUD_DOWN || $newval == RPI_PUD_UP ) { |
|
|
|
0
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$rval = $self->_do_setpud( $newval ); |
53
|
|
|
|
|
|
|
} else { |
54
|
0
|
|
|
|
|
|
croak(qq(Invalid PUD setting $newval)); |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
return $rval; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_pud { |
60
|
0
|
|
|
0
|
0
|
|
my( $self ) = @_; |
61
|
0
|
|
|
|
|
|
my $rval = $self->_do_getpud(); |
62
|
0
|
|
|
|
|
|
return $rval; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_function { |
66
|
0
|
|
|
0
|
0
|
|
my( $self ) = @_; |
67
|
0
|
|
|
|
|
|
return $self->_do_get_function_name(); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub active_low { |
71
|
0
|
|
|
0
|
0
|
|
my($self, $newval) = @_; |
72
|
0
|
0
|
|
|
|
|
if(defined($newval)) { |
73
|
0
|
|
|
|
|
|
return $self->_do_activelow($newval); |
74
|
|
|
|
|
|
|
} else { |
75
|
0
|
|
|
|
|
|
return $self->_do_activelow(); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub interrupt { |
80
|
0
|
|
|
0
|
0
|
|
my($self, $newedge) = @_; |
81
|
0
|
0
|
|
|
|
|
if(defined($newedge)) { |
82
|
0
|
|
0
|
|
|
|
$newedge ||= RPI_INT_NONE; |
83
|
0
|
0
|
|
|
|
|
$newedge = RPI_INT_FALL if $newedge eq 'falling'; |
84
|
0
|
0
|
|
|
|
|
$newedge = RPI_INT_RISE if $newedge eq 'rising'; |
85
|
0
|
0
|
|
|
|
|
$newedge = RPI_INT_BOTH if $newedge eq 'both'; |
86
|
0
|
0
|
|
|
|
|
$newedge = RPI_INT_NONE if $newedge eq 'none'; |
87
|
0
|
|
|
|
|
|
return $self->_do_setinterrupt($newedge); |
88
|
|
|
|
|
|
|
} else { |
89
|
0
|
|
|
|
|
|
return $self->_do_getinterrupt(); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub get_interrupt_filepath { |
94
|
0
|
|
|
0
|
0
|
|
my( $self ) = @_; |
95
|
0
|
|
|
|
|
|
return $self->_do_get_interrupt_filepath(); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |