VSCALE = 2 # pixels per ft or m DAILY_UPDATE_HOUR = 3 # 24 hour format # ------------------------------------------- # don't change these PLOT_WIDTH = 116 PLOT_HEIGHT = 116 PLOT_X = 174 PLOT_Y = 6 PLOT_Y_SCALE = round(PLOT_HEIGHT / (4 * VSCALE)) DATE_FONT = bitmap_font.load_font("/fonts/Kanit-Black-24.bdf") TIME_FONT = bitmap_font.load_font("/fonts/Kanit-Medium-20.bdf") # our MagTag magtag = MagTag() magtag.json_path = ["predictions"] # ---------------------------- # Grid overlay for plot # ---------------------------- grid_bmp, grid_pal = adafruit_imageload.load("/bmps/tides_bg_land.bmp") grid_pal.make_transparent(1) grid_overlay = displayio.TileGrid(grid_bmp, pixel_shader=grid_pal) # ---------------------------- # Tide plot (bitmap, palette, tilegrid) # ---------------------------- tide_plot = displayio.Bitmap(PLOT_WIDTH, PLOT_HEIGHT, 4) tide_pal = displayio.Palette(4) tide_pal[0] = 0x000000 # black
text_position=( (magtag.graphics.display.width // 2), (magtag.graphics.display.height // 2) - 10, ), line_spacing=0.75, text_anchor_point=(0.5, 0.5), # center the text on x & y ) # author in italic text, no wrapping magtag.add_text( text_font="/fonts/Arial-Italic-12.bdf", text_position=(20, 118), text_anchor_point=(0.0, 0.5), # left justify this line ) timestamp = None while True: if not timestamp or (time.monotonic() - timestamp) > 60: # new one each minute try: quote_num = (quote_num + 1) % 10 QUOTE_LOCATION = ["data", "children", quote_num, "data", "title"] AUTHOR_LOCATION = ["data", "children", quote_num, "data", "author"] magtag.json_path = (QUOTE_LOCATION, AUTHOR_LOCATION) value = magtag.fetch() print("Response is", value) except (ValueError, RuntimeError) as e: print("Some error occured, retrying! -", e) timestamp = time.monotonic() print(timestamp)