Skip to content

Commit 3e79ae2

Browse files
author
Melissa LeBlanc-Williams
committed
Linting
1 parent e9d7a49 commit 3e79ae2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

examples/ra8875_bmptest.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
display.init()
2828
display.fill(WHITE)
2929

30+
def color555(self, rgb):
31+
return (rgb & 0x001F) << 11 | (rgb & 0x0700) | (rgb & 0x0060) << 1 | 0x20 | (rgb & 0xF800) >> 11
32+
3033
class BMP(object):
3134
def __init__(self, filename):
3235
self.filename = filename
@@ -53,8 +56,6 @@ def read_header(self):
5356
self.data_size = int.from_bytes(f.read(4), 'little')
5457
f.seek(46)
5558
self.colors = int.from_bytes(f.read(4), 'little')
56-
def color555(self, rgb):
57-
return (rgb & 0x001F) << 11 | (rgb & 0x0700) | (rgb & 0x0060) << 1 | 0x20 | (rgb & 0xF800) >> 11
5859

5960
def draw(self, disp, x=0, y=0):
6061
print("{:d}x{:d} image".format(self.width, self.height))
@@ -74,7 +75,7 @@ def draw(self, disp, x=0, y=0):
7475
if (line_size-i) < self.bpp//8:
7576
break
7677
if self.bpp == 16:
77-
color = self.color555(line_data[i] << 8 | line_data[i+1])
78+
color = color555(line_data[i] << 8 | line_data[i+1])
7879
if self.bpp == 24:
7980
color = color565(line_data[i+2], line_data[i+1], line_data[i])
8081
current_line_data = current_line_data + struct.pack(">H", color)
@@ -83,4 +84,6 @@ def draw(self, disp, x=0, y=0):
8384
disp.set_window(0, 0, disp.width, disp.height)
8485

8586
bitmap = BMP("/ra8875_blinka.bmp")
86-
bitmap.draw(display, (display.width // 2) - (bitmap.width // 2), (display.height // 2) - (bitmap.height // 2))
87+
x_position = (display.width // 2) - (bitmap.width // 2)
88+
y_position = (display.height // 2) - (bitmap.height // 2)
89+
bitmap.draw(display, x_position, y_position)

0 commit comments

Comments
 (0)