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-2023 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
262904
|
use v5.26; |
|
2
|
|
|
|
|
15
|
|
7
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
54
|
|
8
|
2
|
|
|
2
|
|
8
|
use Object::Pad 0.800; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
72
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Device::Chip::SSD1306::SPI4 0.14; |
11
|
|
|
|
|
|
|
class Device::Chip::SSD1306::SPI4 |
12
|
1
|
|
|
1
|
|
508
|
:isa(Device::Chip::SSD1306); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
36
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
407
|
use Future::AsyncAwait; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
7
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
C - use a F OLED driver in 4-wire SPI mode |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This L subclass provides specific communication to an |
23
|
|
|
|
|
|
|
F chip attached via SPI in 4-wire mode; using the C pin. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
For actually interacting with the attached module, see the main |
26
|
|
|
|
|
|
|
L documentation. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
|
111
|
use constant PROTOCOL => "SPI"; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1648
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
method SPI_options |
33
|
1
|
|
|
1
|
0
|
359
|
{ |
34
|
|
|
|
|
|
|
return ( |
35
|
1
|
|
|
|
|
5
|
mode => 0, |
36
|
|
|
|
|
|
|
max_bitrate => 1E6, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 MOUNT PARAMETERS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 dc |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The name of the GPIO line on the adapter that is connected to the C pin |
45
|
|
|
|
|
|
|
of the chip. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
field $dc; |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
2
|
method mount ( $adapter, %params ) |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
52
|
1
|
|
|
1
|
1
|
66
|
{ |
53
|
|
|
|
|
|
|
$dc = delete $params{dc} or |
54
|
1
|
50
|
|
|
|
4
|
die "Require a 'dc' parameter"; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
6
|
return $self->SUPER::mount( $adapter, %params ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# passthrough |
60
|
0
|
|
|
0
|
0
|
0
|
method power ( $on ) { $self->protocol->power( $on ) } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
4
|
method set_dc ( $on ) |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
4
|
|
63
|
2
|
|
|
2
|
0
|
5
|
{ |
64
|
2
|
|
|
|
|
7
|
$self->protocol->write_gpios( { $dc => $on } ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
2
|
async method send_cmd ( @vals ) |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
68
|
1
|
|
|
|
|
2
|
{ |
69
|
1
|
|
|
|
|
3
|
await $self->set_dc( 0 ); |
70
|
1
|
|
|
|
|
7697
|
await $self->protocol->readwrite( join "", map { chr } @vals ); |
71
|
1
|
|
|
1
|
0
|
306
|
} |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
3
|
async method send_data ( $bytes ) |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1
|
|
74
|
1
|
|
|
|
|
3
|
{ |
75
|
1
|
|
|
|
|
3
|
await $self->set_dc( 1 ); |
76
|
1
|
|
|
|
|
1090
|
await $self->protocol->readwrite( $bytes ); |
77
|
1
|
|
|
1
|
0
|
4841
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Paul Evans |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
0x55AA; |