Skip to content

Commit 4520cfd

Browse files
authored
Merge pull request #66 from makermelissa/master
Refactored with kwargs to remove similar code
2 parents 9d9545d + b1cf044 commit 4520cfd

File tree

4 files changed

+17
-32
lines changed

4 files changed

+17
-32
lines changed

adafruit_matrixportal/graphics.py

+4-19
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,11 @@ class Graphics(GraphicsBase):
5555
# pylint: disable=too-few-public-methods
5656
def __init__(
5757
self,
58-
*,
59-
default_bg=0x000000,
60-
width=64,
61-
height=32,
62-
bit_depth=2,
63-
alt_addr_pins=None,
64-
color_order="RGB",
65-
serpentine=True,
66-
tile_rows=1,
67-
debug=False
58+
**kwargs,
6859
):
60+
default_bg = kwargs.pop("default_bg")
61+
debug = kwargs.pop("debug")
6962

70-
matrix = Matrix(
71-
bit_depth=bit_depth,
72-
width=width,
73-
height=height,
74-
alt_addr_pins=alt_addr_pins,
75-
color_order=color_order,
76-
serpentine=serpentine,
77-
tile_rows=tile_rows,
78-
)
63+
matrix = Matrix(**kwargs)
7964

8065
super().__init__(matrix.display, default_bg=default_bg, debug=debug)

adafruit_matrixportal/network.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,15 @@ class Network(NetworkBase):
4848
4949
"""
5050

51-
def __init__(
52-
self,
53-
*,
54-
status_neopixel=None,
55-
esp=None,
56-
external_spi=None,
57-
extract_values=True,
58-
debug=False,
59-
):
60-
wifi = WiFi(status_neopixel=status_neopixel, esp=esp, external_spi=external_spi)
51+
def __init__(self, **kwargs):
52+
extract_values = kwargs.pop("extract_values")
53+
debug = kwargs.pop("debug")
54+
wifi = WiFi(**kwargs)
6155

6256
super().__init__(
63-
wifi, extract_values=extract_values, debug=debug,
57+
wifi,
58+
extract_values=extract_values,
59+
debug=debug,
6460
)
6561

6662
gc.collect()

examples/matrixportal_scrolling_bitcoin.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def text_transform(val):
3030
cwd = ("/" + __file__).rsplit("/", 1)[0]
3131

3232
matrixportal = MatrixPortal(
33-
url=DATA_SOURCE, json_path=DATA_LOCATION, status_neopixel=board.NEOPIXEL,
33+
url=DATA_SOURCE,
34+
json_path=DATA_LOCATION,
35+
status_neopixel=board.NEOPIXEL,
3436
)
3537

3638
matrixportal.add_text(

examples/matrixportal_simpletest.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def text_transform(val):
3030
cwd = ("/" + __file__).rsplit("/", 1)[0]
3131

3232
matrixportal = MatrixPortal(
33-
url=DATA_SOURCE, json_path=DATA_LOCATION, status_neopixel=board.NEOPIXEL,
33+
url=DATA_SOURCE,
34+
json_path=DATA_LOCATION,
35+
status_neopixel=board.NEOPIXEL,
3436
)
3537

3638
matrixportal.add_text(

0 commit comments

Comments
 (0)