Corrections by author

This commit is contained in:
Anne Barela 2022-09-06 08:53:54 -04:00 committed by GitHub
parent e4e38d2477
commit aa16b66a5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 20 deletions

View file

@ -1,11 +1,12 @@
# SPDX-FileCopyrightText: 2022 Charlyn Gonda for Adafruit Industries
#
# SPDX-License-Identifier: MIT
from secrets import secrets
import ssl
import busio
import board
import adafruit_lis3dh
import wifi
import ssl
import socketpool
import adafruit_requests
@ -14,7 +15,6 @@ from adafruit_led_animation.color import (
from adafruit_io.adafruit_io import IO_HTTP
from cube import Cube
from secrets import secrets
# Specify pins
top_cin = board.A0
@ -74,6 +74,7 @@ CUBE_WORD = "... ..."
def update_data():
# pylint: disable=global-statement
global CUBE_WORD, TOP_PIXELS_ON, TOP_PIXELS_COLOR
if connected:
print("Updating data from Adafruit IO")
@ -88,8 +89,8 @@ def update_data():
TOP_PIXELS_ON = pixels_list.split(",")
TOP_PIXELS_COLOR = TOP_PIXELS_COLOR_MAP[color]
# pylint: disable=broad-except
except Exception as error:
print(error)
except Exception as update_error:
print(update_error)
orientations = [
@ -101,29 +102,30 @@ orientations = [
"BACK"
]
# pylint: disable=inconsistent-return-statements
def orientation(x, y, z):
absX = abs(x)
absY = abs(y)
absZ = abs(z)
def orientation(curr_x, curr_y, curr_z):
absX = abs(curr_x)
absY = abs(curr_y)
absZ = abs(curr_z)
if absX > absY and absX > absZ:
if x >= 0:
return orientations[1] # up
else:
return orientations[0] # down
if absZ > absY and absZ > absX: # when "down" is "up"
if z >= 0:
return orientations[2] # left
else:
return orientations[3] # right
return orientations[2]
if absY > absX and absY > absZ:
if y >= 0:
return orientations[4] # front
else:
return orientations[5] # back

View file

@ -9,7 +9,7 @@ from adafruit_led_animation.color import AMBER, JADE, CYAN, GOLD, PINK
from adafruit_pixel_framebuf import PixelFramebuffer
class Cube(object):
class Cube():
def __init__(
self,
top_cin,
@ -70,7 +70,7 @@ class Cube(object):
# scrolling word state vars
self.last_color_time = -1
self.color_wait = 1
self.current_scroll_word = ''
self.word = ''
self.total_scroll_len = 0
self.scroll_x_pos = -self.pixel_width
self.color_idx = 0
@ -110,7 +110,7 @@ class Cube(object):
self.__display_top_pixels()
self.scroll_x_pos = self.scroll_x_pos + 1
def clear_cube(self, clearTop=False):
def clear_cube(self, clear_top=False):
if not self.clear:
self.pixel_framebuf_sides.fill(0)
self.pixel_framebuf_sides.display()
@ -118,7 +118,7 @@ class Cube(object):
self.side_pixels.show()
self.pixel_framebuf_bottom.fill(0)
self.pixel_framebuf_bottom.display()
if (clearTop):
if clear_top:
self.pixel_framebuf_top.fill(0)
self.pixel_framebuf_top.display()
self.clear = True
@ -180,5 +180,6 @@ class Cube(object):
return result
def __convert_to_hex(self, color):
@staticmethod
def __convert_to_hex(color):
return int('0x%02x%02x%02x' % color, 16)