File Coverage

blib/lib/RPi/BMP180.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package RPi::BMP180;
2              
3 1     1   21865 use strict;
  1         4  
  1         37  
4 1     1   7 use warnings;
  1         3  
  1         58  
5              
6             our $VERSION = '2.3604';
7              
8 1     1   270 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__