Skip to content

Commit 3befa99

Browse files
committed
Fix pylint issues
1 parent 8436072 commit 3befa99

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

adafruit_framebuf.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,15 @@ class RGB565Format:
134134

135135
@staticmethod
136136
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+
"""
138139
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)
141142
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])
145146

146147
def set_pixel(self, framebuf, x, y, color):
147148
"""Set a given pixel to a color."""
@@ -152,10 +153,10 @@ def set_pixel(self, framebuf, x, y, color):
152153
def get_pixel(framebuf, x, y):
153154
"""Get the color of a given pixel"""
154155
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
159160
return (r << 16) | (g << 8) | b
160161

161162
def fill(self, framebuf, color):
@@ -167,6 +168,7 @@ def fill(self, framebuf, color):
167168
def fill_rect(self, framebuf, x, y, width, height, color):
168169
"""Draw a rectangle at the given location, size and color. The ``fill_rect`` method draws
169170
both the outline and interior."""
171+
# pylint: disable=too-many-arguments
170172
rgb565_color = self.color_to_rgb565(color)
171173
for _y in range(2 * y, 2 * (y + height), 2):
172174
offset2 = _y * framebuf.stride

0 commit comments

Comments
 (0)