forked from mboyd/BTScan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrssi_plot.py
More file actions
40 lines (29 loc) · 1.22 KB
/
Copy pathrssi_plot.py
File metadata and controls
40 lines (29 loc) · 1.22 KB
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
import matplotlib
matplotlib.use('TkAgg')
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import Tkinter as Tk
from collections import deque
import threading
class RSSIPlot(object):
def __init__(self, device_mac):
self.device_mac = device_mac
self.receiver_plots = dict()
self.window = Tk.Toplevel()
self.figure = Figure()
self.canvas = FigureCanvasTkAgg(self.figure, master=self.window)
self.canvas.draw()
self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
def plot_point(self, packet):
if not packet.receiver_mac in self.receiver_plots:
i = len(self.receiver_plots) + 1
ax = self.figure.add_subplot(7, 1, i)
line, = ax.plot(range(10), range(10), animated=True, lw=2)
self.receiver_plots[packet.receiver_mac] = (ax, line, [], [])
self.canvas.draw()
ax, line, xdata, ydata = self.receiver_plots[packet.receiver_mac]
xdata.append(packet.timestamp[0])
ydata.append(packet.rssi)
line.set_data(xdata, ydata)
#ax.draw_artist(line)
self.figure.canvas.blit(ax.bbox)