From a43940c1a66ea04624c37afaa509e775d35d245c Mon Sep 17 00:00:00 2001 From: markyharris Date: Wed, 30 Mar 2022 18:23:13 -0700 Subject: [PATCH] added layout and auto interval --- data.txt | 4 ++-- metar_layouts.py | 7 ++----- metar_main.py | 31 ++++++++++++++++++++++++++----- templates/metar.html | 5 ++++- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/data.txt b/data.txt index 8cac8d9..134875d 100644 --- a/data.txt +++ b/data.txt @@ -1,4 +1,4 @@ -kflg +KSPI -2 -1800 0 +1 diff --git a/metar_layouts.py b/metar_layouts.py index acf03e7..4c73e00 100644 --- a/metar_layouts.py +++ b/metar_layouts.py @@ -1392,7 +1392,7 @@ def layout6(display, metar, remarks, print_table, use_remarks): # layout7 # ############ # Circles theme -def layout7(display, metar, remarks, print_table, use_remarks): +def layout7(display, metar, remarks, print_table, use_remarks): def circle_points(r, n): circles = [] for r, n in zip(r, n): @@ -1677,7 +1677,7 @@ def layout8(display, metar, remarks, print_table, use_remarks): RADIUS = 10 MARGIN = 10 SPACING = (2*RADIUS)+MARGIN - ICON_OFFSET = COL1-COL0-60 + ICON_OFFSET = COL1-COL0-65 NUM_AIRPORTS = 15 # Display box with airport and flight category. The box must be drawn first than the text @@ -1685,7 +1685,6 @@ def layout8(display, metar, remarks, print_table, use_remarks): # up_left_x, up_left_y, box_width, box_height, radius, box_color def print_box(flight_cat, airport, pos1_x, pos1_y, pos2_x, pos2_y): metar = Metar(airport) -# flightcategory, icon = flight_category(metar) flightcategory = flight_cat output = airport+":"+flightcategory+" " w, h = display.draw_black.textsize(output, font=font36b) @@ -1741,8 +1740,6 @@ def print_box(flight_cat, airport, pos1_x, pos1_y, pos2_x, pos2_y): fc_ap_dict = dict(list(fc_ap_dict.items())[:NUM_AIRPORTS]) # Trim dict -# print(len(fc_ap_dict)) # debug -# print(fc_ap_dict) # debug keys_ap = list(fc_ap_dict.keys()) values_ap = list(fc_ap_dict.values()) diff --git a/metar_main.py b/metar_main.py index a9daad3..43de990 100644 --- a/metar_main.py +++ b/metar_main.py @@ -116,13 +116,14 @@ def main(): epd = epd7in5b_V2.EPD() # Instantiate instance for display. while True: -# try: + try: # error = 1/0 #debug # forces error to test the try-except statements - if True: # used instead of the try-except statements for debug purposes. +# if True: # used instead of the try-except statements for debug purposes. current_time = time.strftime("%m/%d/%Y %H:%M", time.localtime()) metar = Metar(airport) remarks, print_table = decode_remarks(metar.data["properties"]["rawMessage"]) # debug + flightcategory, icon = flight_category(metar) if len(metar.data["properties"]["rawMessage"]) > 0: print(metar.data["properties"]["rawMessage"]+"\n") @@ -142,12 +143,32 @@ def main(): print("Metar Updated") main() # Build METAR data to display using specific layout - - time.sleep(interval) # Sets interval of updates. 3600 = 1 hour + + # Setup update interval + # The update interval can be selected via cmd line or web iterface + # If Auto Interval is selected, then Flight Category dictates update + # So the worse the weather, the more often it updates. + if interval != 0: # if not auto interval selected + print("sleep ",interval) # debug + time.sleep(interval) # Sets interval of updates. 3600 = 1 hour + else: + if flightcategory == "VFR": + print("Sleep 3600") # debug + time.sleep(3600) # 1 hour if weather is good + elif flightcategory == "MVFR": + print("Sleep 1800") # debug + time.sleep(1800) # 30 mins if marginal + elif flightcategory == "IFR": + print("Sleep 1200") # debug + time.sleep(1200) # 20 mins if stormy + elif flightcategory == "LIFR": + print("Sleep 600") # debug + time.sleep(600) # 10 mins if stormy and low visibility + epd.init() epd.sleep() -# except Exception as e: + except Exception as e: time.sleep(2) print("Error Occurred in Main While Loop") exception_type, exception_object, exception_traceback = sys.exc_info() diff --git a/templates/metar.html b/templates/metar.html index 60df790..3d9830e 100755 --- a/templates/metar.html +++ b/templates/metar.html @@ -114,6 +114,7 @@

METAR E-Paper Display Selector


-

+
+ Note: Auto Interval changes the update based on Flight Category.
+ VFR=1 hour, MVFR=30 mins, IFR=20 mins and LIFR=10 mins