@@ -70,9 +70,9 @@ def _block(self, xpos0, ypos0, xpos1, ypos1, data=None):
70
70
return None
71
71
#pylint: enable-msg=too-many-arguments
72
72
73
- def _encode_pos (self , avalue , bvalue ):
73
+ def _encode_pos (self , x , y ): #pylint: disable-msg=invalid-name
74
74
"""Encode a postion into bytes."""
75
- return struct .pack (self ._ENCODE_POS , avalue , bvalue )
75
+ return struct .pack (self ._ENCODE_POS , x , y )
76
76
77
77
def _encode_pixel (self , color ):
78
78
"""Encode a pixel color into bytes."""
@@ -82,23 +82,23 @@ def _decode_pixel(self, data):
82
82
"""Decode bytes into a pixel color."""
83
83
return color565 (* struct .unpack (self ._DECODE_PIXEL , data ))
84
84
85
- def pixel (self , xpos , ypos , color = None ):
85
+ def pixel (self , x , y , color = None ): #pylint: disable-msg=invalid-name
86
86
"""Read or write a pixel."""
87
87
if color is None :
88
- return self ._decode_pixel (self ._block (xpos , ypos , xpos , ypos ))
88
+ return self ._decode_pixel (self ._block (x , y , x , y ))
89
89
90
- if 0 <= xpos < self .width and 0 <= ypos < self .height :
91
- self ._block (xpos , ypos , xpos , ypos , self ._encode_pixel (color ))
90
+ if 0 <= x < self .width and 0 <= y < self .height :
91
+ self ._block (x , y , x , y , self ._encode_pixel (color ))
92
92
return None
93
93
94
94
#pylint: disable-msg=too-many-arguments
95
- def fill_rectangle (self , xpos , ypos , width , height , color ):
95
+ def fill_rectangle (self , x , y , width , height , color ): #pylint: disable-msg=invalid-name
96
96
"""Draw a filled rectangle."""
97
- xpos = min (self .width - 1 , max (0 , xpos ))
98
- ypos = min (self .height - 1 , max (0 , ypos ))
99
- width = min (self .width - xpos , max (1 , width ))
100
- height = min (self .height - ypos , max (1 , height ))
101
- self ._block (xpos , ypos , xpos + width - 1 , ypos + height - 1 , b'' )
97
+ x = min (self .width - 1 , max (0 , x ))
98
+ y = min (self .height - 1 , max (0 , y ))
99
+ width = min (self .width - x , max (1 , width ))
100
+ height = min (self .height - y , max (1 , height ))
101
+ self ._block (x , y , x + width - 1 , y + height - 1 , b'' )
102
102
chunks , rest = divmod (width * height , _BUFFER_SIZE )
103
103
pixel = self ._encode_pixel (color )
104
104
if chunks :
@@ -112,13 +112,13 @@ def fill(self, color=0):
112
112
"""Fill whole screen."""
113
113
self .fill_rectangle (0 , 0 , self .width , self .height , color )
114
114
115
- def hline (self , xpos , ypos , width , color ):
115
+ def hline (self , x , y , width , color ): #pylint: disable-msg=invalid-name
116
116
"""Draw a horizontal line."""
117
- self .fill_rectangle (xpos , ypos , width , 1 , color )
117
+ self .fill_rectangle (x , y , width , 1 , color )
118
118
119
- def vline (self , xpos , ypos , height , color ):
119
+ def vline (self , x , y , height , color ): #pylint: disable-msg=invalid-name
120
120
"""Draw a vertical line."""
121
- self .fill_rectangle (xpos , ypos , 1 , height , color )
121
+ self .fill_rectangle (x , y , 1 , height , color )
122
122
123
123
def write (self , command , data ):
124
124
"""Derived class must implement this"""
@@ -135,9 +135,9 @@ def __init__(self, spi, dc, cs, rst=None, width=1, height=1, baudrate=1000000,
135
135
polarity = 0 , phase = 0 ):
136
136
self .spi_device = spi_device .SPIDevice (spi , cs , baudrate = baudrate ,
137
137
polarity = polarity , phase = phase )
138
- self .d_or_c = dc
138
+ self .dc_pin = dc
139
139
self .rst = rst
140
- self .d_or_c .switch_to_output (value = 0 )
140
+ self .dc_pin .switch_to_output (value = 0 )
141
141
if self .rst :
142
142
self .rst .switch_to_output (value = 0 )
143
143
self .reset ()
@@ -154,18 +154,18 @@ def reset(self):
154
154
def write (self , command = None , data = None ):
155
155
"""SPI write to the device: commands and data"""
156
156
if command is not None :
157
- self .d_or_c .value = 0
157
+ self .dc_pin .value = 0
158
158
with self .spi_device as spi :
159
159
spi .write (bytearray ([command ]))
160
160
if data is not None :
161
- self .d_or_c .value = 1
161
+ self .dc_pin .value = 1
162
162
with self .spi_device as spi :
163
163
spi .write (data )
164
164
165
165
def read (self , command = None , count = 0 ):
166
166
"""SPI read from device with optional command"""
167
167
data = bytearray (count )
168
- self .d_or_c .value = 0
168
+ self .dc_pin .value = 0
169
169
with self .spi_device as spi :
170
170
if command is not None :
171
171
spi .write (bytearray ([command ]))
0 commit comments