第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 Kivy 標簽中顯示來自 python 程序的心跳傳感器讀數

在 Kivy 標簽中顯示來自 python 程序的心跳傳感器讀數

梵蒂岡之花 2022-01-18 17:50:30
我正在嘗試在我的 Kivy 應用程序中顯示從我的心跳傳感器獲得的值。我已經嘗試使用應用于其他傳感器的數據提取方法,但它不適用于該傳感器,因為它不包含任何功能。我嘗試了多種不同的方法,但它們都沒有返回所需的輸出。有人可以看看傳感器代碼并建議一些方法在我的 kivy 應用程序中顯示輸出。Heartbeatsensot.pyimport time# Import the ADS1x15 module.import Adafruit_ADS1x15if __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 應用程序**
查看完整描述

1 回答

?
米琪卡哇伊

TA貢獻1998條經驗 獲得超6個贊

我認為你可以通過一些小的修改來完成你想要的。首先添加一個StringProperty到你的ScreenThermo類,并在on_enter()方法中啟動一個線程來運行你的Heartbeatsensot代碼:


from Heartbeatsensot import hearbeatsensot


class ScreenThermo(Screen):

    BPM_string = StringProperty('BPM: Not Detected')


    def on_enter(self, *args):

        Thread(target=hearbeatsensot, args=(self,)).start()

在您的kv文件中,添加對 new 的引用StringProperty:


<ScreenThermo>:

    Label:

        text: " Pulse rate"

        font_size: 50

        pos: (35, 100)



    Label:

        id: TempLabel

        text: root.BPM_string  # references new StringProperty

        font_size: 60

        halign: 'center'

        valign: 'middle'

現(xiàn)在您只需要將要顯示的任何內容TempLabel放入BPM_string屬性中即可。為此,請更改Heartbeatsensot.py以定義可在Thread. if __name__ == '__main__':只需將該文件中的替換為def hearbeatsensot(screenThermo):如下所示:


import time

# Import the ADS1x15 module.

import Adafruit_ADS1x15



def hearbeatsensot(screenThermo):


    adc = Adafruit_ADS1x15.ADS1015()

    # initialization

    GAIN = 2/3

    .

    .

    .

    screenThermo.BPM_string = 'BPM: 65'

    .

    .

    .

然后,在該方法中,只需使用 somethink like screenThermo.BPM_string = 'BPM: 65'(或任何您想要設置的內容)。BPM_string文件中的引用kv將自動設置綁定以更新TempLabel每當BPM_string被修改時。


查看完整回答
反對 回復 2022-01-18
  • 1 回答
  • 0 關注
  • 182 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號