# Delay for scrolling the text SCROLL_DELAY = 0.03 FONT = "/IBMPlexMono-Medium-24_jep.bdf" # Learn guide count (ID = 0) matrixportal.add_text( text_font=FONT, text_position=( (matrixportal.graphics.display.width // 12) - 1, (matrixportal.graphics.display.height // 2) - 4, ), text_color=0x800000, ) matrixportal.preload_font("0123456789") # Learn guide title (ID = 1) matrixportal.add_text( text_font=terminalio.FONT, text_position=(2, 25), text_color=0x000080, scrolling=True, ) def get_guide_info(index): """Parses JSON data returned by the DATA_SOURCE to obtain the ALS guide title and number of guides and sets the text labels. :param int index: Guide index to display
# the current working directory (where this file is) cwd = ("/" + __file__).rsplit("/", 1)[0] matrixportal = MatrixPortal( url=DATA_SOURCE, json_path=DATA_LOCATION, status_neopixel=board.NEOPIXEL, default_bg=cwd + "/bitcoin_background.bmp", debug=False, ) matrixportal.add_text( text_font=terminalio.FONT, text_position=(27, 16), text_color=0x3d1f5c, text_transform=text_transform, ) matrixportal.preload_font(b"$012345789") # preload numbers matrixportal.preload_font((0x00A3, 0x20AC)) # preload gbp/euro symbol while True: try: value = matrixportal.fetch() print("Response is", value) except (ValueError, RuntimeError) as e: print("Some error occured, retrying! -", e) time.sleep(3 * 60) # wait 3 minutes
status_neopixel=board.NEOPIXEL, debug=False, ) matrixportal.add_text( text_font=terminalio.FONT, text_position=(0, 5), text_color=0xAF1F5C, ) matrixportal.add_text( text_font=terminalio.FONT, text_position=(22, 16), text_color=0x3D1F5C, ) matrixportal.preload_font(b"$012345789") # preload numbers matrixportal.preload_font(b"ABCDEFGHIJKLMNOPQRSTUVWXYZ") while True: try: matrixportal.set_text(TICKER, 0) newdata = matrixportal.network.fetch(DATA_SOURCE) current_price = matrixportal.network.json_traverse( newdata.json(), DATA_LOCATION) matrixportal.set_text("$" + current_price, 1) except (ValueError, RuntimeError) as e: print("Some error occured, retrying! -", e) time.sleep(3 * 60)
) matrixportal.set_text("Connecting", 1) matrixportal.network.connect() matrixportal.set_text("Get time", 1) # matrixportal.get_local_time() refresh_data() last_time_refresh = time.time() epoch = 1584576000 #march 19, 2020 00:00 UTC seconds_per_day = 24 * 60 * 60 days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] matrixportal.preload_font(b"012345789Quarantinedy") # preload numbers try: while True: t = time.time() dt = time.localtime(t) hour = dt.tm_hour if hour == 0: hour = 12 elif hour > 12: hour -= 12 first_line = f"{hour:02}:{(dt.tm_min):02}" day_of_week = days[dt.tm_wday] date = "" data_selector = t % 90 if data_selector >= 60: day = (t - epoch) // seconds_per_day date = f"QD {day}" elif data_selector >= 30: