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 public partial class HspForm
darienf 3:36de8b9e4b1a 44 {
darienf 3:36de8b9e4b1a 45 List<RegisterField> bioZChannelField = new List<RegisterField>();
darienf 3:36de8b9e4b1a 46
darienf 3:36de8b9e4b1a 47 RegisterField bioZSampleRateField; // Needed for dynamic changing of options
darienf 3:36de8b9e4b1a 48 RegisterField bioZDlpfField;
darienf 3:36de8b9e4b1a 49 RegisterField bioZCgmagField;
darienf 3:36de8b9e4b1a 50
darienf 3:36de8b9e4b1a 51 string[][] bioZSampleRateOptions = new string[][]
darienf 3:36de8b9e4b1a 52 {
darienf 3:36de8b9e4b1a 53 new string[] { "64 sps*", "32 sps" },
darienf 3:36de8b9e4b1a 54 new string[] { "62.5 sps*", "31.25 sps" },
darienf 3:36de8b9e4b1a 55 new string[] { "50 sps*", "25 sps" },
darienf 3:36de8b9e4b1a 56 new string[] { "49.95 sps*", "24.98 sps" }
darienf 3:36de8b9e4b1a 57 };
darienf 3:36de8b9e4b1a 58
darienf 3:36de8b9e4b1a 59 string[][] bioZCgmagOptions = { new string[] { "Off*", "8 μA", "16 μA", "32 μA", "48 μA", "64 μA", "80 μA", "96 μA" },
darienf 3:36de8b9e4b1a 60 new string[] { "Off*", "8 μA", "16 μA", "32 μA", "48 μA", "64 μA", "80 μA" },
darienf 3:36de8b9e4b1a 61 new string[] { "Off*", "8 μA", "16 μA", "32 μA" },
darienf 3:36de8b9e4b1a 62 new string[] { "Off*", "8 μA", "16 μA" },
darienf 3:36de8b9e4b1a 63 new string[] { "Off*", "8 μA" }
darienf 3:36de8b9e4b1a 64 };
darienf 3:36de8b9e4b1a 65
darienf 3:36de8b9e4b1a 66 string[][][] bioZDlpfOptions;
darienf 3:36de8b9e4b1a 67
darienf 3:36de8b9e4b1a 68 void initalizeBioZConfigFields()
darienf 3:36de8b9e4b1a 69 {
darienf 3:36de8b9e4b1a 70 bioZDlpfOptions = new string[4][][];
darienf 3:36de8b9e4b1a 71
darienf 3:36de8b9e4b1a 72 for (int i = 0; i < 4; i++)
darienf 3:36de8b9e4b1a 73 {
darienf 3:36de8b9e4b1a 74 bioZDlpfOptions[i] = new string[2][];
darienf 3:36de8b9e4b1a 75 }
darienf 3:36de8b9e4b1a 76
darienf 3:36de8b9e4b1a 77 // 32768 Hz
darienf 3:36de8b9e4b1a 78 bioZDlpfOptions[0][0] = new string[] {"Bypass", "4.096 Hz*", "8.192 Hz", "16.384 Hz"};
darienf 3:36de8b9e4b1a 79 bioZDlpfOptions[0][1] = new string[] {"Bypass", "4.096 Hz*", "8.192 Hz"}; //, "4.096 Hz"};
darienf 3:36de8b9e4b1a 80 // 32000 Hz
darienf 3:36de8b9e4b1a 81 bioZDlpfOptions[1][0] = new string[] {"Bypass", "4.0 Hz*", "8.0 Hz", "16.0 Hz"};
darienf 3:36de8b9e4b1a 82 bioZDlpfOptions[1][1] = new string[] {"Bypass", "4.0 Hz*", "8.0 Hz"}; //, "4.0 Hz"};
darienf 3:36de8b9e4b1a 83 // 32000 Hz
darienf 3:36de8b9e4b1a 84 bioZDlpfOptions[2][0] = new string[] {"Bypass", "4.0 Hz*", "8.0 Hz", "16.0 Hz"};
darienf 3:36de8b9e4b1a 85 bioZDlpfOptions[2][1] = new string[] {"Bypass", "4.0 Hz*", "8.0 Hz"}; //, "4.0 Hz"};
darienf 3:36de8b9e4b1a 86 // 31968 Hz
darienf 3:36de8b9e4b1a 87 bioZDlpfOptions[3][0] = new string[] {"Bypass", "3.996 Hz*", "7.992 Hz", "15.984 Hz"};
darienf 3:36de8b9e4b1a 88 bioZDlpfOptions[3][1] = new string[] {"Bypass", "3.996 Hz*", "7.992 Hz"}; //, "3.996 Hz"};
darienf 3:36de8b9e4b1a 89
darienf 3:36de8b9e4b1a 90 string[] aHpfOptions = { "250 Hz", "500 Hz", "1000 Hz*", "2000 Hz", "4000 Hz", "8000 Hz", "Bypass" };
darienf 3:36de8b9e4b1a 91 string[] gainOptions = { "20 V/V*", "40 V/V", "80 V/V", "160 V/V" };
darienf 3:36de8b9e4b1a 92 string[] dlpfOptions = { "Bypass", "4 Hz*", "8 Hz", "16 Hz" };
darienf 3:36de8b9e4b1a 93 string[] dhpfOptions = { "Bypass (DC)*", "0.05 Hz", "0.50 Hz" };
darienf 3:36de8b9e4b1a 94
darienf 3:36de8b9e4b1a 95
darienf 3:36de8b9e4b1a 96 string[] fcgenOptions = { "4*FMSTR (~128 kHz)", "2*FMSTR (~80 kHz) - offset", "FMSTR (~40 kHz) - offset", "FMSTR/2 (~18 kHz) - offset",
darienf 3:36de8b9e4b1a 97 "FMSTR/4 (~8 kHz)", "FMSTR/8 (~4 kHz)", "FMSTR/16 (~2 kHz)", "FMSTR/32 (~1 kHz)",
darienf 3:36de8b9e4b1a 98 "FMSTR/64 (~500 Hz)*", "FMSTR/128 (~250 Hz)", "FMSTR/256 (~125 Hz)"};
darienf 3:36de8b9e4b1a 99 string[] cgmonOptions = { "Disabled*", "Enabled" };
darienf 3:36de8b9e4b1a 100 string[] extRbiasOptions = { "Internal*", "External" };
darienf 3:36de8b9e4b1a 101 string[] cgModeOptions = { "Unchopped w/ LPF*", "Chopped w/o LPF", "Chopped w/ LPF", "Chopped w/ Resistive CM" };
darienf 3:36de8b9e4b1a 102
darienf 3:36de8b9e4b1a 103 string[] enBloffOptions = { "Disabled*", "Under Range", "Over Range", "Under and Over Range" };
darienf 3:36de8b9e4b1a 104 string[] hiITOptions = new string[256];
darienf 3:36de8b9e4b1a 105 string[] loITOptions = new string[256];
darienf 3:36de8b9e4b1a 106
darienf 3:36de8b9e4b1a 107 for (int i = 0; i < hiITOptions.Length; i++)
darienf 3:36de8b9e4b1a 108 {
darienf 3:36de8b9e4b1a 109 hiITOptions[i] = "±2048 * " + i;
darienf 3:36de8b9e4b1a 110 loITOptions[i] = "±32 * " + i;
darienf 3:36de8b9e4b1a 111 }
darienf 3:36de8b9e4b1a 112 hiITOptions[255] += "*";
darienf 3:36de8b9e4b1a 113 loITOptions[255] += "*";
darienf 3:36de8b9e4b1a 114
darienf 3:36de8b9e4b1a 115 string[] phoffOptions = new string[16];
darienf 3:36de8b9e4b1a 116 for (int i = 0; i < phoffOptions.Length/4; i++)
darienf 3:36de8b9e4b1a 117 {
darienf 3:36de8b9e4b1a 118 phoffOptions[4 * i] = (11.25 * 4 * i).ToString() + "° (For all frequencies)";
darienf 3:36de8b9e4b1a 119 phoffOptions[4 * i + 1] = (11.25 * (4 * i + 1)).ToString() + "° (For <= 40kHz)";
darienf 3:36de8b9e4b1a 120 phoffOptions[4 * i + 2] = (11.25 * (4 * i + 2)).ToString() + "° (For <= 80kHz)";
darienf 3:36de8b9e4b1a 121 phoffOptions[4 * i + 3] = (11.25 * (4 * i + 3)).ToString() + "° (For <= 40kHz)";
darienf 3:36de8b9e4b1a 122 }
darienf 3:36de8b9e4b1a 123 phoffOptions[0] += "*";
darienf 3:36de8b9e4b1a 124
darienf 3:36de8b9e4b1a 125 string[] enDcloffOptions = { "Disabled*", "ECGP/N", "BIP/N" };
darienf 3:36de8b9e4b1a 126
darienf 3:36de8b9e4b1a 127 bioZSampleRateField = new RegisterField { Name = "BIOZ_RATE", Register = 0x18, Index = 23, Width = 1, Descriptions = bioZSampleRateOptions[0], Label = lblBioZSampleRate, Control = cboBioZSampleRate, Device = max30001 };
darienf 3:36de8b9e4b1a 128 RegisterField aHpfField = new RegisterField { Name = "BIOZ_AHPF", Register = 0x18, Index = 20, Width = 3, Descriptions = aHpfOptions, Label = lblBioZAnalogHpf, Control = cboBioZAnalogHpf, Device = max30001 };
darienf 3:36de8b9e4b1a 129 RegisterField rbiasField = new RegisterField { Name = "\nEXT_RBIAS", Register = 0x18, Index = 19, Width = 1, Descriptions = extRbiasOptions, Label = lblBioZExternalResistorBiasEnable, Control = cboBioZExternalResistorBiasEnable, Device = max30001 };
darienf 3:36de8b9e4b1a 130 RegisterField gainField = new RegisterField { Name = "BIOZ_GAIN", Register = 0x18, Index = 16, Width = 2, Descriptions = gainOptions, Label = lblBioZChannelGain, Control = cboBioZChannelGain, Device = max30001 };
darienf 3:36de8b9e4b1a 131 RegisterField digitalHpfField = new RegisterField { Name = "BIOZ_DHPF", Register = 0x18, Index = 14, Width = 2, Descriptions = dhpfOptions, Label = lblBioZDigitalHpf, Control = cboBioZDigitalHpf, Device = max30001 };
darienf 3:36de8b9e4b1a 132 bioZDlpfField = new RegisterField { Name = "BIOZ_DLPF", Register = 0x18, Index = 12, Width = 2, Descriptions = dlpfOptions, Label = lblBioZDigitalLpf, Control = cboBioZDigitalLpf, Device = max30001 };
darienf 3:36de8b9e4b1a 133 RegisterField fcgenField = new RegisterField { Name = "BIOZ_FCGEN", Register = 0x18, Index = 8, Width = 4, Descriptions = fcgenOptions, Label = lblBioZCurrentGeneratorFrequency, Control = cboBioZCurrentGeneratorFrequency, Device = max30001 };
darienf 3:36de8b9e4b1a 134 RegisterField cgmonField = new RegisterField { Name = "BIOZ_CGMON", Register = 0x18, Index = 7, Width = 1, Descriptions = cgmonOptions, Label = lblBioZCurrentGeneratorMonitor, Control = cboBioZCurrentGeneratorMonitor, Device = max30001 };
darienf 3:36de8b9e4b1a 135 bioZCgmagField = new RegisterField { Name = "BIOZ_CGMAG", Register = 0x18, Index = 4, Width = 3, Descriptions = bioZCgmagOptions[0], Label = lblBioZCurrentGeneratorMagnitude, Control = cboBioZCurrentGeneratorMagnitude, Device = max30001 };
darienf 3:36de8b9e4b1a 136 RegisterField phoffField = new RegisterField { Name = "\nBIOZ_PHOFF", Register = 0x18, Index = 0, Width = 4, Descriptions = phoffOptions, Label = lblBioZModulationPhaseOffset, Control = cboBioZModulationPhaseOffset, Device = max30001 };
darienf 3:36de8b9e4b1a 137 bioZChannelField.Add(bioZSampleRateField);
darienf 3:36de8b9e4b1a 138 bioZChannelField.Add(aHpfField);
darienf 3:36de8b9e4b1a 139 bioZChannelField.Add(rbiasField);
darienf 3:36de8b9e4b1a 140 bioZChannelField.Add(gainField);
darienf 3:36de8b9e4b1a 141 bioZChannelField.Add(digitalHpfField);
darienf 3:36de8b9e4b1a 142 bioZChannelField.Add(bioZDlpfField);
darienf 3:36de8b9e4b1a 143 bioZChannelField.Add(fcgenField);
darienf 3:36de8b9e4b1a 144 bioZChannelField.Add(cgmonField);
darienf 3:36de8b9e4b1a 145 bioZChannelField.Add(bioZCgmagField);
darienf 3:36de8b9e4b1a 146 bioZChannelField.Add(phoffField);
darienf 3:36de8b9e4b1a 147
darienf 3:36de8b9e4b1a 148 RegisterField cgmodeField = new RegisterField { Name = "BMUX_CG_MODE", Register = 0x17, Index = 12, Width = 2, Descriptions = cgModeOptions, Label = lblBioZCurrentGeneratorMode, Control = cboBioZCurrentGeneratorMode, Device = max30001 };
darienf 3:36de8b9e4b1a 149 RegisterField enDcloffField = new RegisterField { Name = "EN_BLOFF", Register = 0x10, Index = 14, Width = 2, Descriptions = enBloffOptions, Label = lblBioZDigitalLeadOffDetectionEnable, Control = cboBioZDigitalLeadOffDetectionEnable, Device = max30001 };
darienf 3:36de8b9e4b1a 150 RegisterField bloffHiItField = new RegisterField { Name = "BLOFF_HI_IT", Register = 0x05, Index = 8, Width = 8, Descriptions = hiITOptions, Label = lblBioZACLeadOffOverRangeThreshold, Control = cboBioZACLeadOffOverRangeThreshold, Device = max30001 };
darienf 3:36de8b9e4b1a 151 RegisterField bloffLoItField = new RegisterField { Name = "BLOFF_LO_IT", Register = 0x05, Index = 0, Width = 8, Descriptions = loITOptions, Label = lblBioZACLeadOffUnderRangeThreshold, Control = cboBioZACLeadOffUnderRangeThreshold, Device = max30001 };
darienf 3:36de8b9e4b1a 152 bioZChannelField.Add(cgmodeField);
darienf 3:36de8b9e4b1a 153 bioZChannelField.Add(enDcloffField);
darienf 3:36de8b9e4b1a 154 bioZChannelField.Add(bloffHiItField);
darienf 3:36de8b9e4b1a 155 bioZChannelField.Add(bloffLoItField);
darienf 3:36de8b9e4b1a 156 }
darienf 3:36de8b9e4b1a 157
darienf 3:36de8b9e4b1a 158 void BioZChannelUpdateRegisters()
darienf 3:36de8b9e4b1a 159 {
darienf 3:36de8b9e4b1a 160 internalUpdate = true;
darienf 3:36de8b9e4b1a 161 ReadComboBoxesRegisters(bioZChannelField);
darienf 3:36de8b9e4b1a 162 internalUpdate = false;
darienf 3:36de8b9e4b1a 163 }
darienf 3:36de8b9e4b1a 164
darienf 3:36de8b9e4b1a 165 private CustomControls.InitArgs.BIOZInitStart getBioZArgs()
darienf 3:36de8b9e4b1a 166 {
darienf 3:36de8b9e4b1a 167 CustomControls.InitArgs.BIOZInitStart biozArgs = new CustomControls.InitArgs.BIOZInitStart();
darienf 3:36de8b9e4b1a 168
darienf 3:36de8b9e4b1a 169 biozArgs.Openp = cboBioZBmuxOpenp.SelectedIndex;
darienf 3:36de8b9e4b1a 170 biozArgs.Openn = cboBioZBmuxOpenn.SelectedIndex;
darienf 3:36de8b9e4b1a 171 biozArgs.Calp_sel = cboBioZBmuxCalpSel.SelectedIndex;
darienf 3:36de8b9e4b1a 172 biozArgs.Caln_sel = cboBioZBmuxCalnSel.SelectedIndex;
darienf 3:36de8b9e4b1a 173 biozArgs.CG_mode = cboBioZCurrentGeneratorMode.SelectedIndex;
darienf 3:36de8b9e4b1a 174 biozArgs.En_bioz = chkEnBioZ.Checked == true ? 1 : 0;
darienf 3:36de8b9e4b1a 175 biozArgs.B_fit = 7; // comboBox39.SelectedIndex;
darienf 3:36de8b9e4b1a 176 biozArgs.Rate = cboBioZSampleRate.SelectedIndex;
darienf 3:36de8b9e4b1a 177 biozArgs.Ahpf = cboBioZAnalogHpf.SelectedIndex;
darienf 3:36de8b9e4b1a 178 biozArgs.Ext_rbias = cboBioZExternalResistorBiasEnable.SelectedIndex;
darienf 3:36de8b9e4b1a 179 biozArgs.Gain = cboBioZChannelGain.SelectedIndex;
darienf 3:36de8b9e4b1a 180 biozArgs.Dhpf = cboBioZDigitalHpf.SelectedIndex;
darienf 3:36de8b9e4b1a 181 biozArgs.Dlpf = cboBioZDigitalLpf.SelectedIndex;
darienf 3:36de8b9e4b1a 182 biozArgs.Fcgen = cboBioZCurrentGeneratorFrequency.SelectedIndex;
darienf 3:36de8b9e4b1a 183 biozArgs.Cgmon = cboBioZCurrentGeneratorMonitor.SelectedIndex;
darienf 3:36de8b9e4b1a 184 biozArgs.Cgmag = cboBioZCurrentGeneratorMagnitude.SelectedIndex;
darienf 3:36de8b9e4b1a 185 biozArgs.Phoff = cboBioZModulationPhaseOffset.SelectedIndex;
darienf 3:36de8b9e4b1a 186
darienf 3:36de8b9e4b1a 187 return biozArgs;
darienf 3:36de8b9e4b1a 188 }
darienf 3:36de8b9e4b1a 189
darienf 3:36de8b9e4b1a 190 private void setBioZArgs(CustomControls.InitArgs.BIOZInitStart biozArgs)
darienf 3:36de8b9e4b1a 191 {
darienf 3:36de8b9e4b1a 192 cboBioZBmuxOpenp.SelectedIndex = biozArgs.Openp;
darienf 3:36de8b9e4b1a 193 cboBioZBmuxOpenn.SelectedIndex = biozArgs.Openn;
darienf 3:36de8b9e4b1a 194 cboBioZBmuxCalpSel.SelectedIndex = biozArgs.Calp_sel;
darienf 3:36de8b9e4b1a 195 cboBioZBmuxCalnSel.SelectedIndex = biozArgs.Caln_sel;
darienf 3:36de8b9e4b1a 196 cboBioZCurrentGeneratorMode.SelectedIndex = biozArgs.CG_mode;
darienf 3:36de8b9e4b1a 197 //biozArgs.En_bioz = chkEnBioZ.Checked == true ? 1 : 0;
darienf 3:36de8b9e4b1a 198 //biozArgs.B_fit = 7; // comboBox39.SelectedIndex;
darienf 3:36de8b9e4b1a 199 cboBioZSampleRate.SelectedIndex = biozArgs.Rate;
darienf 3:36de8b9e4b1a 200 cboBioZAnalogHpf.SelectedIndex = biozArgs.Ahpf;
darienf 3:36de8b9e4b1a 201 cboBioZExternalResistorBiasEnable.SelectedIndex = biozArgs.Ext_rbias;
darienf 3:36de8b9e4b1a 202 cboBioZChannelGain.SelectedIndex = biozArgs.Gain;
darienf 3:36de8b9e4b1a 203 cboBioZDigitalHpf.SelectedIndex = biozArgs.Dhpf;
darienf 3:36de8b9e4b1a 204 cboBioZDigitalLpf.SelectedIndex = biozArgs.Dlpf;
darienf 3:36de8b9e4b1a 205 cboBioZCurrentGeneratorFrequency.SelectedIndex = biozArgs.Fcgen;
darienf 3:36de8b9e4b1a 206 cboBioZCurrentGeneratorMonitor.SelectedIndex = biozArgs.Cgmon;
darienf 3:36de8b9e4b1a 207 cboBioZCurrentGeneratorMagnitude.SelectedIndex = biozArgs.Cgmag;
darienf 3:36de8b9e4b1a 208 cboBioZModulationPhaseOffset.SelectedIndex = biozArgs.Phoff;
darienf 3:36de8b9e4b1a 209 }
darienf 3:36de8b9e4b1a 210
darienf 3:36de8b9e4b1a 211 public string BioZSettingString()
darienf 3:36de8b9e4b1a 212 {
darienf 3:36de8b9e4b1a 213 StringBuilder sb = new StringBuilder();
darienf 3:36de8b9e4b1a 214
darienf 3:36de8b9e4b1a 215 foreach(RegisterField rf in bioZChannelField)
darienf 3:36de8b9e4b1a 216 {
darienf 3:36de8b9e4b1a 217 sb.Append(rf.Label.Text.Replace("\n", String.Empty));
darienf 3:36de8b9e4b1a 218 sb.Append(" = ");
darienf 3:36de8b9e4b1a 219 sb.Append(((MaximStyle.MaximComboBox)rf.Control).SelectedItem);
darienf 3:36de8b9e4b1a 220 sb.Append(", ");
darienf 3:36de8b9e4b1a 221 }
darienf 3:36de8b9e4b1a 222
darienf 3:36de8b9e4b1a 223 return sb.ToString();
darienf 3:36de8b9e4b1a 224 }
darienf 3:36de8b9e4b1a 225
darienf 3:36de8b9e4b1a 226 public string EcgSettingString()
darienf 3:36de8b9e4b1a 227 {
darienf 3:36de8b9e4b1a 228 StringBuilder sb = new StringBuilder();
darienf 3:36de8b9e4b1a 229
darienf 3:36de8b9e4b1a 230 foreach (RegisterField rf in ecgChannelField)
darienf 3:36de8b9e4b1a 231 {
darienf 3:36de8b9e4b1a 232 sb.Append(rf.Label.Text.Replace("\n", String.Empty));
darienf 3:36de8b9e4b1a 233 sb.Append(" = ");
darienf 3:36de8b9e4b1a 234 sb.Append(((MaximStyle.MaximComboBox)rf.Control).SelectedItem);
darienf 3:36de8b9e4b1a 235 sb.Append(", ");
darienf 3:36de8b9e4b1a 236 }
darienf 3:36de8b9e4b1a 237
darienf 3:36de8b9e4b1a 238 return sb.ToString();
darienf 3:36de8b9e4b1a 239 }
darienf 3:36de8b9e4b1a 240
darienf 3:36de8b9e4b1a 241
darienf 3:36de8b9e4b1a 242 private void cboBioZChannelGain_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 243 {
darienf 3:36de8b9e4b1a 244 MaximStyle.MaximComboBox cbox = (MaximStyle.MaximComboBox)sender;
darienf 3:36de8b9e4b1a 245
darienf 3:36de8b9e4b1a 246 switch (cbox.SelectedIndex)
darienf 3:36de8b9e4b1a 247 {
darienf 3:36de8b9e4b1a 248 case 0:
darienf 3:36de8b9e4b1a 249 ecgView1.GainBioZ = 20;
darienf 3:36de8b9e4b1a 250 break;
darienf 3:36de8b9e4b1a 251 case 1:
darienf 3:36de8b9e4b1a 252 ecgView1.GainBioZ = 40;
darienf 3:36de8b9e4b1a 253 break;
darienf 3:36de8b9e4b1a 254 case 2:
darienf 3:36de8b9e4b1a 255 ecgView1.GainBioZ = 80;
darienf 3:36de8b9e4b1a 256 break;
darienf 3:36de8b9e4b1a 257 case 3:
darienf 3:36de8b9e4b1a 258 ecgView1.GainBioZ = 160;
darienf 3:36de8b9e4b1a 259 break;
darienf 3:36de8b9e4b1a 260 }
darienf 3:36de8b9e4b1a 261 }
darienf 3:36de8b9e4b1a 262
darienf 3:36de8b9e4b1a 263 private void cboBioZCurrentGeneratorMagnitude_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 264 {
darienf 3:36de8b9e4b1a 265 MaximStyle.MaximComboBox cbox = (MaximStyle.MaximComboBox)sender;
darienf 3:36de8b9e4b1a 266 int[] currents = { 0, 8, 16, 32, 48, 64, 80, 96 };
darienf 3:36de8b9e4b1a 267
darienf 3:36de8b9e4b1a 268 // Equation for Hex code to current magnitude
darienf 3:36de8b9e4b1a 269 ecgView1.CurrentBioZ = currents[cbox.SelectedIndex];
darienf 3:36de8b9e4b1a 270 }
darienf 3:36de8b9e4b1a 271
darienf 3:36de8b9e4b1a 272 private void cboBioZSampleRate_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 273 {
darienf 3:36de8b9e4b1a 274 MaximStyle.MaximComboBox cbo = (MaximStyle.MaximComboBox)sender;
darienf 3:36de8b9e4b1a 275 double[][] sampleRates = new double[][]
darienf 3:36de8b9e4b1a 276 {
darienf 3:36de8b9e4b1a 277 new double[] {64, 32},
darienf 3:36de8b9e4b1a 278 new double[] {62.5, 31.25},
darienf 3:36de8b9e4b1a 279 new double[] {50, 25},
darienf 3:36de8b9e4b1a 280 new double[] {49.95, 24.98}
darienf 3:36de8b9e4b1a 281 };
darienf 3:36de8b9e4b1a 282
darienf 3:36de8b9e4b1a 283 if (connected && !internalUpdate)
darienf 3:36de8b9e4b1a 284 writeComboBox(cbo);
darienf 3:36de8b9e4b1a 285
darienf 3:36de8b9e4b1a 286 if (cboMasterClock.SelectedIndex > -1 && cbo.SelectedIndex > -1 && cboBioZDigitalLpf.SelectedIndex > -1) // All boxes are init
darienf 3:36de8b9e4b1a 287 {
darienf 3:36de8b9e4b1a 288 ecgView1.SampleRateBioZ = sampleRates[cboMasterClock.SelectedIndex][cbo.SelectedIndex];
darienf 3:36de8b9e4b1a 289
darienf 3:36de8b9e4b1a 290 cboBioZDigitalLpf.Items.Clear();
darienf 3:36de8b9e4b1a 291 bioZDlpfField.Descriptions = bioZDlpfOptions[cboMasterClock.SelectedIndex][cboBioZSampleRate.SelectedIndex];
darienf 3:36de8b9e4b1a 292 bioZDlpfField.Control = cboBioZDigitalLpf; // Trigger update of descriptions
darienf 3:36de8b9e4b1a 293
darienf 3:36de8b9e4b1a 294 cboBioZDigitalLpf.SelectedIndex = bioZDlpfField.ReadField();
darienf 3:36de8b9e4b1a 295
darienf 3:36de8b9e4b1a 296 }
darienf 3:36de8b9e4b1a 297 }
darienf 3:36de8b9e4b1a 298
darienf 3:36de8b9e4b1a 299 private void cboBioZCurrentGeneratorFrequency_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 300 {
darienf 3:36de8b9e4b1a 301 string[] currentOptions;
darienf 3:36de8b9e4b1a 302 switch (cboBioZCurrentGeneratorFrequency.SelectedIndex)
darienf 3:36de8b9e4b1a 303 {
darienf 3:36de8b9e4b1a 304 case 0:
darienf 3:36de8b9e4b1a 305 case 1:
darienf 3:36de8b9e4b1a 306 case 2:
darienf 3:36de8b9e4b1a 307 case 3:
darienf 3:36de8b9e4b1a 308 currentOptions = bioZCgmagOptions[0];
darienf 3:36de8b9e4b1a 309 break;
darienf 3:36de8b9e4b1a 310 case 4:
darienf 3:36de8b9e4b1a 311 currentOptions = bioZCgmagOptions[1];
darienf 3:36de8b9e4b1a 312 break;
darienf 3:36de8b9e4b1a 313 case 5:
darienf 3:36de8b9e4b1a 314 currentOptions = bioZCgmagOptions[2];
darienf 3:36de8b9e4b1a 315 break;
darienf 3:36de8b9e4b1a 316 case 6:
darienf 3:36de8b9e4b1a 317 currentOptions = bioZCgmagOptions[3];
darienf 3:36de8b9e4b1a 318 break;
darienf 3:36de8b9e4b1a 319 default:
darienf 3:36de8b9e4b1a 320 currentOptions = bioZCgmagOptions[4];
darienf 3:36de8b9e4b1a 321 break;
darienf 3:36de8b9e4b1a 322 }
darienf 3:36de8b9e4b1a 323
darienf 3:36de8b9e4b1a 324 if (cboBioZCurrentGeneratorMagnitude.SelectedIndex >= currentOptions.Length) // Force user selection to be valid
darienf 3:36de8b9e4b1a 325 {
darienf 3:36de8b9e4b1a 326 cboBioZCurrentGeneratorMagnitude.SelectedIndex = currentOptions.Length - 1;
darienf 3:36de8b9e4b1a 327 }
darienf 3:36de8b9e4b1a 328 bioZCgmagField.Descriptions = currentOptions;
darienf 3:36de8b9e4b1a 329 bioZCgmagField.Control = cboBioZCurrentGeneratorMagnitude; // Repopulate drop down options
darienf 3:36de8b9e4b1a 330 }
darienf 3:36de8b9e4b1a 331
darienf 3:36de8b9e4b1a 332 private void cboBioZDigitalLeadOffDetectionEnable_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 333 {
darienf 3:36de8b9e4b1a 334 MaximStyle.MaximComboBox cbo = (MaximStyle.MaximComboBox)sender;
darienf 3:36de8b9e4b1a 335
darienf 3:36de8b9e4b1a 336 if (cbo.SelectedIndex == 0)
darienf 3:36de8b9e4b1a 337 ecgView1.EnableBioZOverUnderRange = false;
darienf 3:36de8b9e4b1a 338 else
darienf 3:36de8b9e4b1a 339 ecgView1.EnableBioZOverUnderRange = true;
darienf 3:36de8b9e4b1a 340 }
darienf 3:36de8b9e4b1a 341
darienf 3:36de8b9e4b1a 342 }
darienf 3:36de8b9e4b1a 343 }