line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Device::WebIO::Device::PWM; |
2
|
|
|
|
|
|
|
$Device::WebIO::Device::PWM::VERSION = '0.022'; |
3
|
2
|
|
|
2
|
|
10083
|
use v5.12; |
|
2
|
|
|
|
|
5
|
|
4
|
2
|
|
|
2
|
|
8
|
use Moo::Role; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with 'Device::WebIO::Device'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires 'pwm_bit_resolution'; |
9
|
|
|
|
|
|
|
requires 'pwm_pin_count'; |
10
|
|
|
|
|
|
|
requires 'pwm_output_int'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub pwm_max_int |
14
|
|
|
|
|
|
|
{ |
15
|
3
|
|
|
3
|
0
|
6
|
my ($self, $pin) = @_; |
16
|
3
|
|
|
|
|
6
|
my $resolution = $self->pwm_bit_resolution( $pin ); |
17
|
3
|
|
|
|
|
20
|
return 2 ** $resolution - 1; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub pwm_output_float |
21
|
|
|
|
|
|
|
{ |
22
|
1
|
|
|
1
|
0
|
2
|
my ($self, $pin, $out) = @_; |
23
|
1
|
|
|
|
|
2
|
my $max_int = $self->pwm_max_int( $pin ); |
24
|
1
|
|
|
|
|
5
|
my $int_out = sprintf( '%.0f', $max_int * $out ); |
25
|
1
|
|
|
|
|
3
|
return $self->pwm_output_int( $pin, $int_out ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
__END__ |