示例#1
0
stepsUp = np.interp(meanMMHg + 0.5, mmHgs, steps)
stepsDown = np.interp(meanMMHg - 0.5, mmHgs, steps)
slope = stepsUp - stepsDown  # steps to change by 1 mmHg

sei = 0  # span error integral
span_kp = 0.9
span_ki = 0.1

mei = 0  # mean error integral
mid_kp = 0.85
mid_ki = 0.1
RNG = 7500
MID = mean
stop = 0
while (i < N):  # up until N, keep appending to the list
    s = pressure.one_read()
    i = i + 1
    now = time.time()
    t.append(now - before)
    p1 = pressure.psi2mmHg(int(s) * 0.001)
    p.append(p1)
    if ((i % 10) == 0):
        line1.set_data(T0[0:i], p[0:i])
        data = np.array(p)
        m0 = np.amin(data)
        m1 = np.amax(data)
        line2.set_data([0, T0[i - 1]], [m1, m1])
        line3.set_data([0, T0[i - 1]], [m0, m0])
        ax.legend((line1, line2, line3),
                  ('BP', 'MAX:%3.1f' % m1, 'MIN:%3.1f' % m0),
                  loc='lower center')
print(ys)
print("about to write waveform")
pressure.write_waveform(ys)
print("Wrote waveform")
wf = pressure.read_waveform()
print(wf)
print("Read waveform")
#sys.exit(0);
pressure.play_waveform(1, hsteps, home)
before = time.time()
threshold = before + 10.0
t = []
pressure.start_reading()
while (time.time() < threshold):
    pressure.one_read()
    now = time.time()
    t.append(now - before)
    #p.append(p0)
pressure.stop_reading()
if (use_psi):
    p = pressure.get_pressures()
else:
    p = pressure.get_mmHgs()
print("PLOTTING")

import pickle
s = pickle.dumps([t, p])
f = open('data.bin', 'wb')
f.write(s)
f.close()
示例#3
0
from finger import Pressure
import time
import numpy as np
from matplotlib import pyplot as plt

plt.ion()

pressure = Pressure()

for i in range(100):
    print(pressure.one_read())
    time.sleep(1.0)