This commit is contained in:
tillraab 2019-09-11 13:48:49 +02:00
parent 7d8694b576
commit 5271c9c4e4

View File

@ -20,6 +20,38 @@ from uldaq import (get_daq_device_inventory, DaqDevice, AInScanFlag, ScanStatus,
ScanOption, create_float_buffer, InterfaceType, AiInputMode)
class plot():
def __init__(self):
self.n_rows = None
self.n_cols = None
self.max_v = None
self.channel_handle = []
self.fig = plt.figure(figsize=(20 / 2.54, 12 / 2.54), facecolor='white')
self.fig.canvas.mpl_connect('key_press_event', self.keypress)
self.axs = []
def create_axis(self):
gs = gridspec.GridSpec(self.n_rows, self.n_cols)
for y in range(self.n_rows):
for x in range(self.n_cols):
ax = plt.subplot(gs[y, x])
if not y == self.n_rows - 1:
ax.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
if not x == 0:
ax.tick_params(axis='y', which='both', left=False, right=False, labelleft=False)
ax.set_ylim(-self.max_v, self.max_v)
self.axs.append(ax)
gs.update(left=0.05, bottom=0.05, top=1, right=1, hspace=0, wspace=0)
def keypress(self, event):
if event.key == 'v':
print('v pressed')
def GPIO_setup(LED1_pin, LED2_pin, Button1_pin, Button2_pin):
# LED output pins
GPIO.setmode(GPIO.BOARD)
@ -279,27 +311,31 @@ def main():
disp_eth_power = True
fig = plt.figure(figsize =(20/2.54, 12/2.54), facecolor='white')
axs = []
gs = gridspec.GridSpec(n_rows, n_cols)
for y in range(n_rows):
for x in range(n_cols):
ax = plt.subplot(gs[y, x])
if not y == n_rows -1:
ax.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
if not x == 0:
ax.tick_params(axis='y', which='both', left=False, right=False, labelleft=False)
ax.set_ylim(-max_v, max_v)
axs.append(ax)
gs.update(left=0.05, bottom=0.05, top=1, right=1, hspace=0, wspace=0)
Plot = plot()
Plot.max_v = max_v
Plot.n_rows = n_rows
Plot.n_cols = n_cols
# fig = plt.figure(figsize =(20/2.54, 12/2.54), facecolor='white')
# axs = []
# gs = gridspec.GridSpec(n_rows, n_cols)
# for y in range(n_rows):
# for x in range(n_cols):
# ax = plt.subplot(gs[y, x])
#
# if not y == n_rows -1:
# ax.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
#
# if not x == 0:
# ax.tick_params(axis='y', which='both', left=False, right=False, labelleft=False)
# ax.set_ylim(-max_v, max_v)
#
# axs.append(ax)
#
# gs.update(left=0.05, bottom=0.05, top=1, right=1, hspace=0, wspace=0)
# ax = np.hstack(ax)
channel_handle = []
# channel_handle = []
init_fig = True
try:
@ -348,17 +384,17 @@ def main():
min = np.min(np.hstack(channel_data))
if init_fig == True:
for ch in channel_array:
h, = axs[ch].plot(np.arange(250)[:len(channel_data[ch])] / rate, channel_data[ch], color='k')
h, = Plot.axs[ch].plot(np.arange(250)[:len(channel_data[ch])] / rate, channel_data[ch], color='k')
# axs[ch].set_ylim(min - channel_std[power_channel], max + channel_std[power_channel])
# axs[ch].set_ylim(min, max)
channel_handle.append(h)
Plot.channel_handle.append(h)
plt.show(block=False)
init_fig = False
else:
for ch in channel_array:
channel_handle[ch].set_data(np.arange(250)[:len(channel_data[ch])] / rate, channel_data[ch])
Plot.channel_handle[ch].set_data(np.arange(250)[:len(channel_data[ch])] / rate, channel_data[ch])
fig.canvas.draw()
Plot.fig.canvas.draw()
# np.array(data[last_idx:], dtype=np.float32).tofile(f)