Beispiel #1
0
 def connect_HEART(self):
     self.HEART_status = True
     if (not debug_mock):
         self.heart_sensor = max30102.MAX30102()
         self.print_log("[+]MAX30102 conected")
     else:
         self.print_log("[!]MPU9250 mocking mode")
Beispiel #2
0
def heart_beat():
    rate = 0
    oxy = 0
    count = 0
    a = 0
    base = []
    while a < 10:
        m = max30102.MAX30102()
        red, ir, time = m.read_sequential()
        v = my_heart_calc.final_rate(red)
        base.append(v)
        a = a + 1
    pulse_mean = np.mean(base)
    n = pulse_mean / 0.1
    heart_beat = n * 4.4
    print "heart beat is ", str(heart_beat)
    def get(self):
        # MAXREFDES117から値を取得
        m = max30102.MAX30102()
        red, ir = m.read_sequential(1000)
        m.shutdown()

        # 取得した値から心拍数、SpO2を計算
        hr, spo2 = [], []
        for i in range(37):
            measure = hrcalc.calc_hr_and_spo2(ir[25 * i:25 * i + 100],
                                              red[25 * i:25 * i + 100])
            # True のものを取り出す
            if measure[1]:
                hr.append(measure[0])
            if measure[3]:
                spo2.append(measure[2])

        # 中央値を取り出す
        hr = round(median(hr))
        spo2 = round(median(spo2))
        return hr, spo2
Beispiel #4
0
import max30102
import hrcalc
import numpy as np
from numpy_ringbuffer import RingBuffer
import time

irb = RingBuffer(capacity = 600,dtype= np.int)
redb = RingBuffer(capacity = 600,dtype= np.int)

m = max30102.MAX30102()
print("Started Max")

def isFull():
        if len(irb)>=600:
                return 1
        else:
                return 0

def isEmpty():
        if len(irb)==0:
                return 1
        else:
                return 0

def calculatePhase():
	print("CALCULATION PHASE")
	while not isEmpty():
		irbl = []
                redbl = []
                for i in range(100):
                        irbl.append(irb.pop())
import max30102
import hrcalc

import sys
import lcddriver

display = lcddriver.lcd()


m = max30102.MAX30102() # sensor initialization
#red, ir = m.read_sequential() # get LEDs readings

while(1):
    red, ir = m.read_sequential() # get LEDs readings
    d = hrcalc.calc_hr_and_spo2(ir[:100], red[:100]) # give 100 values
    print('心率', d[0], '     血氧', d[2], '%')
    
    display.lcd_display_string('HR: {:.0f} bpm    '.format(d[0]), 1)
    display.lcd_display_string('SpO2: {:.1f} %    '.format(d[2]), 2)
Beispiel #6
0
 def __init__(self, sendQueue, hostQueue):
     self.sendQueue = sendQueue
     self.hostQueue = hostQueue
     self.thermometer_address = 0x5a
     self.thermometer = mlx90614(self.thermometer_address)
     self.m = max30102.MAX30102()
Beispiel #7
0
        if d[1]:
            ir_avg.append(d[0])
        if d[3]:
            red_avg.append(d[2])
    ir_D = (sum(ir_avg) - max(ir_avg) - min(ir_avg)) // len(ir_avg)
    red_D = (sum(red_avg) - max(red_avg) - min(red_avg)) // len(red_avg)
    print('ir:',ir_D)
    print('red:',red_D)
    return [ir_D,red_D]


################################################################



alert = Pin("PE0",Pin.OUT)
alert.on()
time.sleep(1)
alert.off()

while 1:
    try:
        m = max30102.MAX30102(pin='PE1')
    except:
        print("init error and retry ..")
        time.sleep(1)


[ir_D,red_D] = get(1000)