Skip to content

Commit 446d00e

Browse files
committed
Updated code to pass pylint
1 parent 8d1568f commit 446d00e

1 file changed

Lines changed: 19 additions & 41 deletions

File tree

  • MatrixPortal_S3_Flight_Proximity_Tracker

MatrixPortal_S3_Flight_Proximity_Tracker/code.py

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,31 @@
2222
DISPLAY_WIDTH = 128
2323
DISPLAY_HEIGHT = 64
2424

25-
NETWORK_CALL_INTERVAL = 25920 # 432 Minutes - 7.2 Hours
25+
# 432 Minutes - 7.2 Hours
26+
NETWORK_CALL_INTERVAL = 25920
2627

2728
# --- Icon Properties ---
28-
2929
ICON_WIDTH = 26 # Width of the icons
3030
ICON_HEIGHT = 26 # Height of the icons
31+
# Calculate the gap between icons
32+
gap_between_icons = 5
3133

3234
GAP_BETWEEN_ICONS = 15 # Gap between the icons
3335
NUMBER_OF_ICONS = 2 # Number of icons to display
36+
PLACEHOLDER_ICON_PATH = "/airline_logos/placeholder.bmp"
3437

35-
# --- Drawing Properties ---
38+
# --- Text Properties ---
3639
TEXT_START_X = ICON_WIDTH + 4
37-
38-
# Function to scroll the icons
3940
TEXT_RESET_X = 170
40-
4141
FONT = terminalio.FONT
4242
TEXT_COLOR = 0x22FF00 # e.g., Green
4343

44-
# Initialize text labels list
45-
46-
4744
# Initialize the main display group
4845
main_group = Group()
4946

5047
# Initialize the icon group (this remains static on the display)
5148
static_icon_group = Group()
5249

53-
kbounding_box = {
54-
"min_latitude": 40.671859, # Southernmost latitude
55-
"max_latitude": 40.696278, # Northernmost latitude
56-
"min_longitude": -73.932734, # Westernmost longitude
57-
"max_longitude": -73.788054, # Easternmost longitude
58-
}
59-
6050
# Sample Bounding Box
6151
bounding_box = {
6252
"min_latitude": 40.633013, # Southernmost latitude
@@ -65,9 +55,8 @@
6555
"max_longitude": -104.046570, # Easternmost longitude
6656
}
6757

68-
6958
# --- Matrix setup ---
70-
BIT_DEPTH = 3
59+
BIT_DEPTH = 2
7160
matrix = rgbmatrix.RGBMatrix(
7261
width=DISPLAY_WIDTH,
7362
height=DISPLAY_HEIGHT,
@@ -117,13 +106,6 @@
117106
GAP_BETWEEN_ICONS * (NUMBER_OF_ICONS - 1)
118107
)
119108

120-
121-
def scroll_icons(icon_tile):
122-
icon_tile.x -= 1
123-
if icon_tile.x < -64: # Assuming each icon is 64 pixels wide
124-
icon_tile.x = 130 # Reset position to the rightmost
125-
126-
127109
# Function to scroll objects
128110
def scroll_text_labels(text_labels):
129111
for label in text_labels:
@@ -166,9 +148,8 @@ def fetch_flight_data():
166148
print(f"Request failed with status code {response.status_code}")
167149
if response.content:
168150
print(f"Response content: {response.content}")
169-
return [] # Return an empty list if the request failed
151+
return []
170152

171-
172153
def process_flight_data(json_data):
173154
# Initialize an empty list to hold processed flight data
174155
processed_flights = []
@@ -230,27 +211,26 @@ def create_text_labels(flight_data, Ypositions):
230211
local_text_labels.append(text_label)
231212
return local_text_labels
232213

233-
# pylint: disable=consider-using-with
214+
215+
234216
def create_icon_tilegrid(ident):
235217
airline_code = ident[:3].upper() # Use the first three characters of 'ident'
236218
icon_path = f"/airline_logos/{airline_code}.bmp"
219+
237220
try:
238-
icon_bitmap = OnDiskBitmap(open(icon_path, "rb"))
221+
# pylint: disable=consider-using-with
222+
file = open(icon_path, "rb")
223+
icon_bitmap = OnDiskBitmap(file)
239224
except OSError:
240225
print(f"Icon for {airline_code} not found. Using placeholder.")
241-
icon_path = "/airline_logos/placeholder.bmp" # Path to the placeholder image
242-
icon_bitmap = OnDiskBitmap(open(icon_path, "rb")) # Open the placeholder image
226+
# pylint: disable=consider-using-with
227+
file = open(PLACEHOLDER_ICON_PATH, "rb")
228+
icon_bitmap = OnDiskBitmap(file)
243229

244-
icon_tilegrid = TileGrid(
245-
icon_bitmap, pixel_shader=icon_bitmap.pixel_shader, x=0, y=0
246-
)
230+
icon_tilegrid = TileGrid(icon_bitmap, pixel_shader=icon_bitmap.pixel_shader, x=0, y=0)
247231
return icon_tilegrid
248232

249233

250-
251-
# Calculate the gap between icons
252-
gap_between_icons = 5
253-
254234
def update_display_with_flight_data(flight_data, icon_group, display_group):
255235
# Clear previous display items
256236
while len(display_group):
@@ -263,9 +243,6 @@ def update_display_with_flight_data(flight_data, icon_group, display_group):
263243
# Limit flight data to the adjusted number of icons
264244
flight_data = flight_data[:NUMBER_OF_ICONS]
265245

266-
267-
268-
269246
# Calculate the y position for each icon
270247
y_positions = [
271248
gap_between_icons + (ICON_HEIGHT + gap_between_icons) * i
@@ -299,6 +276,7 @@ def update_display_with_flight_data(flight_data, icon_group, display_group):
299276
return text_labels
300277

301278

279+
302280
def display_no_flights():
303281
# Clear the previous group content
304282
while len(main_group):

0 commit comments

Comments
 (0)