line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2015-2022 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
126914
|
use v5.26; |
|
2
|
|
|
|
|
15
|
|
7
|
2
|
|
|
2
|
|
23
|
use Object::Pad 0.66; |
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
10
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Device::Chip::SSD1306::I2C 0.13; |
10
|
|
|
|
|
|
|
class Device::Chip::SSD1306::I2C |
11
|
1
|
|
|
1
|
|
575
|
:isa(Device::Chip::SSD1306); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
482
|
use constant PROTOCOL => "I2C"; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
138
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
12
|
use constant DEFAULT_ADDR => 0x3C; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1234
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=encoding UTF-8 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
C - use a F OLED driver in I²C mode |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This L subclass provides specific communication to an |
26
|
|
|
|
|
|
|
F chip attached via I²C. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
For actually interacting with the attached module, see the main |
29
|
|
|
|
|
|
|
L documentation. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
field $addr; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
2
|
method mount ( $adapter, %params ) |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
36
|
1
|
|
|
1
|
1
|
69
|
{ |
37
|
1
|
|
50
|
|
|
7
|
$addr = delete $params{addr} // DEFAULT_ADDR; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
8
|
return $self->SUPER::mount( $adapter, %params ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
method I2C_options |
43
|
1
|
|
|
1
|
0
|
321
|
{ |
44
|
|
|
|
|
|
|
return ( |
45
|
1
|
|
|
|
|
5
|
addr => $addr, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# passthrough |
50
|
0
|
|
|
0
|
0
|
0
|
method power ( $on ) { $self->protocol->power( $on ) } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
3
|
method send_cmd ( @vals ) |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
53
|
1
|
|
|
1
|
0
|
290
|
{ |
54
|
1
|
|
|
|
|
2
|
my $final = pop @vals; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
3
|
$self->protocol->write( join "", ( map { "\x80" . chr $_ } @vals ), |
|
2
|
|
|
|
|
16
|
|
57
|
|
|
|
|
|
|
"\x00" . chr $final ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
3
|
method send_data ( $bytes ) |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
61
|
1
|
|
|
1
|
0
|
11767
|
{ |
62
|
1
|
|
|
|
|
4
|
$self->protocol->write( "\x40" . $bytes ) |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Paul Evans |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
0x55AA; |