Better folder structure, added a few ambient sensors
This commit is contained in:
@@ -1 +1 @@
|
||||
from . import helper
|
||||
from . import helper, timer
|
@@ -3,46 +3,12 @@ import numpy as np
|
||||
import datetime
|
||||
import time
|
||||
|
||||
|
||||
####### bulky hard-coded values:
|
||||
digits = {
|
||||
"1" : [[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1]],
|
||||
"2" : [[1,1,1],[0,0,1],[1,1,1],[1,0,0],[1,1,1]],
|
||||
"3" : [[1,1,1],[0,0,1],[1,1,1],[0,0,1],[1,1,1]],
|
||||
"4" : [[1,0,1],[1,0,1],[1,1,1],[0,0,1],[0,0,1]],
|
||||
"5" : [[1,1,1],[1,0,0],[1,1,1],[0,0,1],[1,1,1]],
|
||||
"6" : [[1,1,1],[1,0,0],[1,1,1],[1,0,1],[1,1,1]],
|
||||
"7" : [[1,1,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1]],
|
||||
"8" : [[1,1,1],[1,0,1],[1,1,1],[1,0,1],[1,1,1]],
|
||||
"9" : [[1,1,1],[1,0,1],[1,1,1],[0,0,1],[1,1,1]],
|
||||
"0" : [[1,1,1],[1,0,1],[1,0,1],[1,0,1],[1,1,1]],
|
||||
"-" : [[0,0,0],[0,0,0],[1,1,1],[0,0,0],[0,0,0]],
|
||||
"-1" : [[0,0,1],[0,0,1],[1,1,1],[0,0,1],[0,0,1]],
|
||||
"error" : [[1,0,1],[1,0,1],[0,1,0],[1,0,1],[1,0,1]],
|
||||
} # these are 2-d arrays as we only work with one or 2 colors, and not the whole rgb spectrum
|
||||
|
||||
##place of numbers, invariant (for the given shape of 16x32)
|
||||
# bulky hard-coded values:
|
||||
from . import shapes
|
||||
digits = shapes.digits
|
||||
weather_categories = shapes.weather_categories
|
||||
digit_position = [[2,4], [2,10], [9,4], [9,10]]
|
||||
|
||||
weather_categories = {
|
||||
"Clouds": "cloud",
|
||||
"Rain": "rain and cloud",
|
||||
"Thunderstorm": "thunder and cloud",
|
||||
"Drizzle": "rain and cloud",
|
||||
"Snow": "snow and cloud",
|
||||
"Clear": "sun",
|
||||
"Mist": "fog and clouds",
|
||||
"Smoke": "Smoke",
|
||||
"Haze": "Haze",
|
||||
"Dust": "Dust",
|
||||
"Fog": "fog",
|
||||
"Sand": "Sand",
|
||||
"Dust": "Dust",
|
||||
"Ash": "Ash",
|
||||
"Squal": "Squal",
|
||||
"Tornado": "Tornado",
|
||||
"error" : "moon"
|
||||
}
|
||||
|
||||
days = np.append(np.zeros((15,16)), np.array([0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,1])).reshape((16,16))
|
||||
|
||||
|
103
clock/helpers/shapes.py
Normal file
103
clock/helpers/shapes.py
Normal file
@@ -0,0 +1,103 @@
|
||||
import numpy as np
|
||||
|
||||
digits = {
|
||||
"1" : np.array([
|
||||
[0,0,1],
|
||||
[0,0,1],
|
||||
[0,0,1],
|
||||
[0,0,1],
|
||||
[0,0,1]]),
|
||||
"2" : np.array([
|
||||
[1,1,1],
|
||||
[0,0,1],
|
||||
[1,1,1],
|
||||
[1,0,0],
|
||||
[1,1,1]]),
|
||||
"3" : np.array([
|
||||
[1,1,1],
|
||||
[0,0,1],
|
||||
[1,1,1],
|
||||
[0,0,1],
|
||||
[1,1,1]]),
|
||||
"4" : np.array([
|
||||
[1,0,1],
|
||||
[1,0,1],
|
||||
[1,1,1],
|
||||
[0,0,1],
|
||||
[0,0,1]]),
|
||||
"5" : np.array([
|
||||
[1,1,1],
|
||||
[1,0,0],
|
||||
[1,1,1],
|
||||
[0,0,1],
|
||||
[1,1,1]]),
|
||||
"6" : np.array([
|
||||
[1,1,1],
|
||||
[1,0,0],
|
||||
[1,1,1],
|
||||
[1,0,1],
|
||||
[1,1,1]]),
|
||||
"7" : np.array([
|
||||
[1,1,1],
|
||||
[0,0,1],
|
||||
[0,0,1],
|
||||
[0,0,1],
|
||||
[0,0,1]]),
|
||||
"8" : np.array([
|
||||
[1,1,1],
|
||||
[1,0,1],
|
||||
[1,1,1],
|
||||
[1,0,1],
|
||||
[1,1,1]]),
|
||||
"9" : np.array([
|
||||
[1,1,1],
|
||||
[1,0,1],
|
||||
[1,1,1],
|
||||
[0,0,1],
|
||||
[1,1,1]]),
|
||||
"0" : np.array([
|
||||
[1,1,1],
|
||||
[1,0,1],
|
||||
[1,0,1],
|
||||
[1,0,1],
|
||||
[1,1,1]]),
|
||||
"-" : np.array([
|
||||
[0,0,0],
|
||||
[0,0,0],
|
||||
[1,1,1],
|
||||
[0,0,0],
|
||||
[0,0,0]]),
|
||||
"-1" : np.array([
|
||||
[0,0,1],
|
||||
[0,0,1],
|
||||
[1,1,1],
|
||||
[0,0,1],
|
||||
[0,0,1]]),
|
||||
"error" : np.array([
|
||||
[1,0,1],
|
||||
[1,0,1],
|
||||
[0,1,0],
|
||||
[1,0,1],
|
||||
[1,0,1]]),
|
||||
}
|
||||
|
||||
|
||||
weather_categories = {
|
||||
"Clouds": "cloud",
|
||||
"Rain": "rain and cloud",
|
||||
"Thunderstorm": "thunder and cloud",
|
||||
"Drizzle": "rain and cloud",
|
||||
"Snow": "snow and cloud",
|
||||
"Clear": "sun",
|
||||
"Mist": "fog and clouds",
|
||||
"Smoke": "Smoke",
|
||||
"Haze": "Haze",
|
||||
"Dust": "Dust",
|
||||
"Fog": "fog",
|
||||
"Sand": "Sand",
|
||||
"Dust": "Dust",
|
||||
"Ash": "Ash",
|
||||
"Squal": "Squal",
|
||||
"Tornado": "Tornado",
|
||||
"error" : "moon"
|
||||
}
|
29
clock/helpers/timer.py
Normal file
29
clock/helpers/timer.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from threading import Timer
|
||||
import time
|
||||
|
||||
class RepeatedTimer(object):
|
||||
def __init__(self, interval, function, *args, **kwargs):
|
||||
self._timer = None
|
||||
self.interval = interval
|
||||
self.function = function
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
self.is_running = False
|
||||
self.next_call = time.time()
|
||||
self.start()
|
||||
|
||||
def _run(self):
|
||||
self.is_running = False
|
||||
self.start()
|
||||
self.function(*self.args, **self.kwargs)
|
||||
|
||||
def start(self):
|
||||
if not self.is_running:
|
||||
self.next_call += self.interval
|
||||
self._timer = Timer(self.next_call - time.time(), self._run)
|
||||
self._timer.start()
|
||||
self.is_running = True
|
||||
|
||||
def stop(self):
|
||||
self._timer.cancel()
|
||||
self.is_running = False
|
Reference in New Issue
Block a user