line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RPi::BMP180; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
14632
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.3603'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
191
|
use WiringPi::API qw(:all); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use RPi::WiringPi::Constant qw(:all); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
my ($class, $pin_base) = @_; |
13
|
|
|
|
|
|
|
my $self = bless {}, $class; |
14
|
|
|
|
|
|
|
$self->_pin_base($pin_base); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
setup_gpio(); |
17
|
|
|
|
|
|
|
bmp180_setup($pin_base); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
sub temp { |
22
|
|
|
|
|
|
|
my ($self, $want) = @_; |
23
|
|
|
|
|
|
|
return bmp180_temp($self->_pin_base + 0, $want); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
sub pressure { |
26
|
|
|
|
|
|
|
my ($self) = @_; |
27
|
|
|
|
|
|
|
return bmp180_pressure($self->_pin_base + 1); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
sub _pin_base { |
30
|
|
|
|
|
|
|
my ($self, $base) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
if (defined $base){ |
33
|
|
|
|
|
|
|
if ($base !~ /^\d+$/){ |
34
|
|
|
|
|
|
|
die "_pin_base() requires an integer\n"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
$self->{bmp_pin_base} = $base; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
if (! defined $self->{bmp_pin_base}){ |
40
|
|
|
|
|
|
|
die "_pin_base() has not yet been set...\n"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
return $self->{bmp_pin_base}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
sub _vim{}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
__END__ |