我正在尝试在我的 Kivy 应用程序中显示从我的心跳传感器获得的值。我已经尝试使用应用于其他传感器的数据提取方法,但它不适用于该传感器,因为它不包含任何功能。
我尝试了多种不同的方法,但它们都没有返回所需的输出。有人可以看看传感器代码并建议一些方法在我的 kivy 应用程序中显示输出。
Heartbeatsensot.py
import time
# Import the ADS1x15 module.
import Adafruit_ADS1x15
if __name__ == '__main__':
adc = Adafruit_ADS1x15.ADS1015()
# initialization
GAIN = 2/3
curState = 0
thresh = 525 # mid point in the waveform
P = 512
T = 512
stateChanged = 0
sampleCounter = 0
lastBeatTime = 0
firstBeat = True
secondBeat = False
Pulse = False
IBI = 600
rate = [0]*10
amp = 100
lastTime = int(time.time()*1000)
# Main loop. use Ctrl-c to stop the code
while True:
# read from the ADC
Signal = adc.read_adc(0, gain=GAIN) #TODO: Select the correct ADC channel. I have selected A0 here
curTime = int(time.time()*1000)
sampleCounter += curTime - lastTime; # # keep track of the time in mS with this variable
lastTime = curTime
N = sampleCounter - lastBeatTime; # # monitor the time since the last beat to avoid noise
#print N, Signal, curTime, sampleCounter, lastBeatTime
## find the peak and trough of the pulse wave
if Signal < thresh and N > (IBI/5.0)*3.0 : # # avoid dichrotic noise by waiting 3/5 of last IBI
if Signal < T : # T is the trough
T = Signal; # keep track of lowest point in pulse wave
if Signal > thresh and Signal > P: # thresh condition helps avoid noise
P = Signal; # P is the peak
# keep track of highest point in pulse wave
** 我正在尝试将读数添加到的 kivy 应用程序**
米琪卡哇伊
相关分类