Skip to content

Commit

Permalink
compatability testing
Browse files Browse the repository at this point in the history
Trying to get the start button to work (no luck so far)
  • Loading branch information
Mart4672 committed Jul 19, 2020
1 parent 403a618 commit 49b1a44
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 13 deletions.
62 changes: 52 additions & 10 deletions drivers/flight_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def init(config=Config.FLIGHT):
manager.DataType('temperature', float, units='deg C', thresholds=(-20, 80)),
manager.DataType('gps_vel', float, units='xy m/s', thresholds=(-20, 100)),
manager.DataType('gps_dir', float, units='xy deg', thresholds=(-20, 365)),
manager.DataType('xy_from_lanch', float, units='xy m', thresholds=(-20, 100000)),
manager.DataType('x_from_launch', float, units='m', thresholds=(-100000, 100000)),
manager.DataType('y_from_launch', float, units='m', thresholds=(-100000, 100000)),
manager.DataType('dir_from_launch', float, units='xy deg', thresholds=(-20, 365)),
manager.DataType('P1_setting', bool),
manager.DataType('P2_setting', bool),
Expand All @@ -65,14 +66,10 @@ def init(config=Config.FLIGHT):
manager.DataType('launch_lon', float),
manager.DataType('land_lat', float),
manager.DataType('land_lon', float),
manager.DataType('gps_n', float, units="m"),
manager.DataType('gps_e', float, units="m"),

manager.DataType('up', bool),
manager.DataType('down', bool),
manager.DataType('gps_d', bool),
manager.DataType('bmp_d', bool),
manager.DataType('bmp_d2', bool),
#manager.DataType('bmp_d2', bool),
manager.DataType('bno_d', bool),

manager.DataType('run_time', int, units="ms"),
Expand All @@ -93,6 +90,7 @@ def init(config=Config.FLIGHT):
dispatcher = manager.Dispatcher(*dts)
data_manager = manager.DataManager(dispatcher)
root = Tk()
<<<<<<< HEAD
root.configure(background='#69615e')
app = gui.Application(
dispatcher, data_manager, plots, master=root,
Expand All @@ -106,8 +104,20 @@ def init(config=Config.FLIGHT):
plots_background='#69615e',
controls_background='#69615e',
default_baud=57600)
=======
app = gui.Application(dispatcher, data_manager, plots, master=root,
window_manager_title=
"Telemetry monitor - Demo" if config == Config.DEMO else
"Telemetry monitor - Flight" if config == Config.FLIGHT else
"Telemetry monitor",
show_send_value=False,
serial_console_height=5,
plots_size=(10,10),
default_baud=57600)
>>>>>>> parent of b41a304... bg colors and positioning

This comment has been minimized.

Copy link
@krame505

krame505 Jul 19, 2020

Member

FYI, you just pushed a bunch of unresolved merge conflicts in this commit. I would suggest hard-resetting it and redoing the merge.

This comment has been minimized.

Copy link
@Mart4672

Mart4672 Jul 19, 2020

Author

How do I hard-reset?

This comment has been minimized.

Copy link
@krame505

krame505 Jul 19, 2020

Member

Actually I'm not really sure what you just did... but you can undo the most recent commit with git reset --hard HEAD^ && git push -f origin UI_Testing.

This comment has been minimized.

Copy link
@Mart4672

Mart4672 Jul 19, 2020

Author

where do I enter this command?

This comment has been minimized.

Copy link
@krame505

krame505 Jul 19, 2020

Member

In the terminal

This comment has been minimized.

Copy link
@krame505

krame505 Jul 19, 2020

Member

I have no idea how to do it from the graphical interface.

This comment has been minimized.

Copy link
@Mart4672

Mart4672 Jul 19, 2020

Author

git is not recognized as a windows command in the command prompt. Is there a different terminal that I'm supposed to use?

This comment has been minimized.

Copy link
@krame505

krame505 Jul 19, 2020

Member

I don't use git on Windows, but it sounds like there is a program called git bash that gives you a command line interface for git.


running = False

def heartbeat():
if running: #get link2ground status all the time, exept if I delete this line, the start/abort button doesn't work right for some reason
app.sendValue("c") #c stands for connection, i.e. heartbeat
Expand All @@ -128,29 +138,36 @@ def check_stop(time, status):
nonlocal running
if status == 'STAND_BY': #was 'STAND_BY'
#status.config(bg='#0fe9f5')
app.stop()
app.stop() #app.stop()
running = False
if config == Config.DEMO:
countdown.config(text=" T-00:10:00")
else:
countdown.config(text=" T-01:00:00")
start_abort_button.config(text="Start", bg='lime green')
elif status == 'TERMINAL_COUNT':
running = True
app.start()
status.config(bg='#e6d925')
start_abort_button.config(text="Abort", bg='red')
elif status == 'POWERED_ASCENT':
status.config(bg='#e04122')

