The question is, will it run on a pi?

This commit is contained in:
Remy Moll
2020-10-17 16:24:07 +02:00
parent 7e3893716d
commit 341b2b6ece
7 changed files with 86 additions and 436 deletions

View File

@@ -91,21 +91,4 @@ class UnicornHat(object):
def off(self):
print("Closing window")
#pygame.quit()
"""
# SD hats works as expected
#unicornhat = UnicornHatSim(8,8)
#unicornphat = UnicornHatSim(8, 4)
# Unicornhat HD seems to be the other way around (not that there's anything wrong with that), so we rotate it 180°
# unicornhathd = UnicornHatSim(16, 16, 180)
"""
# twohats = UnicornHat(32, 16)
#
# for i in range(16):
# twohats.set_pixel(i,i, 200,200,200)
# twohats.show()
# time.sleep(1)
pygame.quit()

View File

@@ -14,7 +14,7 @@ import persistence.rw
class ClockFace(object):
"""Actual functions one might need for a clock"""
def __init__(self, text_speed=10):
def __init__(self, text_speed=12):
self.IO = led.OutputHandler(32,16)
self.tspeed = text_speed
@@ -24,6 +24,8 @@ class ClockFace(object):
# Threads to execute next
self.weather = ""
self.brightness_overwrite = {"value" : 1, "duration" : 0}
def run(self, command, kw=()):
"""Checks for running threads and executes the ones in queue"""
@@ -44,9 +46,11 @@ class ClockFace(object):
self.output_queue.append([command,kw])
############################################################################
### basic clock commands
def set_face(self, weather):
""""""
self.set_brightness()
self.weather = weather
self.run(self.IO.clock_face,(weather,))
@@ -56,9 +60,25 @@ class ClockFace(object):
self.run(self.IO.text_scroll,(text, self.tspeed, color))
def set_brightness(self, overwrite=[]):
"""Checks, what brightness rules to apply"""
if len(overwrite) != 0:
self.brightness_overwrite = overwrite
is_WE = datetime.datetime.now().weekday() > 4
now = int(datetime.datetime.now().strftime("%H%M"))
if (is_WE and (now > 1000 and now < 2200)) or ((not is_WE) and (now > 800 and now < 2130)):
brightness = 0.8
else:
brightness = 0.1
self.IO.output.set_brightness(brightness)
############################################################################
### Higher level commands, accessible from the chat-bot
def wake_light(self, duration=600):
"""Duration in seconds"""
"""Simulates a sunris, takes one optional parameter: the duration"""
def output(duration):
start_color = numpy.array([153, 0, 51])
end_color = numpy.array([255, 255, 0])
@@ -78,7 +98,7 @@ class ClockFace(object):
def alarm_blink(self, duration, frequency):
"""Duration in seconds, frequency in Hertz"""
"""Blinks the whole screen (red-black). Duration in seconds, frequency in Hertz"""
def output(duration, frequency):
duration = int(duration)
frequency = int(frequency)
@@ -95,10 +115,15 @@ class ClockFace(object):
self.run(output,(duration, frequency))
def image_show(self, image, duratation):
def image_show(self, image, duration):
"""Shows a 16x32 image for duration seconds"""
def output(image, duratation):
def output(image, duration):
self.IO.set_matrix_rgb(red)
self.run(output,(image, duration))
def show_message(self, message):
"""Runs a text message over the screen. Obviously needs the text"""
# keep in mind, message is a list of all input, separated by a space
message_str = " ".join(message)
self.text_scroll(message_str)