Skip to content

Commit c662a10

Browse files
author
Melissa LeBlanc-Williams
committed
Fixed more Travis CI errors
1 parent b89b204 commit c662a10

File tree

4 files changed

+38
-33
lines changed

4 files changed

+38
-33
lines changed

adafruit_ra8875/ra8875.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ def write_reg(self, cmd, data, raw=False):
169169
def write_cmd(self, cmd):
170170
"""Select a register and write a byte"""
171171
with self.spi_device as spi:
172-
spi.write(reg.CMDWR)
173-
spi.write(bytearray([cmd]))
172+
spi.write(reg.CMDWR) # pylint: disable=no-member
173+
spi.write(bytearray([cmd])) # pylint: disable=no-member
174174

175175
def write_data(self, data, raw=False):
176176
"""Write a byte of data or push raw data out"""
177177
with self.spi_device as spi:
178-
spi.write(reg.DATWR)
179-
spi.write(data if raw else bytearray([data]))
178+
spi.write(reg.DATWR) # pylint: disable=no-member
179+
spi.write(data if raw else bytearray([data])) # pylint: disable=no-member
180180

181181
def read_reg(self, cmd):
182182
"""Select a Register and read a byte"""
@@ -187,16 +187,16 @@ def read_status(self):
187187
"""Read the status at the current memory location"""
188188
cmd = bytearray(1)
189189
with self.spi_device as spi:
190-
spi.write(reg.CMDRD)
191-
spi.readinto(cmd)
190+
spi.write(reg.CMDRD) # pylint: disable=no-member
191+
spi.readinto(cmd) # pylint: disable=no-member
192192
return struct.unpack(">B", cmd)[0]
193193

194194
def read_data(self):
195195
"""Read a byte at the current memory location"""
196196
data = bytearray(1)
197197
with self.spi_device as spi:
198-
spi.write(reg.DATRD)
199-
spi.readinto(data)
198+
spi.write(reg.DATRD) # pylint: disable=no-member
199+
spi.readinto(data) # pylint: disable=no-member
200200
return struct.unpack(">B", data)[0]
201201

202202
def wait_poll(self, register, mask):
@@ -410,11 +410,6 @@ def set_window(self, x, y, width, height):
410410
self.write_reg(reg.VEAW0 + 1, (y + height) >> 8)
411411
#pylint: enable-msg=invalid-name,too-many-arguments
412412

413-
@staticmethod
414-
def _encode_pixel(color):
415-
"""Encode a pixel that is compatible with this display"""
416-
return struct.pack(">H", color)
417-
418413
class RA8875(RA8875Display):
419414
"""Set Initial Variables"""
420415
#pylint: disable-msg=invalid-name,too-many-arguments

docs/api.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
55
.. use this format as the module name: "adafruit_foo.foo"
66
7-
.. automodule:: adafruit_ra8875
7+
.. automodule:: adafruit_ra8875.ra8875
88
:members:
9+
10+
.. automodule:: adafruit_ra8875.registers
11+
:members:
12+

examples/ra8875_bmptest.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# Quick bitmap test of RA8875 with Feather M4
2-
import time
32
import busio
43
import digitalio
54
import board
65

76
import adafruit_ra8875.ra8875 as ra8875
87
from adafruit_ra8875.ra8875 import color565
8+
try:
9+
import struct
10+
except ImportError:
11+
import ustruct as struct
912

1013
WHITE = color565(255, 255, 255)
1114

@@ -24,10 +27,15 @@
2427
display.init()
2528
display.fill(WHITE)
2629

27-
class BMP:
30+
class BMP(object):
2831
def __init__(self, filename):
2932
self.filename = filename
30-
self.colors = 0
33+
self.colors = None
34+
self.data = 0
35+
self.data_size = 0
36+
self.bpp = 0
37+
self.width = 0
38+
self.height=0
3139

3240
def read_header(self):
3341
if self.colors:
@@ -45,22 +53,20 @@ def read_header(self):
4553
f.seek(46)
4654
self.colors = int.from_bytes(f.read(4), 'little')
4755

48-
def draw(self, display, x=0, y=0):
56+
def draw(self, disp, x=0, y=0):
4957
self.read_header()
5058
print("{:d}x{:d} image".format(self.width, self.height))
5159
print("{:d}-bit encoding detected".format(self.bpp))
52-
line = 0;
60+
line = 0
5361
line_size = self.width * (self.bpp//8)
54-
mod4 = line_size % 4
55-
if mod4 !=0:
56-
line_size += (4-mod4)
57-
self.bmp_data = b''
58-
self.current_line_data = b''
62+
if line_size % 4 != 0:
63+
line_size += (4 - line_size % 4)
64+
current_line_data = b''
5965
with open(self.filename, 'rb') as f:
6066
f.seek(self.data)
61-
display.set_window(x, y, self.width, self.height)
67+
disp.set_window(x, y, self.width, self.height)
6268
for line in range(self.height):
63-
self.current_line_data = b''
69+
current_line_data = b''
6470
line_data = f.read(line_size)
6571
for i in range(0, line_size, self.bpp//8):
6672
if (line_size-i) < self.bpp//8:
@@ -72,10 +78,10 @@ def draw(self, display, x=0, y=0):
7278
if self.bpp == 24:
7379
b3 = line_data[i+2]
7480
color = color565(b1, b2, b3)
75-
c = display._encode_pixel(color)
76-
self.current_line_data = self.current_line_data + c
77-
display.setxy(x, self.height - line + y)
78-
display.push_pixels(self.current_line_data)
79-
display.set_window(0, 0, display.width, display.height)
81+
c = struct.pack(">H", color)
82+
current_line_data = current_line_data + c
83+
disp.setxy(x, self.height - line + y)
84+
disp.push_pixels(current_line_data)
85+
disp.set_window(0, 0, disp.width, disp.height)
8086

81-
BMP("/blinka.bmp").draw(display, 287, 127)
87+
BMP("/blinka.bmp").draw(display, 287, 127)

examples/ra8875_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@
8080
display.txt_set_cursor(240, 240)
8181
display.txt_size(2)
8282
display.txt_write("Position (" + str(int(coords[0]/x_scale)) + ", " +
83-
str(int(coords[1]/y_scale)) + ")")
83+
str(int(coords[1]/y_scale)) + ")")

0 commit comments

Comments
 (0)