-
Notifications
You must be signed in to change notification settings - Fork 0
/
testAltDisplay.py
63 lines (48 loc) · 1.53 KB
/
testAltDisplay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Test Altimeter Display
Uses live altimeter data to track the LV and shows its path on the display.
"""
import csv
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.figure import Figure
from functools import partial
import numpy as np
import time
from Parsing import Parse
import tkinter as tk
from tkinter import *
from matplotlib.backends.backend_tkagg import (
FigureCanvasTkAgg, NavigationToolbar2Tk)
# rocket speed: 800ft/sec
class AltGraph(Parse):
def __init__(self, altP):
super().__init__()
self.fig = plt.figure()
self.ax = self.fig.add_subplot(1, 1, 1)
self.xs = []
self.ys = []
self.t = 0
self.altF = altP
self.canvas = FigureCanvasTkAgg(self.fig, master = self.altF)
self.canvas.get_tk_widget().pack(side = tk.TOP, fill = tk.BOTH, expand = True)
self.canvas.draw()
self.updatePlot()
# make graph not show up a billion times
def updatePlot(self):
plt.cla()
# Add data points
self.xs.append(float(self.t))
self.ys.append(float(self.alt))
self.xs = self.xs[-20:]
self.ys = self.ys[-20:]
plt.plot(self.xs, self.ys)
# Format plot
plt.title('Altitude vs Time')
plt.ylabel('Alitude (ft)')
plt.xlabel(' ')
#self.ax.set_ylim([0, 12000])
#plt.show(block = False)
self.t += 1
self.canvas.draw_idle()
#alt = AltGraph()