Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
Getting time for timezone America/New_York
Traceback (most recent call last):
File "code.py", line 51, in <module>
File "adafruit_matrixportal/network.py", line 198, in get_local_time
File "adafruit_matrixportal/network.py", line 180, in get_local_time
File "adafruit_requests.py", line 291, in get
File "adafruit_requests.py", line 250, in request
File "adafruit_esp32spi/adafruit_esp32spi_socket.py", line 204, in close
File "adafruit_esp32spi/adafruit_esp32spi.py", line 769, in socket_close
File "adafruit_esp32spi/adafruit_esp32spi.py", line 323, in _send_command_get_response
File "adafruit_esp32spi/adafruit_esp32spi.py", line 306, in _wait_response_cmd
File "adafruit_esp32spi/adafruit_esp32spi.py", line 290, in _wait_response_cmd
File "adafruit_esp32spi/adafruit_esp32spi.py", line 266, in _wait_spi_char
RuntimeError: Error response to command
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
import time
import displayio
import rgbmatrix
import board
import framebufferio
from secrets import secrets
from adafruit_matrixportal.matrix import Matrix
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text import label
from rtc import RTC
from adafruit_matrixportal.network import Network
network = Network(status_neopixel=board.NEOPIXEL, debug=False)
displayio.release_displays()
matrix = rgbmatrix.RGBMatrix(
width=64, bit_depth=4,
rgb_pins=[
board.MTX_R1,
board.MTX_G1,
board.MTX_B1,
board.MTX_R2,
board.MTX_G2,
board.MTX_B2
],
addr_pins=[
board.MTX_ADDRA,
board.MTX_ADDRB,
board.MTX_ADDRC,
board.MTX_ADDRD
],
clock_pin=board.MTX_CLK,
latch_pin=board.MTX_LAT,
output_enable_pin=board.MTX_OE
)
display = framebufferio.FramebufferDisplay(matrix)
type_face = bitmap_font.load_font('/fonts/helvR10.bdf')
left_side_Text = 3
top_y = 6
middle_y = 16
bottom_y = 26
hour_Names = ["midnight","one","two","three","four","five","six","seven","eight","nine","ten","eleven","noon"]
min_Names = ["just","just","just","five","five","five","five","five","ten","ten","ten","ten","ten","quarter","quarter","quarter","quarter","quarter","twenty","twenty","twenty","twenty","twenty","twenty five","twenty five","twenty five","twenty five","twenty five","half","half","half"]
min_modifier_Names = ["about","after","past","to"]
while True:
network.get_local_time()
datetime=time.localtime()
print(datetime)
current_Hour = datetime.tm_hour
current_Min = datetime.tm_min
if current_Min > 30:
current_Hour = current_Hour + 1
if current_Hour>12:
current_Hour = current_Hour - 12
current_hour_Name = hour_Names[current_Hour]
if current_Min > 30:
current_min_Name = min_Names[30-(current_Min-30)] #so if it's 33 after, 30-(33-30) = 27 - X minutes after the hour matches back to X minutes before the hour and uses the same term
current_min_Modifier = min_modifier_Names[3]
else:
current_min_Name = min_Names[current_Min]
if current_Min < 3:
current_min_Modifier = min_modifier_Names[0]
elif current_Min < 28:
current_min_Modifier = min_modifier_Names[1]
elif current_Min < 58:
current_min_Modifier = min_modifier_Names[2]
else:
current_min_Modifier = min_modifier_Names[0]
top_line_Text = label.Label(type_face,color=0x022681,text=current_min_Name)
top_line_Text.x = left_side_Text
top_line_Text.y = top_y
middle_line_Text = label.Label(type_face,color=0x081677,text=current_min_Modifier)
middle_line_Text.x = left_side_Text
middle_line_Text.y = middle_y
bottom_line_Text = label.Label(type_face,color=0x021518,text=current_hour_Name)
bottom_line_Text.x = left_side_Text
bottom_line_Text.y = bottom_y
text_Group = displayio.Group()
text_Group.append(top_line_Text)
text_Group.append(middle_line_Text)
text_Group.append(bottom_line_Text)
display.show(text_Group)
time.sleep(60)
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock
Re: Adabox016 - "close enough" clock