34
34
# Datasheet high times for a "1" bit are 650 (min) 720 (typ) 1000 (max) ns
35
35
#
36
36
# Operating PIO at 14x the bit clock lets us achieve nominal 357ns and 714ns
37
- _program = Program (
38
- f"""
39
- .side_set 1
40
- .wrap_target
41
- pull block side 1
42
- out y, 32 side 1 ; get count of pixel bits
43
-
44
- bitloop:
45
- pull ifempty side 1 ; drive low
46
- out x 1 side 1 [4]
47
- jmp !x do_zero side 0 [3] ; drive low and branch depending on bit val
48
- jmp y--, bitloop side 0 [3] ; drive low for a one (long pulse)
49
- jmp end_sequence side 1 ; sequence is over
50
-
51
- do_zero:
52
- jmp y--, bitloop side 1 [3] ; drive high for a zero (short pulse)
53
-
54
- end_sequence:
55
- pull block side 1 ; get fresh delay value
56
- out y, 32 side 1 ; get delay count
57
- wait_reset:
58
- jmp y--, wait_reset side 1 ; wait until delay elapses
59
- .wrap
60
- """
61
- )
37
+ _pio_source = ()
62
38
63
39
TM1814_MIN_CURRENT = 6.5
64
40
TM1814_MAX_CURRENT = 38
@@ -101,6 +77,7 @@ class TM1814PixelBackground( # pylint: disable=too-few-public-methods
101
77
below.
102
78
:param str pixel_order: Set the pixel color channel order. WRGB is set by
103
79
default. Only 4-bytes-per-pixel formats are supported.
80
+ :param bool inverted: True to invert the polarity of the output signal.
104
81
"""
105
82
106
83
def __init__ ( # noqa: PLR0913
@@ -111,10 +88,35 @@ def __init__( # noqa: PLR0913
111
88
brightness : float = 1.0 ,
112
89
pixel_order : str = "WRGB" ,
113
90
current_control : float | tuple [float , float , float , float ] = 38.0 ,
91
+ inverted : bool = False ,
114
92
):
115
93
if len (pixel_order ) != 4 :
116
94
raise ValueError ("Invalid pixel_order" )
117
95
96
+ _program = Program (f"""
97
+ .side_set 1
98
+ .wrap_target
99
+ pull block side { not inverted :1d}
100
+ out y, 32 side { not inverted :1d} ; get count of pixel bits
101
+
102
+ bitloop:
103
+ pull ifempty side { not inverted :1d} ; drive low
104
+ out x 1 side { not inverted :1d} [4]
105
+ jmp !x do_zero side { inverted :1d} [3] ; drive low and branch depending on bit val
106
+ jmp y--, bitloop side { inverted :1d} [3] ; drive low for a one (long pulse)
107
+ jmp end_sequence side { not inverted :1d} ; sequence is over
108
+
109
+ do_zero:
110
+ jmp y--, bitloop side { not inverted :1d} [3] ; drive high for a zero (short pulse)
111
+
112
+ end_sequence:
113
+ pull block side { not inverted :1d} ; get fresh delay value
114
+ out y, 32 side { not inverted :1d} ; get delay count
115
+ wait_reset:
116
+ jmp y--, wait_reset side { not inverted :1d} ; wait until delay elapses
117
+ .wrap
118
+ """ )
119
+
118
120
byte_count = 4 * n
119
121
bit_count = byte_count * 8 + 64 # count the 64 brightness bits
120
122
0 commit comments