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