start_abort_button.config(text="Abort", bg='red')
elif status == 'UNPOWERED_ASCENT':
status.config(bg='#bd857b')
start_abort_button.config(text="Abort", bg='red')
elif status == 'FREEFALL':
status.config(bg='#760e99')
start_abort_button.config(text="Abort", bg='red')
elif status == 'DROGUE_DESCENT':
status.config(bg='#8b65ba')
start_abort_button.config(text="Abort", bg='red')
elif status == 'MAIN_DESCENT':
status.config(bg='#402aa1')

start_abort_button.config(text="Abort", bg='red')
elif status == 'LANDED':
status.config(bg='#4395d9')
start_abort_button.config(text="Abort", bg='red')
else:
start_abort_button.config(text="Abort", bg='red')

Expand All @@ -169,13 +186,22 @@ def state_name(name):
return lower_name.replace("_", " ")

# Add custom gui controls
<<<<<<< HEAD
Label(app, text="\nControls", bg= '#69615e').pack(side=TOP)
=======
Label(app, text="\nControls").pack()
>>>>>>> parent of b41a304... bg colors and positioning

# Sensor controls
#Label(app, text="\nSensor Controls").pack()
controlsFrame = Frame(app, bg= '#69615e')
<<<<<<< HEAD
controlsFrame.pack(side=TOP) #expand=1
sensorStatus = Label(controlsFrame, text="All sensors functional", fg='green', font=("Helvetica", 12), bg= '#c9c1be') #light grey c9c1be
=======
controlsFrame.pack() #expand=1
sensorStatus = Label(controlsFrame, text="All sensors functional", fg='green', font=("Helvetica", 17))
>>>>>>> parent of b41a304... bg colors and positioning
sensorStatus.grid(row=0,column=0,columnspan=4)
#Button(controlsFrame, text="Zero force", command=lambda: app.sendValue("zero_force")).pack(side=LEFT)
#Button(controlsFrame, text="Zero pressure", command=lambda: app.sendValue("zero_pressure")).pack(side=LEFT)
Expand Down Expand Up @@ -236,12 +262,21 @@ def state_name(name):
#Label(app, text="\nThrottle Controls").pack()
throttleFrame = Frame(app, bg= '#69615e') #bg or background works
throttleFrame.pack()
<<<<<<< HEAD
Label(throttleFrame, text="Drogue", font=("Helvetica", 10), bg= '#69615e').grid(row=0, column=1, sticky= W)
Label(throttleFrame, text="Main", font=("Helvetica", 10), bg= '#69615e').grid(row=0, column=2, padx=15, sticky= W)
Label(throttleFrame, text="1", font=("Helvetica", 10), bg= '#69615e').grid(row=1, column=0, sticky=W, padx=5)
Label(throttleFrame, text="2", font=("Helvetica", 10), bg= '#69615e').grid(row=2, column=0, sticky=W, padx=5)
Label(throttleFrame, text="Cam", font=("Helvetica", 10), bg= '#69615e').grid(row=3, column=0, sticky=W, padx=5)
Button(throttleFrame, text="Reset board", font=("Helvetica", 8), command=lambda: app.sendValue("reset")).grid(row=3, column=2, sticky=W, padx=5)
Button(throttleFrame, text="Reset board", font=("Helvetica", 8), command=lambda: app.sendValue("r")).grid(row=3, column=2, sticky=W, padx=5)
=======
Label(throttleFrame, text="Drouge", font=("Helvetica", 15)).grid(row=0, column=1)
Label(throttleFrame, text="Main", font=("Helvetica", 15)).grid(row=0, column=2, padx=15)
Label(throttleFrame, text="1", font=("Helvetica", 15)).grid(row=1, column=0, sticky=W, padx=5)
Label(throttleFrame, text="2", font=("Helvetica", 15)).grid(row=2, column=0, sticky=W, padx=5)
Label(throttleFrame, text="Cam", font=("Helvetica", 15)).grid(row=3, column=0, sticky=W, padx=5)
Button(throttleFrame, text="Reset board", command=lambda: app.sendValue("reset")).grid(row=3, column=2, sticky=W, padx=5)
>>>>>>> parent of b41a304... bg colors and positioning


