# Load the fonts print(gc.mem_free()," free") print("loading fonts") time_font = bitmap_font.load_font('/fonts/Asimov-104.pcf') time_font.load_glyphs(b'0123456789:%') # pre-load glyphs for fast printing # type: ignore speed_font = bitmap_font.load_font('/fonts/AsimovNar-45.pcf') speed_font.load_glyphs(b'0123456789mph.:%') # type: ignore title_font = bitmap_font.load_font('/fonts/Asimov-25.pcf') title_font.load_glyphs(b'123456789INSIDEOUTFft.%') # type: ignore # temperature_font = bitmap_font.load_font('/fonts/AsimovNar-40.pcf') # temperature_font.load_glyphs(b'0123456789INSIDEOUTFft.%') # type: ignore print("fonts loaded") def create_text_areas(configs): """Given a list of area specifications, create and return text areas.""" print("creating text areas") text_areas = [] for cfg in configs: textarea = Label(cfg['font'], text=' '*cfg['size']) textarea.x = cfg['x'] textarea.y = cfg['y'] textarea.color = cfg['color'] text_areas.append(textarea) return text_areas class Time_State(State): """This state manages the primary time display screen/mode""" def __init__(self): super().__init__() self.background_day = None self.background_night = 'main_background_nightl.bmp' self.refresh_time = None self.update_time = None self.weather_refresh = None text_area_configs = [dict(x=160, y=235, size=5, color=0xFFFFFF, font=time_font), # TIME dict(x=325, y=100, size=5, color=0xE09941, font=speed_font), # SPEED dict(x=120, y=10, size=16, color=0xCFFC03, font=title_font), # screen heading dict(x=125, y=48, size=4, color=0xFFFFFF, font=title_font), # INSIDE temp dict(x=125, y=93, size=10, color=0x4F0066, font=title_font), # INSIDE humid dict(x=215, y=48, size=4, color=0xFFFFFF, font=title_font), # OUTSIDE temp dict(x=215, y=93, size=4, color=0x4F0066, font=title_font), # OUTSIDE humid dict(x=145, y=170, size=1, color=0x32A89E, font=speed_font), # Altitude dict(x=310, y=180, size=5, color=0xCFFC03, font=title_font)] # Air Quality self.text_areas = create_text_areas(text_area_configs)