Skip to content
Snippets Groups Projects
Commit 131a7fc2 authored by Hinerk's avatar Hinerk
Browse files

review of analog clock app

  - remove Time Class since it is not used
  - remove unused variables from Clock class
parent 612772fa
No related branches found
No related tags found
1 merge request!284review of analog clock app
# Adapted from https://github.com/muccc/flipdots/blob/master/scripts/clock.py
import display
from utime import sleep
import utime
import math
import leds
......@@ -11,28 +10,6 @@ import os
CONFIG_NAME = "clock.json"
class Time:
def __init__(self, start=0):
self.time = start
self.wait_time = 0.95
def tick(self):
sleep(self.wait_time)
self.time += 1
@property
def second(self):
return self.time % 60
@property
def minute(self):
return (self.time / 60) % 60
@property
def hour(self):
return (self.time / 3600) % 24
class Clock:
def __init__(
self,
......@@ -45,22 +22,15 @@ class Clock:
second_hand=True,
console_out=False,
run_once=False,
update_interval=0,
):
self.sizex = sizex
self.sizey = sizey
self.radius = radius
self.center = (int(self.sizex / 2), int(self.sizey / 2))
self.center = (int(sizex / 2), int(sizey / 2))
self.hour_hand = hour_hand
self.minute_hand = minute_hand
self.second_hand = second_hand
self.console_out = console_out
self.update_interval = (
update_interval if update_interval != 0 else (1 if self.second_hand else 30)
)
self.run_once = run_once
self.offsetx = offsetx
self.time = Time()
self.theme = 0
self.default_themes = [
{
......@@ -178,7 +148,6 @@ class Clock:
)
def loop(self):
colored = False
try:
with display.open() as disp:
button_pressed = False
......@@ -275,6 +244,7 @@ class Clock:
for x in range(self.radius * 2):
line = line + (
"."
# TODO image is unknown! Dead Code
if image[(self.center[1] - self.radius) + y][
(self.center[0] - self.radius) + x
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment