public void set_spo_config(SAMPLE_RATE sample_rate = SAMPLE_RATE.R100, PULSE_WIDTH pulse_width = PULSE_WIDTH.P1600) { var reg = Get(SPO2_CONFIG); reg = reg & 0xFC; // Set LED pulsewidth to 00 Set(SPO2_CONFIG, (byte)(reg | (int)pulse_width)); }
public Max30100(byte mode = MODE_HR, SAMPLE_RATE sample_rate = SAMPLE_RATE.R100, LED_CURRENT led_current_red = LED_CURRENT.L11_0, LED_CURRENT led_current_ir = LED_CURRENT.L11_0, PULSE_WIDTH pulse_width = PULSE_WIDTH.P1600, int max_buffer_len = 10000 ) { new Thread(new ThreadStart(delegate { var list = new List <int[]>(); int count = 0; while (Program.appRun) { if (Program.pause) { Thread.Sleep(2000); if (isStart) { shutdown(); } } else { if (!isStart) { start(); } var data = read_sensor(); if (data == null) { continue; } list.Insert(0, data); list = list.Take(10).ToList(); var hasfinger = list.Count(i => i[0] == 0) < 2; HasFinger = hasfinger; if (count == 10) { if (HasFinger) { var moyenIR = (int)list.Average(i => i[0]); var ir = moyenIR / 100 - 40; IR = ir > 90 ? 90 : ir < 40 ? 0 : ir; var red = (int)(((double)(data[1] / 10000.0) - 0.05) * 100.0); RED = IR == 0 ? 0 : (red > 100 ? 100 : red < 0 ? 0 : red) - 1; } else { IR = RED = 0; } } count++; if (count >= 11) { count = 0; } } } })).Start(); }