bf
This commit is contained in:
parent
7d8694b576
commit
5271c9c4e4
@ -20,6 +20,38 @@ from uldaq import (get_daq_device_inventory, DaqDevice, AInScanFlag, ScanStatus,
|
|||||||
ScanOption, create_float_buffer, InterfaceType, AiInputMode)
|
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):
|
def GPIO_setup(LED1_pin, LED2_pin, Button1_pin, Button2_pin):
|
||||||
# LED output pins
|
# LED output pins
|
||||||
GPIO.setmode(GPIO.BOARD)
|
GPIO.setmode(GPIO.BOARD)
|
||||||
@ -279,27 +311,31 @@ def main():
|
|||||||
|
|
||||||
disp_eth_power = True
|
disp_eth_power = True
|
||||||
|
|
||||||
|
Plot = plot()
|
||||||
fig = plt.figure(figsize =(20/2.54, 12/2.54), facecolor='white')
|
Plot.max_v = max_v
|
||||||
axs = []
|
Plot.n_rows = n_rows
|
||||||
gs = gridspec.GridSpec(n_rows, n_cols)
|
Plot.n_cols = n_cols
|
||||||
for y in range(n_rows):
|
|
||||||
for x in range(n_cols):
|
# fig = plt.figure(figsize =(20/2.54, 12/2.54), facecolor='white')
|
||||||
ax = plt.subplot(gs[y, x])
|
# axs = []
|
||||||
|
# gs = gridspec.GridSpec(n_rows, n_cols)
|
||||||
if not y == n_rows -1:
|
# for y in range(n_rows):
|
||||||
ax.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
|
# for x in range(n_cols):
|
||||||
|
# ax = plt.subplot(gs[y, x])
|
||||||
if not x == 0:
|
#
|
||||||
ax.tick_params(axis='y', which='both', left=False, right=False, labelleft=False)
|
# if not y == n_rows -1:
|
||||||
ax.set_ylim(-max_v, max_v)
|
# ax.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
|
||||||
|
#
|
||||||
axs.append(ax)
|
# if not x == 0:
|
||||||
|
# ax.tick_params(axis='y', which='both', left=False, right=False, labelleft=False)
|
||||||
gs.update(left=0.05, bottom=0.05, top=1, right=1, hspace=0, wspace=0)
|
# 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)
|
# ax = np.hstack(ax)
|
||||||
channel_handle = []
|
# channel_handle = []
|
||||||
init_fig = True
|
init_fig = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -348,17 +384,17 @@ def main():
|
|||||||
min = np.min(np.hstack(channel_data))
|
min = np.min(np.hstack(channel_data))
|
||||||
if init_fig == True:
|
if init_fig == True:
|
||||||
for ch in channel_array:
|
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 - channel_std[power_channel], max + channel_std[power_channel])
|
||||||
# axs[ch].set_ylim(min, max)
|
# axs[ch].set_ylim(min, max)
|
||||||
channel_handle.append(h)
|
Plot.channel_handle.append(h)
|
||||||
plt.show(block=False)
|
plt.show(block=False)
|
||||||
init_fig = False
|
init_fig = False
|
||||||
else:
|
else:
|
||||||
for ch in channel_array:
|
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)
|
# np.array(data[last_idx:], dtype=np.float32).tofile(f)
|
||||||
|
Loading…
Reference in New Issue
Block a user