39
39
40
40
# imports
41
41
try :
42
- from typing import Union
43
-
44
- from adafruit_dotstar import DotStar
45
- from neopixel import NeoPixel
42
+ from circuitpython_typing .led import FillBasedColorUnion
46
43
except ImportError :
47
44
pass
48
45
@@ -77,9 +74,10 @@ class PixelFramebuffer(adafruit_framebuf.FrameBuffer):
77
74
78
75
"""
79
76
77
+ # pylint: disable=too-many-arguments
80
78
def __init__ (
81
79
self ,
82
- pixels : Union [ NeoPixel , DotStar ] ,
80
+ pixels : FillBasedColorUnion ,
83
81
width : int ,
84
82
height : int ,
85
83
orientation : int = HORIZONTAL ,
@@ -89,7 +87,7 @@ def __init__(
89
87
top : int = 0 ,
90
88
bottom : int = 0 ,
91
89
rotation : int = 0 ,
92
- ) -> None : # pylint: disable=too-many-arguments
90
+ ) -> None :
93
91
self ._width = width
94
92
self ._height = height
95
93
@@ -107,7 +105,9 @@ def __init__(
107
105
108
106
self ._buffer = bytearray (width * height * 3 )
109
107
self ._double_buffer = bytearray (width * height * 3 )
110
- super ().__init__ (self ._buffer , width , height , buf_format = adafruit_framebuf .RGB888 )
108
+ super ().__init__ (
109
+ self ._buffer , width , height , buf_format = adafruit_framebuf .RGB888
110
+ )
111
111
self .rotation = rotation
112
112
113
113
def blit (self ) -> None :
@@ -119,7 +119,12 @@ def display(self) -> None:
119
119
for _y in range (self ._height ):
120
120
for _x in range (self ._width ):
121
121
index = (_y * self .stride + _x ) * 3
122
- if self ._buffer [index : index + 3 ] != self ._double_buffer [index : index + 3 ]:
122
+ if (
123
+ self ._buffer [index : index + 3 ]
124
+ != self ._double_buffer [index : index + 3 ]
125
+ ):
123
126
self ._grid [(_x , _y )] = tuple (self ._buffer [index : index + 3 ])
124
- self ._double_buffer [index : index + 3 ] = self ._buffer [index : index + 3 ]
127
+ self ._double_buffer [index : index + 3 ] = self ._buffer [
128
+ index : index + 3
129
+ ]
125
130
self ._grid .show ()
0 commit comments