This is the latest working repository used in our demo video for the Maxim to display temperature readings on Bluetooth

Dependencies:   USBDevice

Committer:
darienf
Date:
Sat Apr 10 03:05:42 2021 +0000
Revision:
3:36de8b9e4b1a
ayoooo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
darienf 3:36de8b9e4b1a 1 /*******************************************************************************
darienf 3:36de8b9e4b1a 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved.
darienf 3:36de8b9e4b1a 3 *
darienf 3:36de8b9e4b1a 4 * This software is protected by copyright laws of the United States and
darienf 3:36de8b9e4b1a 5 * of foreign countries. This material may also be protected by patent laws
darienf 3:36de8b9e4b1a 6 * and technology transfer regulations of the United States and of foreign
darienf 3:36de8b9e4b1a 7 * countries. This software is furnished under a license agreement and/or a
darienf 3:36de8b9e4b1a 8 * nondisclosure agreement and may only be used or reproduced in accordance
darienf 3:36de8b9e4b1a 9 * with the terms of those agreements. Dissemination of this information to
darienf 3:36de8b9e4b1a 10 * any party or parties not specified in the license agreement and/or
darienf 3:36de8b9e4b1a 11 * nondisclosure agreement is expressly prohibited.
darienf 3:36de8b9e4b1a 12 *
darienf 3:36de8b9e4b1a 13 * The above copyright notice and this permission notice shall be included
darienf 3:36de8b9e4b1a 14 * in all copies or substantial portions of the Software.
darienf 3:36de8b9e4b1a 15 *
darienf 3:36de8b9e4b1a 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
darienf 3:36de8b9e4b1a 17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
darienf 3:36de8b9e4b1a 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
darienf 3:36de8b9e4b1a 19 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
darienf 3:36de8b9e4b1a 20 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
darienf 3:36de8b9e4b1a 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
darienf 3:36de8b9e4b1a 22 * OTHER DEALINGS IN THE SOFTWARE.
darienf 3:36de8b9e4b1a 23 *
darienf 3:36de8b9e4b1a 24 * Except as contained in this notice, the name of Maxim Integrated
darienf 3:36de8b9e4b1a 25 * Products, Inc. shall not be used except as stated in the Maxim Integrated
darienf 3:36de8b9e4b1a 26 * Products, Inc. Branding Policy.
darienf 3:36de8b9e4b1a 27 *
darienf 3:36de8b9e4b1a 28 * The mere transfer of this software does not imply any licenses
darienf 3:36de8b9e4b1a 29 * of trade secrets, proprietary technology, copyrights, patents,
darienf 3:36de8b9e4b1a 30 * trademarks, maskwork rights, or any other form of intellectual
darienf 3:36de8b9e4b1a 31 * property whatsoever. Maxim Integrated Products, Inc. retains all
darienf 3:36de8b9e4b1a 32 * ownership rights.
darienf 3:36de8b9e4b1a 33 *******************************************************************************
darienf 3:36de8b9e4b1a 34 */
darienf 3:36de8b9e4b1a 35
darienf 3:36de8b9e4b1a 36 using System;
darienf 3:36de8b9e4b1a 37 using System.Collections.Generic;
darienf 3:36de8b9e4b1a 38 using System.Linq;
darienf 3:36de8b9e4b1a 39 using System.Text;
darienf 3:36de8b9e4b1a 40
darienf 3:36de8b9e4b1a 41 namespace HealthSensorPlatform
darienf 3:36de8b9e4b1a 42 {
darienf 3:36de8b9e4b1a 43
darienf 3:36de8b9e4b1a 44 public partial class HspForm
darienf 3:36de8b9e4b1a 45 {
darienf 3:36de8b9e4b1a 46 List<RegisterField> paceChannelField = new List<RegisterField>();
darienf 3:36de8b9e4b1a 47
darienf 3:36de8b9e4b1a 48 void initalizePaceChannelFields()
darienf 3:36de8b9e4b1a 49 {
darienf 3:36de8b9e4b1a 50 // Pace Channel
darienf 3:36de8b9e4b1a 51 string[] aoutLbwOptions = { "Max (~100 kHz)*", "Limited (16 kHz)" };
darienf 3:36de8b9e4b1a 52 string[] aoutOptions = { "Disabled*", "INA Output", "PGA Output", "Pace Input" };
darienf 3:36de8b9e4b1a 53 string[] polOptions = { "Non-Inverted*", "Inverted" };
darienf 3:36de8b9e4b1a 54 string[] gainOptions = { "540 / 50.625 / 202.50*",
darienf 3:36de8b9e4b1a 55 "270 / 50.625 / 101.25",
darienf 3:36de8b9e4b1a 56 "240 / 22.5 / 90",
darienf 3:36de8b9e4b1a 57 "120 / 22.5 / 45",
darienf 3:36de8b9e4b1a 58 " 60 / 5.625 / 22.5",
darienf 3:36de8b9e4b1a 59 " 30 / 5.625 / 11.25",
darienf 3:36de8b9e4b1a 60 " 26.4 / 5.625 / 22.5",
darienf 3:36de8b9e4b1a 61 " 13.2 / 5.625 / 11.25"
darienf 3:36de8b9e4b1a 62 };
darienf 3:36de8b9e4b1a 63 string[] gnDiffOffOptions = { "Differentiator*", "Sample and Hold" };
darienf 3:36de8b9e4b1a 64 string[] dacpOptions = new string[16];
darienf 3:36de8b9e4b1a 65 for (int i = 0; i < dacpOptions.Length; i++)
darienf 3:36de8b9e4b1a 66 {
darienf 3:36de8b9e4b1a 67 dacpOptions[i] = (22.5 * i).ToString() + " mV";
darienf 3:36de8b9e4b1a 68 }
darienf 3:36de8b9e4b1a 69 dacpOptions[5] += "*";
darienf 3:36de8b9e4b1a 70 string[] dacnOptions = new string[16];
darienf 3:36de8b9e4b1a 71 for (int i = 0; i < dacnOptions.Length; i++)
darienf 3:36de8b9e4b1a 72 {
darienf 3:36de8b9e4b1a 73 dacnOptions[i] = (-22.5 * i).ToString() + " mV";
darienf 3:36de8b9e4b1a 74 }
darienf 3:36de8b9e4b1a 75 dacnOptions[5] += "*";
darienf 3:36de8b9e4b1a 76
darienf 3:36de8b9e4b1a 77 //RegisterField rateField = new RegisterField { Name = "BIOZ_RATE", Register = 0x18, Index = 23, Width = 1, Descriptions = rateOptions, Label = lblBioZSampleRate, Control = cboBioZSampleRate };
darienf 3:36de8b9e4b1a 78 RegisterField polField = new RegisterField { Name = "PACE_POL", Register = 0x1A, Index = 23, Width = 1, Descriptions = polOptions, Label = lblPaceInputPolarity, Control = cboPaceInputPolarity, Device = max30001 };
darienf 3:36de8b9e4b1a 79 RegisterField gnDiffOffField = new RegisterField { Name = "PACE_GN_DIFF_OFF", Register = 0x1A, Index = 19, Width = 1, Descriptions = gnDiffOffOptions, Label = lblPaceDifferentiatorMode, Control = cboPaceDifferentiatorMode, Device = max30001 };
darienf 3:36de8b9e4b1a 80 RegisterField gainField = new RegisterField { Name = "PACE_GAIN", Register = 0x1A, Index = 16, Width = 3, Descriptions = gainOptions, Label = lblPaceChannelGain, Control = cboPaceChannelGain, Device = max30001 };
darienf 3:36de8b9e4b1a 81 RegisterField aoutLbwField = new RegisterField { Name = "PACE_AOUT_LBW", Register = 0x1A, Index = 14, Width = 1, Descriptions = aoutLbwOptions, Label = lblPaceBufferBandwidth, Control = cboPaceBufferBandwidth, Device = max30001 };
darienf 3:36de8b9e4b1a 82 RegisterField aoutField = new RegisterField { Name = "PACE_AOUT", Register = 0x1A, Index = 12, Width = 2, Descriptions = aoutOptions, Label = lblPaceSignalSelection, Control = cboPaceSignalSelection, Device = max30001 };
darienf 3:36de8b9e4b1a 83 RegisterField dacpField = new RegisterField { Name = "PACE_DACP", Register = 0x1A, Index = 4, Width = 4, Descriptions = dacpOptions, Label = lblPaceDetectorPostiveThreshold, Control = cboPaceDetectorPostiveThreshold, Device = max30001 };
darienf 3:36de8b9e4b1a 84 RegisterField dacnField = new RegisterField { Name = "PACE_DACN", Register = 0x1A, Index = 0, Width = 4, Descriptions = dacnOptions, Label = lblPaceDetectorNegativeThreshold, Control = cboPaceDetectorNegativeThreshold, Device = max30001 };
darienf 3:36de8b9e4b1a 85 paceChannelField.Add(polField);
darienf 3:36de8b9e4b1a 86 paceChannelField.Add(gnDiffOffField);
darienf 3:36de8b9e4b1a 87 paceChannelField.Add(gainField);
darienf 3:36de8b9e4b1a 88 paceChannelField.Add(aoutLbwField);
darienf 3:36de8b9e4b1a 89 paceChannelField.Add(aoutField);
darienf 3:36de8b9e4b1a 90 paceChannelField.Add(dacpField);
darienf 3:36de8b9e4b1a 91 paceChannelField.Add(dacnField);
darienf 3:36de8b9e4b1a 92
darienf 3:36de8b9e4b1a 93 // BioZ Channel
darienf 3:36de8b9e4b1a 94 string[] aHpfOptions = { "250 Hz", "500 Hz", "1000 Hz*", "2000 Hz", "4000 Hz", "8000 Hz", "Bypass" };
darienf 3:36de8b9e4b1a 95 RegisterField aHpfField = new RegisterField { Name = "BIOZ_AHPF", Register = 0x18, Index = 20, Width = 3, Descriptions = aHpfOptions, Label = lblPaceAnalogHpf, Control = cboPaceAnalogHpf, Device = max30001 };
darienf 3:36de8b9e4b1a 96 paceChannelField.Add(aHpfField);
darienf 3:36de8b9e4b1a 97 }
darienf 3:36de8b9e4b1a 98
darienf 3:36de8b9e4b1a 99 void PaceChannelUpdateRegisters()
darienf 3:36de8b9e4b1a 100 {
darienf 3:36de8b9e4b1a 101 internalUpdate = true;
darienf 3:36de8b9e4b1a 102 ReadComboBoxesRegisters(paceChannelField);
darienf 3:36de8b9e4b1a 103 internalUpdate = false;
darienf 3:36de8b9e4b1a 104 }
darienf 3:36de8b9e4b1a 105
darienf 3:36de8b9e4b1a 106 private CustomControls.InitArgs.PACEInitStart getPaceArgs()
darienf 3:36de8b9e4b1a 107 {
darienf 3:36de8b9e4b1a 108 CustomControls.InitArgs.PACEInitStart paceArgs = new CustomControls.InitArgs.PACEInitStart();
darienf 3:36de8b9e4b1a 109
darienf 3:36de8b9e4b1a 110 paceArgs.En_pace = chkEnPace.Checked == true ? 1 : 0;
darienf 3:36de8b9e4b1a 111 paceArgs.Clr_pedge = 0; // TODO default from jerry
darienf 3:36de8b9e4b1a 112 paceArgs.Pol = cboPaceInputPolarity.SelectedIndex;
darienf 3:36de8b9e4b1a 113 paceArgs.Gn_diff_off = cboPaceDifferentiatorMode.SelectedIndex;
darienf 3:36de8b9e4b1a 114 paceArgs.Gain = cboPaceChannelGain.SelectedIndex;
darienf 3:36de8b9e4b1a 115 paceArgs.Aout_lbw = cboPaceBufferBandwidth.SelectedIndex;
darienf 3:36de8b9e4b1a 116 paceArgs.Aout = cboPaceSignalSelection.SelectedIndex;
darienf 3:36de8b9e4b1a 117 paceArgs.Dacp = cboPaceDetectorPostiveThreshold.SelectedIndex;
darienf 3:36de8b9e4b1a 118 paceArgs.Dacn = cboPaceDetectorNegativeThreshold.SelectedIndex;
darienf 3:36de8b9e4b1a 119
darienf 3:36de8b9e4b1a 120 return paceArgs;
darienf 3:36de8b9e4b1a 121 }
darienf 3:36de8b9e4b1a 122
darienf 3:36de8b9e4b1a 123 private void setPaceArgs(CustomControls.InitArgs.PACEInitStart paceArgs)
darienf 3:36de8b9e4b1a 124 {
darienf 3:36de8b9e4b1a 125 //paceArgs.En_pace = chkEnPace.Checked == true ? 1 : 0;
darienf 3:36de8b9e4b1a 126 //paceArgs.Clr_pedge = 0; // TODO default from jerry
darienf 3:36de8b9e4b1a 127 cboPaceInputPolarity.SelectedIndex = paceArgs.Pol;
darienf 3:36de8b9e4b1a 128 cboPaceDifferentiatorMode.SelectedIndex = paceArgs.Gn_diff_off;
darienf 3:36de8b9e4b1a 129 cboPaceChannelGain.SelectedIndex = paceArgs.Gain;
darienf 3:36de8b9e4b1a 130 cboPaceBufferBandwidth.SelectedIndex = paceArgs.Aout_lbw;
darienf 3:36de8b9e4b1a 131 cboPaceSignalSelection.SelectedIndex = paceArgs.Aout;
darienf 3:36de8b9e4b1a 132 cboPaceDetectorPostiveThreshold.SelectedIndex = paceArgs.Dacp;
darienf 3:36de8b9e4b1a 133 cboPaceDetectorNegativeThreshold.SelectedIndex = paceArgs.Dacn;
darienf 3:36de8b9e4b1a 134 }
darienf 3:36de8b9e4b1a 135 }
darienf 3:36de8b9e4b1a 136 }