line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
######################################################################################### |
2
|
|
|
|
|
|
|
# Package HiPi::Interface |
3
|
|
|
|
|
|
|
# Description : Base class for interfaces |
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::Interface; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
######################################################################################### |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
375
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
24
|
|
14
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
15
|
1
|
|
|
1
|
|
4
|
use parent qw( HiPi::Class ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
16
|
1
|
|
|
1
|
|
626
|
use Time::HiRes qw( usleep ); |
|
1
|
|
|
|
|
1497
|
|
|
1
|
|
|
|
|
5
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
__PACKAGE__->create_accessors( qw( device ) ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION ='0.80'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
0
|
|
|
0
|
0
|
|
my ($class, %params) = @_; |
24
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(%params); |
25
|
0
|
|
|
|
|
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub delay { |
29
|
0
|
|
|
0
|
0
|
|
my($class, $millis) = @_; |
30
|
0
|
|
|
|
|
|
usleep( int($millis * 1000) ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub delayMicroseconds { |
34
|
0
|
|
|
0
|
0
|
|
my($class, $micros) = @_; |
35
|
0
|
|
|
|
|
|
usleep( int($micros) ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
*HiPi::Interface::sleep_milliseconds = \&delay; |
39
|
|
|
|
|
|
|
*HiPi::Interface::sleep_microseconds = \&delayMicroseconds; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub DESTROY { |
42
|
0
|
|
|
0
|
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
$self->SUPER::DESTROY; |
44
|
0
|
|
|
|
|
|
$self->device( undef ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |