Skip to content

Commit aa16b66

Browse files
authored
Corrections by author
1 parent e4e38d2 commit aa16b66

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

QT_Py_Cube/code.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# SPDX-FileCopyrightText: 2022 Charlyn Gonda for Adafruit Industries
22
#
33
# SPDX-License-Identifier: MIT
4+
from secrets import secrets
5+
import ssl
46
import busio
57
import board
68
import adafruit_lis3dh
79
import wifi
8-
import ssl
910
import socketpool
1011
import adafruit_requests
1112

@@ -14,7 +15,6 @@
1415
from adafruit_io.adafruit_io import IO_HTTP
1516

1617
from cube import Cube
17-
from secrets import secrets
1818

1919
# Specify pins
2020
top_cin = board.A0
@@ -74,6 +74,7 @@
7474

7575

7676
def update_data():
77+
# pylint: disable=global-statement
7778
global CUBE_WORD, TOP_PIXELS_ON, TOP_PIXELS_COLOR
7879
if connected:
7980
print("Updating data from Adafruit IO")
@@ -88,8 +89,8 @@ def update_data():
8889
TOP_PIXELS_ON = pixels_list.split(",")
8990
TOP_PIXELS_COLOR = TOP_PIXELS_COLOR_MAP[color]
9091
# pylint: disable=broad-except
91-
except Exception as error:
92-
print(error)
92+
except Exception as update_error:
93+
print(update_error)
9394

9495

9596
orientations = [
@@ -101,30 +102,31 @@ def update_data():
101102
"BACK"
102103
]
103104

105+
# pylint: disable=inconsistent-return-statements
104106

105-
def orientation(x, y, z):
106-
absX = abs(x)
107-
absY = abs(y)
108-
absZ = abs(z)
107+
108+
def orientation(curr_x, curr_y, curr_z):
109+
absX = abs(curr_x)
110+
absY = abs(curr_y)
111+
absZ = abs(curr_z)
109112

110113
if absX > absY and absX > absZ:
111114
if x >= 0:
112115
return orientations[1] # up
113-
else:
114-
return orientations[0] # down
116+
117+
return orientations[0] # down
115118

116119
if absZ > absY and absZ > absX: # when "down" is "up"
117120
if z >= 0:
118121
return orientations[2] # left
119-
else:
120-
return orientations[3] # right
121-
return orientations[2]
122+
123+
return orientations[3] # right
122124

123125
if absY > absX and absY > absZ:
124126
if y >= 0:
125127
return orientations[4] # front
126-
else:
127-
return orientations[5] # back
128+
129+
return orientations[5] # back
128130

129131

130132
upside_down = False

QT_Py_Cube/cube.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from adafruit_pixel_framebuf import PixelFramebuffer
1010

1111

12-
class Cube(object):
12+
class Cube():
1313
def __init__(
1414
self,
1515
top_cin,
@@ -70,7 +70,7 @@ def __init__(
7070
# scrolling word state vars
7171
self.last_color_time = -1
7272
self.color_wait = 1
73-
self.current_scroll_word = ''
73+
self.word = ''
7474
self.total_scroll_len = 0
7575
self.scroll_x_pos = -self.pixel_width
7676
self.color_idx = 0
@@ -110,15 +110,15 @@ def scroll_word_and_update_top(self):
110110
self.__display_top_pixels()
111111
self.scroll_x_pos = self.scroll_x_pos + 1
112112

113-
def clear_cube(self, clearTop=False):
113+
def clear_cube(self, clear_top=False):
114114
if not self.clear:
115115
self.pixel_framebuf_sides.fill(0)
116116
self.pixel_framebuf_sides.display()
117117
self.side_pixels.fill(0)
118118
self.side_pixels.show()
119119
self.pixel_framebuf_bottom.fill(0)
120120
self.pixel_framebuf_bottom.display()
121-
if (clearTop):
121+
if clear_top:
122122
self.pixel_framebuf_top.fill(0)
123123
self.pixel_framebuf_top.display()
124124
self.clear = True
@@ -180,5 +180,6 @@ def __next_color(self):
180180

181181
return result
182182

183-
def __convert_to_hex(self, color):
183+
@staticmethod
184+
def __convert_to_hex(color):
184185
return int('0x%02x%02x%02x' % color, 16)

0 commit comments

Comments
 (0)