@@ -134,14 +134,15 @@ class RGB565Format:
134
134
135
135
@staticmethod
136
136
def color_to_rgb565 (color ):
137
- """Convert a color in either tuple or 24 bit integer form to RGB565, and return as two bytes"""
137
+ """Convert a color in either tuple or 24 bit integer form to RGB565, and return as two bytes
138
+ """
138
139
if isinstance (color , tuple ):
139
- hi = (color [0 ] & 0xF8 ) | (color [1 ] >> 5 )
140
- lo = ((color [1 ] << 5 ) & 0xE0 ) | (color [2 ] >> 3 )
140
+ hibyte = (color [0 ] & 0xF8 ) | (color [1 ] >> 5 )
141
+ lobyte = ((color [1 ] << 5 ) & 0xE0 ) | (color [2 ] >> 3 )
141
142
else :
142
- hi = ((color >> 16 ) & 0xF8 ) | ((color >> 13 ) & 0x07 )
143
- lo = ((color >> 5 ) & 0xE0 ) | ((color >> 3 ) & 0x1F )
144
- return bytes ([lo , hi ])
143
+ hibyte = ((color >> 16 ) & 0xF8 ) | ((color >> 13 ) & 0x07 )
144
+ lobyte = ((color >> 5 ) & 0xE0 ) | ((color >> 3 ) & 0x1F )
145
+ return bytes ([lobyte , hibyte ])
145
146
146
147
def set_pixel (self , framebuf , x , y , color ):
147
148
"""Set a given pixel to a color."""
@@ -152,10 +153,10 @@ def set_pixel(self, framebuf, x, y, color):
152
153
def get_pixel (framebuf , x , y ):
153
154
"""Get the color of a given pixel"""
154
155
index = (y * framebuf .stride + x ) * 2
155
- bl , bh = framebuf .buf [index : index + 2 ]
156
- r = bh & 0xF8
157
- g = ((bh & 0x07 ) << 5 ) | ((bl & 0xE0 ) >> 5 )
158
- b = (bl & 0x1F ) << 3
156
+ lobyte , hibyte = framebuf .buf [index : index + 2 ]
157
+ r = hibyte & 0xF8
158
+ g = ((hibyte & 0x07 ) << 5 ) | ((lobyte & 0xE0 ) >> 5 )
159
+ b = (lobyte & 0x1F ) << 3
159
160
return (r << 16 ) | (g << 8 ) | b
160
161
161
162
def fill (self , framebuf , color ):
@@ -167,6 +168,7 @@ def fill(self, framebuf, color):
167
168
def fill_rect (self , framebuf , x , y , width , height , color ):
168
169
"""Draw a rectangle at the given location, size and color. The ``fill_rect`` method draws
169
170
both the outline and interior."""
171
+ # pylint: disable=too-many-arguments
170
172
rgb565_color = self .color_to_rgb565 (color )
171
173
for _y in range (2 * y , 2 * (y + height ), 2 ):
172
174
offset2 = _y * framebuf .stride
0 commit comments