File Coverage

blib/lib/Device/WebIO/Device/PWM.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 17 19 89.4


line stmt bran cond sub pod time code
1             package Device::WebIO::Device::PWM;
2             $Device::WebIO::Device::PWM::VERSION = '0.009';
3 2     2   11445 use v5.12;
  2         7  
  2         106  
4 2     2   12 use Moo::Role;
  2         5  
  2         15  
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 4 my ($self, $pin) = @_;
16 3         8 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         7 my $max_int = $self->pwm_max_int( $pin );
24 1         6 my $int_out = sprintf( '%.0f', $max_int * $out );
25 1         4 return $self->pwm_output_int( $pin, $int_out );
26             }
27              
28              
29             1;
30             __END__