valves = ['P1', 'P2', 'P3', 'P4', 'P5'] #indexing starts at 0
Expand All @@ -259,11 +294,18 @@ def state_name(name):
runFrame.pack(side=TOP)
start_abort_button = Button(runFrame, text="Start", command=start_abort_handler, bg="lime green", height=2, width=8)
start_abort_button.pack(side=LEFT)
<<<<<<< HEAD
countdown = Label(runFrame, text=" T-01:00:00", width=10, fg="red", font=("Helvetica", 16, "bold"), bg= '#c9c1be') #b9b1ae
countdown.pack(side=TOP)

status = Label(runFrame, text=" Stand by", width=16, font=("Helvetica", 10), bg= '#c9c1be')
status.pack(side=TOP)
=======
countdown = Label(runFrame, text=" T-01:00:00", fg="red", font=("Helvetica", 20, "bold"))
countdown.pack()
status = Label(runFrame, text=" Stand by", width=15, font=("Helvetica", 17))
status.pack()
>>>>>>> parent of b41a304... bg colors and positioning

# Listeners
app.dispatcher.add_listener('status', lambda time, val: status.config(text=" " + state_name(val)))
Expand Down
27 changes: 27 additions & 0 deletions src/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ def __init__(self,
'serial_console_height': 15,
'default_baud': 9600,
'plots_size': (12,10),
<<<<<<< HEAD
'plots_background': 'white',
'controls_background': None}
=======
'plots_background': 'white'}
>>>>>>> parent of b41a304... bg colors and positioning
new_flags.update(flags)
self.flags = new_flags

Expand All @@ -70,8 +74,13 @@ def __init__(self,
self.flags['full_screen'] = args.full_screen

# Init gui
<<<<<<< HEAD
Frame.__init__(self, master, bg=self.flags['controls_background'])
self.pack(side=LEFT) #side=LEFT
=======
Frame.__init__(self, master)
self.pack()
>>>>>>> parent of b41a304... bg colors and positioning
#master.iconbitmap('telemetry.png')
master.attributes("-fullscreen", self.flags['full_screen'])
master.bind('<Escape>', self.unmaximize)
Expand Down Expand Up @@ -119,8 +128,13 @@ def _createWidgets(self):
"""Initialize the various widgets in the main frame."""
self._setupPlots()

<<<<<<< HEAD
buttons = Frame(self, bg=self.flags['controls_background'])
self.controlButton = Button(buttons, text="Start", command=self.start, bg="lime green",font=("Helvetica", 8))
=======
buttons = Frame(self)
self.controlButton = Button(buttons, text="Start", command=self.start, bg="lime green")
>>>>>>> parent of b41a304... bg colors and positioning
self.controlButton.pack(side=LEFT)

self.exitButton = Button(buttons, text="Quit", command=self.terminate, font=("Helvetica", 8))
Expand All @@ -139,11 +153,20 @@ def _createWidgets(self):
self.thresholdButton.pack(side=LEFT)

buttons.pack()
<<<<<<< HEAD
serialLabel = Label(self, text="\nSerial console", bg=self.flags['controls_background'])
serialLabel.pack()

serial = Frame(self, bg=self.flags['controls_background'])
serialControls = Frame(serial, bg=self.flags['controls_background'])
=======

serialLabel = Label(self, text="\nSerial console")
serialLabel.pack()

serial = Frame(self, bg= '#69615e')
serialControls = Frame(serial)
>>>>>>> parent of b41a304... bg colors and positioning

self.serialPort = StringVar(self)
self.serialSelect = OptionMenu(serialControls, self.serialPort, [])
Expand Down Expand Up @@ -204,7 +227,11 @@ def _createWidgets(self):
sendValues.pack()

# Value readout widget
<<<<<<< HEAD
valuesLabel = Label(self, text="\nCurrent values", bg=self.flags['controls_background'], height= 2)
=======
valuesLabel = Label(self, text="\nCurrent values")
>>>>>>> parent of b41a304... bg colors and positioning
if self.flags['show_current_values']:
valuesLabel.pack(side=TOP)

Expand Down
6 changes: 3 additions & 3 deletions src/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self,
suffix = suffix.replace("_", " ")
if " " in suffix:
suffix = suffix[suffix.index(" "):]

if ys_names:
self.ys_names = ys_names
elif suffix:
Expand Down Expand Up @@ -133,7 +133,7 @@ def fn(x_data, y_data, y=y):
j += 1
x_data = new_x_data
y_data = new_y_data

assert len(x_data) == len(y_data)
# 'Prune' plotted data to avoid slow-down with large amounts of data
indices = range(0, len(x_data), max(len(x_data) // max_points, 1))
Expand Down Expand Up @@ -167,7 +167,7 @@ def gen_layout(plots):
available = {(i, j): True
for i in range(width)
for j in range(height)}

# List of info for each plot
layout = []

Expand Down

0 comments on commit 49b1a44

Please sign in to comment.