line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
21171
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Device::LSM303DLHC; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# PODNAME: Device::LSM303DLHC |
7
|
|
|
|
|
|
|
# ABSTRACT: I2C interface to LSM303DLHC 3 axis magnetometer(compass) and accelerometer using Device::SMBus |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# This file is part of Device-LSM303DLHC |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# This software is copyright (c) 2013 by Shantanu Bhadoria. |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
14
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
our $VERSION = '0.011'; # VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Dependencies |
19
|
1
|
|
|
1
|
|
23
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
20
|
1
|
|
|
1
|
|
438
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use POSIX; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Device::SMBus; |
24
|
|
|
|
|
|
|
use Device::Magnetometer::LSM303DLHC; |
25
|
|
|
|
|
|
|
use Device::Accelerometer::LSM303DLHC; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'I2CBusDevicePath' => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
required => 1, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has Magnetometer => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => 'Device::Magnetometer::LSM303DLHC', |
37
|
|
|
|
|
|
|
lazy_build => 1, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _build_Magnetometer { |
41
|
|
|
|
|
|
|
my ($self) = @_; |
42
|
|
|
|
|
|
|
my $obj = |
43
|
|
|
|
|
|
|
Device::Magnetometer::LSM303DLHC->new( |
44
|
|
|
|
|
|
|
I2CBusDevicePath => $self->I2CBusDevicePath ); |
45
|
|
|
|
|
|
|
return $obj; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has Accelerometer => ( |
50
|
|
|
|
|
|
|
is => 'ro', |
51
|
|
|
|
|
|
|
isa => 'Device::Accelerometer::LSM303DLHC', |
52
|
|
|
|
|
|
|
lazy_build => 1, |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _build_Accelerometer { |
56
|
|
|
|
|
|
|
my ($self) = @_; |
57
|
|
|
|
|
|
|
my $obj = |
58
|
|
|
|
|
|
|
Device::Accelerometer::LSM303DLHC->new( |
59
|
|
|
|
|
|
|
I2CBusDevicePath => $self->I2CBusDevicePath ); |
60
|
|
|
|
|
|
|
return $obj; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=pod |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Device::LSM303DLHC - I2C interface to LSM303DLHC 3 axis magnetometer(compass) and accelerometer using Device::SMBus |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 0.011 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 I2CBusDevicePath |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
this is the device file path for your I2CBus that the LSM303DLHC is connected on e.g. /dev/i2c-1 |
82
|
|
|
|
|
|
|
This must be provided during object creation. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 Magnetometer |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$self->Magnetometer->enable(); |
87
|
|
|
|
|
|
|
$self->Magnetometer->getReading(); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This is a object of L<Device::Magnetometer::LSM303DLHC> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 Accelerometer |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$self->Accelerometer->enable(); |
94
|
|
|
|
|
|
|
$self->Accelerometer->getReading(); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This is a object of L<Device::Accelerometer::LSM303DLHC> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SUPPORT |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 Bugs / Feature Requests |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Please report any bugs or feature requests through github at |
105
|
|
|
|
|
|
|
L<https://github.com/shantanubhadoria/device-lsm303dlhc/issues>. |
106
|
|
|
|
|
|
|
You will be notified automatically of any progress on your issue. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 Source Code |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is open source software. The code repository is available for |
111
|
|
|
|
|
|
|
public review and contribution under the terms of the license. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L<https://github.com/shantanubhadoria/device-lsm303dlhc> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
git clone git://github.com/shantanubhadoria/device-lsm303dlhc.git |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Shantanu Bhadoria <shantanu at cpan dott org> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=over 4 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Shantanu <shantanu@cpan.org> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Shantanu Bhadoria <shantanu@cpan.org> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Shantanu Bhadoria. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
140
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |