print("Hello, ESP32!")
import machine
import tm1637
import time
class SegDis:
def __init__(self, clk, dio):
self.clk = machine.Pin(clk)
self.dio = machine.Pin(dio)
self.hw = tm1637.TM1637(clk=self.clk, dio=self.dio)
segdis = SegDis(clk=18, dio=16)
segdis.hw.show('----')
flight_phase = "taxi"
flight_level = 36500
velocity = 420
heading = 182
lat = 42.056
lon = 46.792
# STATUS_CODE mapping (enum)
STATUS_CODE = {
"idle": "IDLE",
"taxi": "TAXI",
"departure": "TKOF",
"climb": "CLMB",
"cruise": "CRUZ",
"descend": "DESC",
"approach": "APCH",
"arrival": "ARVD"
}
# STATUS_TYPE constants (enum)
STATUS_TYPE_PHASE = 1
STATUS_TYPE_ALTIT = 2
STATUS_TYPE_SPEED = 3
STATUS_TYPE_LOCAT = 4
STATUS_TYPE_SQUAK = 5
status_order = [1, 2, 1, 3, 1, 4]
while True:
# Show flight status in queue
status_type = status_order[0]
print(status_type)
if status_type == STATUS_TYPE_PHASE:
segdis.hw.show(STATUS_CODE[flight_phase])
elif status_type == STATUS_TYPE_ALTIT:
segdis.hw.show(f"H{round(flight_level/100)}")
elif status_type == STATUS_TYPE_SPEED:
segdis.hw.show(f"V{round(velocity)}")
elif status_type == STATUS_TYPE_LOCAT:
segdis.hw.show(f"N{290}")
status_order.append(status_order.pop(0))
time.sleep(3)