import time
from neopixel import Neopixel
from machine import Pin, SoftI2C, RTC
import tm1637
import ds1307
pixels = Neopixel(61, 0, 6, "GRB")
colors = [
(0xb6, 0xe4, 0x30),
(0x42, 0xd1, 0xe0),
]
# full test code
i2c0 = SoftI2C(scl=Pin(1), sda=Pin(0), freq=100000)
ds1307rtc = ds1307.DS1307(i2c0, 0x68)
mydisplay = tm1637.TM1637(clk=Pin(26), dio=Pin(27))
pixel_index = 0
color_index = 0
while True:
dt = ds1307rtc.datetime
hours = dt[3]
minutes = dt[4]
seconds = dt[5]
if (seconds%2 == 0):
mydisplay.numbers(hours, minutes)
else:
mydisplay.number(hours * 100 + minutes)
hourhandpos = (hours * 5 + minutes / 12) % 60
pixels.set_pixel(int(hourhandpos), (255, 0, 0))
pixels.set_pixel(minutes, (0, 255, 0))
pixels.set_pixel(seconds, (0, 0, 255))
pixels.show()
for i in range(60):
pixels.set_pixel(i, (0, 0, 0))
time.sleep(1)