def __init__(self, magtag: MagTag) -> None: self._magtag = magtag magtag.add_text( text_position=( 50, 10, ), text_scale=3, ) magtag.set_text("Spotlight")
def main(): magtag = MagTag(debug=True) current_screen = MainScreen(magtag) current_screen.init_screen() while True: current_screen.update()
import time import rtc from adafruit_display_shapes.rect import Rect from adafruit_magtag.magtag import MagTag # CONFIGURABLE SETTINGS and ONE-TIME INITIALIZATION ------------------------ JSON_URL = 'https://spreadsheets.google.com/feeds/cells/1vk6jE1-6CMV-hjDgBk-PuFLgG64YemyDoREhGrA6uGI/1/public/full?alt=json' TWELVE_HOUR = True # If set, show 12-hour vs 24-hour (e.g. 3:00 vs 15:00) DD_MM = False # If set, show DD/MM instead of MM/DD dates DAYS = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ] MAGTAG = MagTag(rotation=0) # Portrait (vertical) display MAGTAG.network.connect() # SOME UTILITY FUNCTIONS --------------------------------------------------- def hh_mm(time_struct, twelve_hour=True): """ Given a time.struct_time, return a string as H:MM or HH:MM, either 12- or 24-hour style depending on twelve_hour flag. """ if twelve_hour: if time_struct.tm_hour > 12: hour_string = str(time_struct.tm_hour - 12) # 13-23 -> 1-11 (pm) elif time_struct.tm_hour > 0: hour_string = str(time_struct.tm_hour) # 1-12 else:
# MagTag Quote Board # Displays Quotes from the Adafruit quotes server # Be sure to put WiFi access point info in secrets.py file to connect import time from adafruit_magtag.magtag import MagTag # Set up where we'll be fetching data from DATA_SOURCE = "https://www.adafruit.com/api/quotes.php" QUOTE_LOCATION = [0, "text"] AUTHOR_LOCATION = [0, "author"] # in seconds, we can refresh about 100 times on a battery TIME_BETWEEN_REFRESHES = 1 * 60 * 60 # one hour delay magtag = MagTag( url=DATA_SOURCE, json_path=(QUOTE_LOCATION, AUTHOR_LOCATION), ) magtag.graphics.set_background("/bmps/magtag_quotes_bg.bmp") # quote in bold text, with text wrapping magtag.add_text( text_font="/fonts/Arial-Bold-12.bdf", text_wrap=28, text_maxlen=120, 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
elif hour > 12: timestring = "%d:%02d pm" % (hour - 12, min) else: timestring = "%d:%02d am" % (hour, min) return "%s %d, at %s" % (months[month - 1], day, timestring) def details_transform(val3): if val3 == None or not len(val3): return "Details: To Be Determined" return "Details: " + val3[0:166] + "..." # Set up the MagTag with the JSON data parameters magtag = MagTag(url=DATA_SOURCE, json_path=(NAME_LOCATION, DATE_LOCATION, DETAIL_LOCATION)) magtag.add_text(text_font="/fonts/Lato-Bold-ltd-25.bdf", text_position=(10, 15), is_data=False) # Display heading text below with formatting above magtag.set_text("Next SpaceX Launch") # Formatting for the mission text magtag.add_text(text_font="/fonts/Arial-Bold-12.pcf", text_position=(10, 38), text_transform=mission_transform) # Formatting for the launch time text magtag.add_text(text_font="/fonts/Arial-12.bdf", text_position=(10, 60),
# SPDX-License-Identifier: Unlicense import time import random import terminalio import json from adafruit_magtag.magtag import MagTag SHOW_INTRO = False # Whether to show the digikey logo + intro text PLAY_SONG = False # shhhh! DEFAULT_SIGN = None # Set to None to pick, or "Scorpio" (etc) to skip SHOW_SIGN_IMAGE = True # skip showing the name of the sign/graphic PLAINFONT = False # Use built in font if True # if we have wifi, we'll get a horoscope online! DATA_SOURCE = "https://aztro.sameerkumar.website/?day=today&sign=" magtag = MagTag() # lights up fast magtag.peripherals.neopixels.brightness = 0.1 magtag.peripherals.neopixel_disable = False # turn on lights if SHOW_INTRO: magtag.set_background("digikey.bmp") magtag.peripherals.neopixels.fill(0x800000) # red! magtag.refresh() print("Thank you Digi-Key!") signs = (("Aquarius", (0, 0, 255)), # blue ("Pisces", (144, 240, 144)), # light green ("Aries", (255, 0, 0)), # red ("Taurus", (0, 255, 0)), # green ("Gemini", (128, 128, 0)), # yellow
import time import board import busio import terminalio from adafruit_magtag.magtag import MagTag from adafruit_scd30 import SCD30 from adafruit_tsl2591 import TSL2591 try: from secrets import secrets except ImportError: raise ImportError( "Please add your Adafruit IO and WiFi secrets into secrets.py. Exiting." ) device = MagTag() scd = SCD30(board.I2C()) tsl = TSL2591(board.I2C()) # We'll connect this MagTag to the internet if we need to use Adafruit IO connectivity. # device.network.connect() device.add_text( text_font=terminalio.FONT, text_position=( 10, (device.graphics.display.height // 2) - 1, ), text_scale=1, )
# SPDX-FileCopyrightText: 2020 Tim C, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense import wifi import ssl import socketpool import adafruit_requests from adafruit_progressbar import ProgressBar from adafruit_magtag.magtag import MagTag magtag = MagTag() # Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and # "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other # source control. # pylint: disable=no-name-in-module,wrong-import-order try: from secrets import secrets except ImportError: print( "Credentials and tokens are kept in secrets.py, please add them there!" ) raise # Get our username, key and desired timezone aio_username = secrets["aio_username"] aio_key = secrets["aio_key"] location = secrets.get("timezone", None) TIME_URL = ( "https://io.adafruit.com/api/v2/%s/integrations/time/strftime?x-aio-key=%s"
import json import terminalio from adafruit_magtag.magtag import MagTag magtag = MagTag() magtag.peripherals.neopixel_disable = True # turn off lights magtag.set_background("bmps\magtag_bible.bmp") verses = json.loads(open("verses.json").read()) # main text, index 0 magtag.add_text( text_font = terminalio.FONT if PLAINFONT else "Arial-Bold-24.bdf", text_position=( magtag.graphics.display.width // 2, 10, ), text_scale = 3 if PLAINFONT else 1, line_spacing=1, text_anchor_point=(0.5, 0), ) # verse text, index 1 magtag.add_text( text_font= terminalio.FONT if PLAINFONT else "Arial-12.bdf", text_position=(10, 10), line_spacing=1.0, text_wrap=35, text_maxlen=130, text_anchor_point=(0, 0),
import time import terminalio from adafruit_magtag.magtag import MagTag from secrets import secrets DATA_SOURCE = 'https://api.openweathermap.org/data/2.5/weather?zip=52601,us&units=imperial&appid=' + \ secrets['open_weather_key'] magtag = MagTag(url=DATA_SOURCE, json_path=(["name"], ["main", "temp"], ["main", "temp_max"], ["main", "temp_min"], ["weather", 0, "main"], ["wind", "speed"])) magtag.add_text(text_position=(5, 10), text_scale=2, is_data=False) magtag.get_local_time() now = time.localtime() magtag.set_text("{}/{}/{} {}:{}".format(*now)) magtag.add_text(text_position=(5, 30), text_scale=2) magtag.add_text(text_position=(10, 50), text_transform=lambda x: "Current: {}F".format(x), text_scale=2) magtag.add_text(text_position=(10, 75), text_transform=lambda x: "Max: {}F".format(x), text_scale=2) magtag.add_text(text_position=(120, 75), text_transform=lambda x: "Min: {}F".format(x),
timestring = "%d:%02d" % (hour, min) elif hour > 12: timestring = "%d:%02d pm" % (hour-12, min) else: timestring = "%d:%02d am" % (hour, min) return "%s %d, %d, at %s" % (months[month-1], day, year, timestring) def Humidity_transform(val2): if val2 == None: return "Details: To Be Determined" return "Humidity: " + str(val2) # Set up the MagTag with the JSON data parameters magtag = MagTag( url=DATA_SOURCE, json_path=(reading_time, reading_Temperature, reading_Humidity) ) magtag.add_text( text_font="/fonts/Lato-Bold-ltd-25.bdf", text_position=(10, 15), is_data=False ) # Display heading text below with formatting above magtag.set_text("5th Wheel") # Formatting for the Time text magtag.add_text( text_font="/fonts/Arial-Bold-12.pcf", text_position=(10, 38), text_transform=time_transform
""" from adafruit_magtag.magtag import MagTag from adafruit_progressbar.progressbar import ProgressBar import rtc def days_in_year(date_obj): # check for leap year if (date_obj.tm_year % 100 != 0 or date_obj.tm_year % 400 == 0) and date_obj.tm_year % 4 == 0: return 366 return 365 magtag = MagTag() magtag.network.connect() magtag.add_text( text_font="/fonts/epilogue18.bdf", text_position=( (magtag.graphics.display.width // 2) - 1, 24, ), text_anchor_point=(0.5, 0.5), is_data=False, ) magtag.set_text("Year Progress:", auto_refresh=False) magtag.add_text( text_font="/fonts/epilogue18.bdf",
# # SPDX-License-Identifier: Unlicense import time import board from adafruit_magtag.magtag import MagTag import neopixel external_pixels = neopixel.NeoPixel(board.D10, 30, brightness=0.3) # Set up where we'll be fetching data from DATA_SOURCE = "http://api.thingspeak.com/channels/1417/field/2/last.json" COLOR_LOCATION = ['field2'] DATE_LOCATION = ['created_at'] magtag = MagTag( url=DATA_SOURCE, json_path=(COLOR_LOCATION, DATE_LOCATION), ) magtag.network.connect() # Color magtag.add_text( text_font="Arial-Bold-12.bdf", text_position=(10, 15), text_transform=lambda x: "New Color {}".format(x), ) # datestamp magtag.add_text( text_font="Arial-Bold-12.bdf", text_position=(10, 35), text_transform=lambda x: "Updated on: {}".format(x), )
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense import time import random import alarm import terminalio from adafruit_magtag.magtag import MagTag # Set up where we'll be fetching data from DATA_SOURCE = ( "https://raw.githubusercontent.com/codyogden/killedbygoogle/main/graveyard.json" ) # Get the MagTag ready MAGTAG = MagTag() MAGTAG.peripherals.neopixel_disable = True MAGTAG.set_background("/bmps/background.bmp") MAGTAG.network.connect() # Prepare the three text fields MAGTAG.add_text( text_font="/fonts/Deutsch-Gothic-14.bdf", text_position=( 55, 60, ), text_wrap=14, text_anchor_point=(0.5, 0.5), text_scale=1, line_spacing=0.9,
DAILY_UPDATE_HOUR = 11 # https://open-iowa.opendata.arcgis.com/datasets/iacovid19-demographics HOSPITAL_DATA = 'https://services.arcgis.com/vPD5PVLI6sfkZ5E4/arcgis/rest/services/IACOVID19Cases_Demographics' \ '/FeatureServer/0/query?where=1=1&outFields=CurrHospitalized,Deceased,' \ 'last_updated&returnGeometry=false&outSR=4326&f=json' # https://open-iowa.opendata.arcgis.com/datasets/ia-covid19-cases DM_COUNTY_DATA = 'https://services.arcgis.com/vPD5PVLI6sfkZ5E4/arcgis/rest/services/IA_COVID19_Cases' \ '/FeatureServer/0/query?where=IACountyID%3D29&outFields=IACountyID,Name,Confirmed,Deaths,last_updated,' \ 'pop_est_2018,individuals_tested&returnGeometry=false&outSR=4326&f=json' DATE_LOCATION = '$.features[0].attributes' magtag = MagTag() def format_date_time(response): date_time = time.localtime(response) mins = date_time[4] if date_time[4] > 9 else "0{}".format(date_time[4]) return "{}/{}/{} {}:{}".format(date_time[0], date_time[1], date_time[2], date_time[3], mins) def format_percent(a, b): return round(a / b * 100, 1) def add_text(x, y): magtag.add_text( text_font="Arial-12.bdf", text_position=(x, y),
import time from adafruit_magtag.magtag import MagTag from adafruit_progressbar import ProgressBar time.sleep(4) # Set up where we'll be fetching data from DATA_SOURCE = "https://hosted.weblate.org/api/projects/circuitpython/statistics/" DATA_LOCATION = ["translated_percent"] def text_transform(val): return "Translated: {}%".format(val) magtag = MagTag( url=DATA_SOURCE, json_path=DATA_LOCATION, ) magtag.network.connect() magtag.add_text( text_font="fonts/leaguespartan18.bdf", text_position=( (magtag.graphics.display.width // 2) - 1, 42, ), text_scale=1, text_transform=text_transform, text_anchor_point=(0.5, 0.5), )
) magtag.splash.append(label_event_time) label_event_desc = label.Label( font_event, x=88, y=40 + (event_idx * 35), color=0x000000, text=event_name, line_spacing=0.65, ) magtag.splash.append(label_event_desc) # Create a new MagTag object magtag = MagTag() r = rtc.RTC() # DisplayIO Setup magtag.set_background(0xFFFFFF) # Add the header line_header = Line(0, 30, 320, 30, color=0x000000) magtag.splash.append(line_header) font_h1 = bitmap_font.load_font("fonts/Arial-18.pcf") label_header = label.Label(font_h1, x=5, y=15, color=0x000000, max_glyphs=30) magtag.splash.append(label_header) # Set up calendar event fonts font_event = bitmap_font.load_font("fonts/Arial-12.pcf")
# Defines the colors, speeds, and tail lengths for the comet animation cometColorA = WHITE cometColorB = GOLD cometColorC = RED boardCometSpeed = 0.25 stripCometSpeed = 0.0625 boardCometTailLen = 3 stripCometTailLen = 15 ### Hardware Set-Up ### # Sets up the MagTag board and Neopixels magtag = MagTag() boardPixels = magtag.peripherals.neopixels boardPixels.brightness = boardBrightness magtag.peripherals.neopixel_disable = False stripPixels = neopixel.NeoPixel(stripPin, stripCnt, brightness=stripBrightness, auto_write=False) ### Animation Sequences & Groups ### # Creates and organizes the animations animations = AnimationSequence( AnimationGroup( Solid(boardPixels, WHITE), ColorCycle(stripPixels, cycleSpeed, cycleColors),
""" # pylint: disable=import-error, line-too-long import time import rtc from adafruit_display_shapes.rect import Rect from adafruit_magtag.magtag import MagTag # CONFIGURABLE SETTINGS and ONE-TIME INITIALIZATION ------------------------ JSON_URL = 'https://spreadsheets.google.com/feeds/cells/1Tk943egFNDV7TmXGL_VspYyWKELeJO8gguAmNSgLDbk/1/public/full?alt=json' NICE = True # Use 'True' for nice list, 'False' for naughty TWELVE_HOUR = True # If set, show 12-hour vs 24-hour (e.g. 3:00 vs 15:00) DD_MM = False # If set, show DD/MM instead of MM/DD dates MAGTAG = MagTag(rotation=0) # Portrait (vertical) display # SOME UTILITY FUNCTIONS --------------------------------------------------- def hh_mm(time_struct, twelve_hour=True): """ Given a time.struct_time, return a string as H:MM or HH:MM, either 12- or 24-hour style depending on twelve_hour flag. """ if twelve_hour: if time_struct.tm_hour > 12: hour_string = str(time_struct.tm_hour - 12) # 13-23 -> 1-11 (pm) elif time_struct.tm_hour > 0: hour_string = str(time_struct.tm_hour) # 1-12 else: hour_string = '12' # 0 -> 12 (am)
# SPDX-FileCopyrightText: 2020 Eva Herrada for Adafruit Industries # # SPDX-License-Identifier: MIT import time import terminalio from adafruit_magtag.magtag import MagTag magtag = MagTag() magtag.peripherals.neopixel_disable = False magtag.add_text( text_font=terminalio.FONT, text_position=(140, 55), text_scale=7, text_anchor_point=(0.5, 0.5), ) magtag.set_text("00:00") # Function that makes the neopixels display the seconds left def update_neopixels(seconds): n = seconds // 15 for j in range(n): magtag.peripherals.neopixels[3 - j] = (128, 0, 0) magtag.peripherals.neopixels[3 - n] = (int( ((seconds / 15) % 1) * 128), 0, 0) alarm_set = False
import time import random import json import terminalio from adafruit_magtag.magtag import MagTag magtag = MagTag() #provide a local configuration file that inits config = json.loads(open("config.json").read()) #attempt to get an updated version of the config file online. import ipaddress import ssl import wifi import socketpool import adafruit_requests # URLs to fetch from TEXT_URL = "https://raw.githubusercontent.com/danlemire/danlemire.github.io/main/config.json" JSON_QUOTES_URL = "https://www.adafruit.com/api/quotes.php" # Get wifi details and more from a secrets.py file try: from secrets import secrets except ImportError: print("WiFi secrets are kept in secrets.py, please add them there!") raise def get_config():
METRIC = False # set to True for metric units 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)
import time import displayio from adafruit_magtag.magtag import MagTag from adafruit_display_shapes.circle import Circle # create MagTag and connect to network try: magtag = MagTag() magtag.network.connect() except (ConnectionError, ValueError, RuntimeError) as e: print("*** MagTag(), Some error occured, retrying! -", e) # Exit program and restart in 1 seconds. magtag.exit_and_deep_sleep(1) # displayio groups group = displayio.Group(max_size=30) tree_group = displayio.Group(max_size=30) circle_group = displayio.Group(max_size=30) # import tree bitmap tree = displayio.OnDiskBitmap(open("/atree.bmp", "rb")) tree_grid = displayio.TileGrid(tree, pixel_shader=displayio.ColorConverter()) # add bitmap to its group tree_group.append(tree_grid) # add tree group to the main group group.append(tree_group) # list of circle positions spots = ((246, 53), (246, 75), (206, 42), (206, 64), (206, 86), (176, 31),
strip_brightness = 1 # The color of the sparkle. sparkle_color = GOLD # Sparkle speed. It is measured in seconds. sparkle_speed = 0.1 def days_in_year(date_obj): # Check whether if the day count is a leap year. if (date_obj.tm_year % 100 != 0 or date_obj.tm_year % 400 == 0) and date_obj.tm_year % 4 == 0: return 366 return 365 # Initialize the MagTag. magtag = MagTag() # Connect the MagTag to ESP32 WiFi interface. magtag.network.connect() # Setup the pixel interface. pixels = magtag.peripherals.neopixels pixels.brightness = pixel_brightness magtag.peripherals.neopixel_disable = False strip = neopixel.NeoPixel(strip_pin, strip_num, brightness=strip_brightness, auto_write=False)
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense import time from adafruit_magtag.magtag import MagTag magtag = MagTag() magtag.add_text( text_position=( 50, (magtag.graphics.display.height // 2) - 1, ), text_scale=3, ) magtag.set_text("Hello World") button_colors = ((255, 0, 0), (255, 150, 0), (0, 255, 255), (180, 0, 255)) button_tones = (1047, 1318, 1568, 2093) while True: for i, b in enumerate(magtag.peripherals.buttons): if not b.value: print("Button %c pressed" % chr((ord("A") + i))) magtag.peripherals.neopixel_disable = False magtag.peripherals.neopixels.fill(button_colors[i]) magtag.peripherals.play_tone(button_tones[i], 0.25) break else: magtag.peripherals.neopixel_disable = True
# SPDX-License-Identifier: Unlicense import time import terminalio from adafruit_magtag.magtag import MagTag # Set up where we'll be fetching data from DATA_SOURCE = "https://api.coindesk.com/v1/bpi/currentprice.json" DATA_LOCATION = ["bpi", "USD", "rate_float"] def text_transform(val): return "Bitcoin: $%d" % val magtag = MagTag( url=DATA_SOURCE, json_path=DATA_LOCATION, ) magtag.network.connect() magtag.add_text( text_font=terminalio.FONT, text_position=( (magtag.graphics.display.width // 2) - 1, (magtag.graphics.display.height // 2) - 1, ), text_scale=3, text_transform=text_transform, text_anchor_point=(0.5, 0.5), )
raise # Set to the twitter username you'd like to fetch tweets from TWITTER_USERNAME = "******" # Set to the amount of time to deep sleep for, in minutes SLEEP_TIME = 15 # Set up where we'll be fetching data from DATA_SOURCE = ("https://api.twitter.com/1.1/statuses/user_timeline.json?" "screen_name=%s&count=1&tweet_mode=extended" % TWITTER_USERNAME) TWEET_TEXT = [0, "full_text"] TWEET_FULL_NAME = [0, "user", "name"] TWEET_HANDLE = [0, "user", "screen_name"] magtag = MagTag(url=DATA_SOURCE, json_path=(TWEET_FULL_NAME, TWEET_HANDLE, TWEET_TEXT)) # Set Twitter OAuth2.0 Bearer Token bearer_token = secrets["twitter_bearer_token"] magtag.set_headers({"Authorization": "Bearer " + bearer_token}) # Display setup magtag.set_background("/images/background.bmp") # Twitter name magtag.add_text( text_position=(70, 10), text_font="/fonts/Arial-Bold-12.pcf", ) # Twitter handle (@username) magtag.add_text(
# SPDX-License-Identifier: Unlicense import time from adafruit_magtag.magtag import MagTag # Set up where we'll be fetching data from DATA_SOURCE = "https://api.covidtracking.com/v1/us/current.json" DATE_LOCATION = [0, 'dateChecked'] NEWPOS_LOCATION = [0, 'positiveIncrease'] CURRHOSP_LOCATION = [0, 'hospitalizedCurrently'] NEWHOSP_LOCATION = [0, 'hospitalizedIncrease'] ALLDEATH_LOCATION = [0, 'death'] NEWDEATH_LOCATION = [0, 'deathIncrease'] magtag = MagTag( url=DATA_SOURCE, json_path=(DATE_LOCATION, NEWPOS_LOCATION, CURRHOSP_LOCATION, NEWHOSP_LOCATION, ALLDEATH_LOCATION, NEWDEATH_LOCATION), ) magtag.network.connect() # All positive magtag.add_text( text_font="Arial-Bold-12.bdf", text_position=(10, 15), text_transform=lambda x: "Date: {}".format(x[0:10]), ) # Positive increase magtag.add_text( text_font="Arial-Bold-12.bdf", text_position=(10, 35), text_transform=lambda x: "New positive: {:,}".format(x),
# The time of the thing! EVENT_YEAR = 2021 EVENT_MONTH = 1 EVENT_DAY = 20 EVENT_HOUR = 12 EVENT_MINUTE = 00 # we'll make a python-friendly structure event_time = time.struct_time((EVENT_YEAR, EVENT_MONTH, EVENT_DAY, EVENT_HOUR, EVENT_MINUTE, 0, # we don't track seconds -1, -1, False)) # we dont know day of week/year or DST # Set up where we'll be fetching data from # pylint: disable=line-too-long DATA_SOURCE = "http://worldtimeapi.org/api/timezone/America/New_York" magtag = MagTag() magtag.network.connect() magtag.add_text( text_font="Arial-Bold-24.bdf", text_position=(10, 25), line_spacing=0.85, ) magtag.graphics.qrcode(b"https://buildbackbetter.com/", qr_size=3, x=200, y=25) timestamp = None lasttimefetch_stamp = None while True: if not lasttimefetch_stamp or (time.monotonic() - lasttimefetch_stamp) > 3600:
import time from adafruit_magtag.magtag import MagTag USE_AMPM_TIME = True weekdays = ("mon", "tue", "wed", "thur", "fri", "sat", "sun") last_sync = None last_minute = None magtag = MagTag() magtag.graphics.set_background("/background.bmp") mid_x = magtag.graphics.display.width // 2 - 1 magtag.add_text( text_font="Lato-Regular-74.bdf", text_position=(mid_x, 10), text_anchor_point=(0.5, 0), is_data=False, ) magtag.set_text("00:00a", auto_refresh=False) magtag.add_text( text_font="/BebasNeueRegular-41.bdf", text_position=(126, 86), #was 141 text_anchor_point=(0, 0), is_data=False, ) magtag.set_text("DAY 00:00a", index=1, auto_refresh=False) def hh_mm(time_struct, twelve_hour=True):