File Coverage

blib/lib/Device/WebIO/PCDuino.pm
Criterion Covered Total %
statement 12 28 42.8
branch n/a
condition n/a
subroutine 4 9 44.4
pod n/a
total 16 37 43.2


line stmt bran cond sub pod time code
1             # Copyright (c) 2014 Timm Murray
2             # All rights reserved.
3             #
4             # Redistribution and use in source and binary forms, with or without
5             # modification, are permitted provided that the following conditions are met:
6             #
7             # * Redistributions of source code must retain the above copyright notice,
8             # this list of conditions and the following disclaimer.
9             # * Redistributions in binary form must reproduce the above copyright
10             # notice, this list of conditions and the following disclaimer in the
11             # documentation and/or other materials provided with the distribution.
12             #
13             # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14             # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15             # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16             # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17             # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18             # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19             # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20             # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21             # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22             # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23             # POSSIBILITY OF SUCH DAMAGE.
24             package Device::WebIO::PCDuino;
25             $Device::WebIO::PCDuino::VERSION = '0.001';
26             # ABSTRACT: Device::WebIO implementation for the pcDuino
27 1     1   816 use v5.12;
  1         4  
  1         38  
28 1     1   839 use Moo;
  1         17790  
  1         7  
29 1     1   2473 use namespace::clean;
  1         13690  
  1         7  
30 1     1   948 use Device::PCDuino ();
  1         890  
  1         288  
31              
32              
33             sub BUILDARGS
34             {
35 0     0     my ($class, $args) = @_;
36              
37             #$args->{pwm_bit_resolution} = 8;
38             #$args->{pwm_max_int} = 2 ** $args->{pwm_bit_resolution};
39 0           $args->{input_pin_count} = 18;
40 0           $args->{output_pin_count} = 18;
41             #$args->{pwm_pin_count} = 1;
42             # TODO
43             # 6 bits for ADC 0 and 1, but 12 for the rest
44             #$args->{adc_bit_resolution} = 12;
45             #$args->{adc_max_int} = 2 ** $args->{adc_bit_resolution};
46             # TODO
47             # 2 Volts for ADC 0 and 1, but 3.3V for the rest
48             #$args->{adc_volt_ref} = 3.3;
49             #$args->{adc_pin_count} = 6;
50              
51 0           return $args;
52             }
53              
54              
55             has 'input_pin_count', is => 'ro';
56             with 'Device::WebIO::Device::DigitalInput';
57              
58             sub set_as_input
59             {
60 0     0     my ($self, $pin) = @_;
61 0           Device::PCDuino::set_input( $pin );
62 0           return 1;
63             }
64              
65             sub input_pin
66             {
67 0     0     my ($self, $pin) = @_;
68 0           my $in = Device::PCDuino::input( $pin );
69 0           return $in;
70             }
71              
72              
73             has 'output_pin_count', is => 'ro';
74             with 'Device::WebIO::Device::DigitalOutput';
75              
76             sub set_as_output
77             {
78 0     0     my ($self, $pin) = @_;
79 0           Device::PCDuino::set_output( $pin );
80 0           return 1;
81             }
82              
83             sub output_pin
84             {
85 0     0     my ($self, $pin, $val) = @_;
86 0           Device::PCDuino::output( $pin, $val );
87 0           return 1;
88             }
89              
90              
91             # TODO PWM
92             #has 'pwm_pin_count', is => 'ro';
93             #has 'pwm_bit_resolution', is => 'ro';
94             #has 'pwm_max_int', is => 'ro';
95             #with 'Device::WebIO::Device::PWM';
96             #
97             #sub pwm_output_int
98             #{
99             #}
100              
101              
102             # TODO ADC
103             #has 'adc_max_int', is => 'ro';
104             #has 'adc_bit_resolution', is => 'ro';
105             #has 'adc_volt_ref', is => 'ro';
106             #has 'adc_pin_count', is => 'ro';
107             #with 'Device::WebIO::Device::ADC';
108             #
109             #sub adc_input_int
110             #{
111             #}
112              
113              
114             # TODO
115             #with 'Device::WebIO::Device::SPI';
116             #with 'Device::WebIO::Device::I2C';
117             #with 'Device::WebIO::Device::Serial';
118             #with 'Device::WebIO::Device::VideoStream';
119              
120             1;
121             __END__