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:
Sun May 02 23:09:04 2021 +0000
Revision:
5:bc128a16232f
Parent:
3:36de8b9e4b1a
This is the program that was last used, that has the working temperature and some comments

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;
darienf 3:36de8b9e4b1a 38 using System.Collections.Generic;
darienf 3:36de8b9e4b1a 39 using System.ComponentModel;
darienf 3:36de8b9e4b1a 40 using System.Data;
darienf 3:36de8b9e4b1a 41 using System.Drawing;
darienf 3:36de8b9e4b1a 42 using System.Linq;
darienf 3:36de8b9e4b1a 43 using System.Text;
darienf 3:36de8b9e4b1a 44 using System.Windows.Forms;
darienf 3:36de8b9e4b1a 45 using HealthSensorPlatform.CustomControls;
darienf 3:36de8b9e4b1a 46 using HealthSensorPlatform;
darienf 3:36de8b9e4b1a 47
darienf 3:36de8b9e4b1a 48
darienf 3:36de8b9e4b1a 49 namespace HealthSensorPlatform
darienf 3:36de8b9e4b1a 50 {
darienf 3:36de8b9e4b1a 51 // Code for ECG Input Mux Tab
darienf 3:36de8b9e4b1a 52 public partial class HspForm
darienf 3:36de8b9e4b1a 53 {
darienf 3:36de8b9e4b1a 54 List<RegisterField> ecgInputMuxField = new List<RegisterField>();
darienf 3:36de8b9e4b1a 55
darienf 3:36de8b9e4b1a 56 // Needed for dynamic changing of options
darienf 3:36de8b9e4b1a 57 RegisterField ecgCalFiftyField;
darienf 3:36de8b9e4b1a 58
darienf 3:36de8b9e4b1a 59
darienf 3:36de8b9e4b1a 60 public int[] sw = new int[15];
darienf 3:36de8b9e4b1a 61
darienf 3:36de8b9e4b1a 62 void initalizeECGInputMuxFields()
darienf 3:36de8b9e4b1a 63 {
darienf 3:36de8b9e4b1a 64 string[] enDcloffOptions = { "Disabled*", "ECG Ch.", "BioZ Ch." };
darienf 3:36de8b9e4b1a 65 string[] dcloffIpolOptions = { "P: Pull Up, N: Pull Down*", "P: Pull Down, N: Pull Up" };
darienf 3:36de8b9e4b1a 66 string[] dcloffImagOptions = { "0nA/Disabled*", "5nA", "10nA", "20nA", "50nA", "100nA" };
darienf 3:36de8b9e4b1a 67 string[] dcloffVthOptions = { "VMID ±300mV*", "VMID ±400mV", "VMID ±450mV", "VMID ±500mV" };
darienf 3:36de8b9e4b1a 68
darienf 3:36de8b9e4b1a 69 string[] enUlpLonOptions = { "Disabled", "ECG Ch.", "BioZ Ch." };
darienf 3:36de8b9e4b1a 70
darienf 3:36de8b9e4b1a 71 string[] emuxOpenpOptions = { "Connected", "Isolated*" };
darienf 3:36de8b9e4b1a 72 string[] emuxOpennOptions = { "Connected", "Isolated*" };
darienf 3:36de8b9e4b1a 73 string[] emuxPolOptions = { "Non-Inverted*", "Inverted" };
darienf 3:36de8b9e4b1a 74
darienf 3:36de8b9e4b1a 75 string[] enRbiasOptions = { "Disabled*", "ECG Bias", "BIOZ Bias" };
darienf 3:36de8b9e4b1a 76 string[] rBiasvOptions = { "50MΩ", "100MΩ*", "200MΩ" };
darienf 3:36de8b9e4b1a 77 string[] rBiaspOptions = { "Disconnected*", "Connected" };
darienf 3:36de8b9e4b1a 78 string[] rBiasnOptions = { "Disconnected*", "Connected" };
darienf 3:36de8b9e4b1a 79
darienf 3:36de8b9e4b1a 80 string[] calEnVcalOptions = { "Disabled*", "Enabled" };
darienf 3:36de8b9e4b1a 81 string[] calVmodeOptions = { "Unipolar*", "Bipolar" };
darienf 3:36de8b9e4b1a 82 string[] calVmagOptions = { "0.25mV*", "0.50mV" };
darienf 3:36de8b9e4b1a 83 string[] calFcalOptions = { "FMSTR/128 (~256Hz)", "FMSTR/512 (~64Hz)", "FMSTR/2048 (~16Hz)", "FMSTR/8192 (~4Hz)",
darienf 3:36de8b9e4b1a 84 "FMSTR/2^15 (~1Hz)*", "FMSTR/2^17 (~1/4Hz)", "FMSTR/2^19 (~1/16Hz)", "FMSTR/2^21 (~1/64Hz)" };
darienf 3:36de8b9e4b1a 85 string[] calFiftyOptions = { "Time High", "50%*" };
darienf 3:36de8b9e4b1a 86 string[] calThighOptions = new string[2048/8]; // Assume FMSTR = 32768 Hz
darienf 3:36de8b9e4b1a 87 for (int i = 0; i < 2048/8; i++)
darienf 3:36de8b9e4b1a 88 {
darienf 3:36de8b9e4b1a 89 calThighOptions[i] = (30.52 * i * 8).ToString("F0") + " μs";
darienf 3:36de8b9e4b1a 90 }
darienf 3:36de8b9e4b1a 91 calThighOptions[0] += "*"; // Default
darienf 3:36de8b9e4b1a 92
darienf 3:36de8b9e4b1a 93 string[] calPSelOptions = { "None*", "VMID", "VCALP", "VCALN" };
darienf 3:36de8b9e4b1a 94 string[] calNSelOptions = calPSelOptions;
darienf 3:36de8b9e4b1a 95
darienf 3:36de8b9e4b1a 96 RegisterField enDcloffField = new RegisterField { Name = "\nEN_DCLOFF", Register = 0x10, Index = 12, Width = 2, Descriptions = enDcloffOptions, Label = lblEnDcloff, Control = cboEnDcloff , Device = max30001};
darienf 3:36de8b9e4b1a 97 RegisterField dcloffIpolField = new RegisterField { Name = "DCLOFF_IPOL", Register = 0x10, Index = 11, Width = 1, Descriptions = dcloffIpolOptions, Label = lblDcloffIpol, Control = cboDcloffIpol, Device = max30001 };
darienf 3:36de8b9e4b1a 98 RegisterField dcloffImagField = new RegisterField { Name = "DCLOFF_IMAG", Register = 0x10, Index = 8, Width = 3, Descriptions = dcloffImagOptions, Label = lblDcloffImag, Control = cboDcloffImag, Device = max30001 };
darienf 3:36de8b9e4b1a 99 RegisterField dcloffVthField = new RegisterField { Name = "DCLOFF_VTH", Register = 0x10, Index = 6, Width = 2, Descriptions = dcloffVthOptions, Label = lblDcloffVth, Control = cboDcloffVth, Device = max30001};
darienf 3:36de8b9e4b1a 100 ecgInputMuxField.Add(enDcloffField);
darienf 3:36de8b9e4b1a 101 ecgInputMuxField.Add(dcloffIpolField);
darienf 3:36de8b9e4b1a 102 ecgInputMuxField.Add(dcloffImagField);
darienf 3:36de8b9e4b1a 103 ecgInputMuxField.Add(dcloffVthField);
darienf 3:36de8b9e4b1a 104
darienf 3:36de8b9e4b1a 105 RegisterField enUlpLonField = new RegisterField { Name = "\nEN_ULP_LON", Register = 0x10, Index = 22, Width = 2, Descriptions = enDcloffOptions, Label = lblEmuxEnUlpLon, Control = cboEmuxEnUlpLon, Device = max30001};
darienf 3:36de8b9e4b1a 106 ecgInputMuxField.Add(enUlpLonField);
darienf 3:36de8b9e4b1a 107
darienf 3:36de8b9e4b1a 108
darienf 3:36de8b9e4b1a 109 RegisterField emuxOpenpField = new RegisterField { Name = "EMUX_OPENP", Register = 0x14, Index = 21, Width = 1, Descriptions = emuxOpenpOptions, Label = lblEmuxOpenp, Control = cboEmuxOpenp, Device = max30001 };
darienf 3:36de8b9e4b1a 110 RegisterField emuxOpennField = new RegisterField { Name = "EMUX_OPENN", Register = 0x14, Index = 20, Width = 1, Descriptions = emuxOpennOptions, Label = lblEmuxOpenn, Control = cboEmuxOpenn, Device = max30001 };
darienf 3:36de8b9e4b1a 111 RegisterField emuxPolField = new RegisterField { Name = "EMUX_POL", Register = 0x14, Index = 23, Width = 1, Descriptions = emuxPolOptions, Label = lblEmuxPol, Control = cboEmuxPol, Device = max30001 };
darienf 3:36de8b9e4b1a 112 ecgInputMuxField.Add(emuxOpenpField);
darienf 3:36de8b9e4b1a 113 ecgInputMuxField.Add(emuxOpennField);
darienf 3:36de8b9e4b1a 114 ecgInputMuxField.Add(emuxPolField);
darienf 3:36de8b9e4b1a 115
darienf 3:36de8b9e4b1a 116 RegisterField enRbiasField = new RegisterField { Name = "\nEN_RBIAS", Register = 0x10, Index = 4, Width = 2, Descriptions = enDcloffOptions, Label = lblEnRbias, Control = cboEnRbias, Device = max30001 };
darienf 3:36de8b9e4b1a 117 RegisterField rBiasvField = new RegisterField { Name = "RBIASV", Register = 0x10, Index = 2, Width = 2, Descriptions = rBiasvOptions, Label = lblRbiasv, Control = cboRbiasv, Device = max30001 };
darienf 3:36de8b9e4b1a 118 RegisterField rBiaspField = new RegisterField { Name = "RBIASP", Register = 0x10, Index = 1, Width = 1, Descriptions = rBiaspOptions, Label = lblRbiasp, Control = cboRbiasp, Device = max30001 };
darienf 3:36de8b9e4b1a 119 RegisterField rBiasnField = new RegisterField { Name = "RBIASN", Register = 0x10, Index = 0, Width = 1, Descriptions = rBiasnOptions, Label = lblRbiasn, Control = cboRbiasn, Device = max30001 };
darienf 3:36de8b9e4b1a 120 ecgInputMuxField.Add(enRbiasField);
darienf 3:36de8b9e4b1a 121 ecgInputMuxField.Add(rBiasvField);
darienf 3:36de8b9e4b1a 122 ecgInputMuxField.Add(rBiaspField);
darienf 3:36de8b9e4b1a 123 ecgInputMuxField.Add(rBiasnField);
darienf 3:36de8b9e4b1a 124
darienf 3:36de8b9e4b1a 125 RegisterField calEnVcalField = new RegisterField { Name = "CAL_EN_VCAL", Register = 0x12, Index = 22, Width = 1, Descriptions = calEnVcalOptions, Label = lblCalEnVcal, Control = cboCalEnVcal, Device = max30001 };
darienf 3:36de8b9e4b1a 126 RegisterField calVmodeField = new RegisterField { Name = "CAL_VMODE", Register = 0x12, Index = 21, Width = 1, Descriptions = calVmodeOptions, Label = lblCalVMode, Control = cboCalVmode, Device = max30001 };
darienf 3:36de8b9e4b1a 127 RegisterField calVmagField = new RegisterField { Name = "CAL_VMAG", Register = 0x12, Index = 20, Width = 1, Descriptions = calVmagOptions, Label = lblCalVmag, Control = cboCalVmag, Device = max30001 };
darienf 3:36de8b9e4b1a 128 RegisterField calFcalField = new RegisterField { Name = "CAL_FCAL", Register = 0x12, Index = 12, Width = 3, Descriptions = calFcalOptions, Label = lblCalFreq, Control = cboCalFcal, Device = max30001 };
darienf 3:36de8b9e4b1a 129 ecgCalFiftyField = new RegisterField { Name = "CAL_FIFTY", Register = 0x12, Index = 11, Width = 1, Descriptions = calFiftyOptions, Label = lblCalFifty, Control = cboCalFifty, Device = max30001 };
darienf 3:36de8b9e4b1a 130 RegisterField calThighField = new RegisterField { Name = "CAL_THIGH", Register = 0x12, Index = 3, Width = 8, Descriptions = calThighOptions, Label = lblCalTHigh, Control = cboCalThigh, Device = max30001 };
darienf 3:36de8b9e4b1a 131 // Decreasing GUI options from 2048 to 256
darienf 3:36de8b9e4b1a 132 //RegisterField calThighField = new RegisterField { Name = "CAL_THIGH", Register = 0x12, Index = 0, Width = 10, Descriptions = calThighOptions, Label = lblCalTHigh };
darienf 3:36de8b9e4b1a 133 ecgInputMuxField.Add(calEnVcalField);
darienf 3:36de8b9e4b1a 134 ecgInputMuxField.Add(calVmodeField);
darienf 3:36de8b9e4b1a 135 ecgInputMuxField.Add(calVmagField);
darienf 3:36de8b9e4b1a 136 ecgInputMuxField.Add(calFcalField);
darienf 3:36de8b9e4b1a 137 ecgInputMuxField.Add(ecgCalFiftyField);
darienf 3:36de8b9e4b1a 138 ecgInputMuxField.Add(calThighField);
darienf 3:36de8b9e4b1a 139
darienf 3:36de8b9e4b1a 140 RegisterField calPSelField = new RegisterField { Name = "EMUX_CALP_SEL", Register = 0x14, Index = 18, Width = 2, Descriptions = calPSelOptions, Label = lblEmuxCalPSel, Control = cboEmuxCalPSel, Device = max30001 };
darienf 3:36de8b9e4b1a 141 RegisterField calNSelField = new RegisterField { Name = "EMUX_CALN_SEL", Register = 0x14, Index = 16, Width = 2, Descriptions = calNSelOptions, Label = lblEmuxCalNSel, Control = cboEmuxCalNSel, Device = max30001 };
darienf 3:36de8b9e4b1a 142 ecgInputMuxField.Add(calPSelField);
darienf 3:36de8b9e4b1a 143 ecgInputMuxField.Add(calNSelField);
darienf 3:36de8b9e4b1a 144 }
darienf 3:36de8b9e4b1a 145
darienf 3:36de8b9e4b1a 146 void ECGInputMuxUpdateRegisters()
darienf 3:36de8b9e4b1a 147 {
darienf 3:36de8b9e4b1a 148 internalUpdate = true;
darienf 3:36de8b9e4b1a 149 ReadComboBoxesRegisters(ecgInputMuxField);
darienf 3:36de8b9e4b1a 150 internalUpdate = false;
darienf 3:36de8b9e4b1a 151 }
darienf 3:36de8b9e4b1a 152
darienf 3:36de8b9e4b1a 153 private void cboCalFifty_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 154 {
darienf 3:36de8b9e4b1a 155 if (cboCalFifty.SelectedIndex == 1)
darienf 3:36de8b9e4b1a 156 {
darienf 3:36de8b9e4b1a 157 cboCalThigh.Enabled = false;
darienf 3:36de8b9e4b1a 158 }
darienf 3:36de8b9e4b1a 159 else
darienf 3:36de8b9e4b1a 160 {
darienf 3:36de8b9e4b1a 161 cboCalThigh.Enabled = true;
darienf 3:36de8b9e4b1a 162 }
darienf 3:36de8b9e4b1a 163 }
darienf 3:36de8b9e4b1a 164
darienf 3:36de8b9e4b1a 165 private void cboEnDcloff_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 166 {
darienf 3:36de8b9e4b1a 167 MaximStyle.MaximComboBox cbo = (MaximStyle.MaximComboBox)sender;
darienf 3:36de8b9e4b1a 168
darienf 3:36de8b9e4b1a 169 if (cbo.SelectedIndex == 0)
darienf 3:36de8b9e4b1a 170 {
darienf 3:36de8b9e4b1a 171 ecgView1.EnableDCLeadOff = false;
darienf 3:36de8b9e4b1a 172 }
darienf 3:36de8b9e4b1a 173 else
darienf 3:36de8b9e4b1a 174 {
darienf 3:36de8b9e4b1a 175 ecgView1.EnableDCLeadOff = true;
darienf 3:36de8b9e4b1a 176 if (cbo.SelectedIndex == 1)
darienf 3:36de8b9e4b1a 177 ecgView1.EnableEcgDCLeadOff = true;
darienf 3:36de8b9e4b1a 178 else
darienf 3:36de8b9e4b1a 179 ecgView1.EnableEcgDCLeadOff = false;
darienf 3:36de8b9e4b1a 180 }
darienf 3:36de8b9e4b1a 181
darienf 3:36de8b9e4b1a 182 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 183 }
darienf 3:36de8b9e4b1a 184
darienf 3:36de8b9e4b1a 185 private void cboDcloffIpol_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 186 {
darienf 3:36de8b9e4b1a 187 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 188 }
darienf 3:36de8b9e4b1a 189
darienf 3:36de8b9e4b1a 190 private void cboEmuxEnUlpLon_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 191 {
darienf 3:36de8b9e4b1a 192 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 193 }
darienf 3:36de8b9e4b1a 194
darienf 3:36de8b9e4b1a 195 private void cboEmuxOpenp_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 196 {
darienf 3:36de8b9e4b1a 197 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 198 }
darienf 3:36de8b9e4b1a 199
darienf 3:36de8b9e4b1a 200 private void cboEmuxOpenn_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 201 {
darienf 3:36de8b9e4b1a 202 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 203 }
darienf 3:36de8b9e4b1a 204
darienf 3:36de8b9e4b1a 205 private void cboEmuxPol_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 206 {
darienf 3:36de8b9e4b1a 207 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 208 }
darienf 3:36de8b9e4b1a 209
darienf 3:36de8b9e4b1a 210 private void cboEnRbias_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 211 {
darienf 3:36de8b9e4b1a 212 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 213 }
darienf 3:36de8b9e4b1a 214
darienf 3:36de8b9e4b1a 215 private void cboRbiasp_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 216 {
darienf 3:36de8b9e4b1a 217 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 218 }
darienf 3:36de8b9e4b1a 219
darienf 3:36de8b9e4b1a 220 private void cboRbiasn_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 221 {
darienf 3:36de8b9e4b1a 222 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 223 }
darienf 3:36de8b9e4b1a 224
darienf 3:36de8b9e4b1a 225 private void cboCalEnVcal_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 226 {
darienf 3:36de8b9e4b1a 227 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 228 }
darienf 3:36de8b9e4b1a 229
darienf 3:36de8b9e4b1a 230 private void cboEmuxCalPSel_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 231 {
darienf 3:36de8b9e4b1a 232 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 233 }
darienf 3:36de8b9e4b1a 234
darienf 3:36de8b9e4b1a 235 private void cboEmuxCalNSel_SelectedIndexChanged(object sender, EventArgs e)
darienf 3:36de8b9e4b1a 236 {
darienf 3:36de8b9e4b1a 237 redrawEcgMuxImage();
darienf 3:36de8b9e4b1a 238 }
darienf 3:36de8b9e4b1a 239
darienf 3:36de8b9e4b1a 240 private void redrawEcgMuxImage()
darienf 3:36de8b9e4b1a 241 {
darienf 3:36de8b9e4b1a 242 processSwitchState();
darienf 3:36de8b9e4b1a 243
darienf 3:36de8b9e4b1a 244 redrawSwitches();
darienf 3:36de8b9e4b1a 245 }
darienf 3:36de8b9e4b1a 246
darienf 3:36de8b9e4b1a 247 private void processSwitchState()
darienf 3:36de8b9e4b1a 248 {
darienf 3:36de8b9e4b1a 249 //Logic for panel 1
darienf 3:36de8b9e4b1a 250 if (cboEnDcloff.SelectedIndex == 1)
darienf 3:36de8b9e4b1a 251 {
darienf 3:36de8b9e4b1a 252 if (cboDcloffIpol.SelectedIndex == 0)
darienf 3:36de8b9e4b1a 253 {
darienf 3:36de8b9e4b1a 254 sw[1] = 0;
darienf 3:36de8b9e4b1a 255 sw[2] = 1;
darienf 3:36de8b9e4b1a 256 sw[10] = 1;
darienf 3:36de8b9e4b1a 257 sw[11] = 0;
darienf 3:36de8b9e4b1a 258 }
darienf 3:36de8b9e4b1a 259 else
darienf 3:36de8b9e4b1a 260 {
darienf 3:36de8b9e4b1a 261 sw[1] = 1;
darienf 3:36de8b9e4b1a 262 sw[2] = 0;
darienf 3:36de8b9e4b1a 263 sw[10] = 0;
darienf 3:36de8b9e4b1a 264 sw[11] = 1;
darienf 3:36de8b9e4b1a 265 }
darienf 3:36de8b9e4b1a 266 }
darienf 3:36de8b9e4b1a 267 else
darienf 3:36de8b9e4b1a 268 {
darienf 3:36de8b9e4b1a 269 sw[1] = 0;
darienf 3:36de8b9e4b1a 270 sw[2] = 0;
darienf 3:36de8b9e4b1a 271 sw[10] = 0;
darienf 3:36de8b9e4b1a 272 sw[11] = 0;
darienf 3:36de8b9e4b1a 273 }
darienf 3:36de8b9e4b1a 274 //Logic for panel 2
darienf 3:36de8b9e4b1a 275 if (cboEmuxEnUlpLon.SelectedIndex == 1)
darienf 3:36de8b9e4b1a 276 {
darienf 3:36de8b9e4b1a 277 sw[3] = 1;
darienf 3:36de8b9e4b1a 278 sw[12] = 1;
darienf 3:36de8b9e4b1a 279 }
darienf 3:36de8b9e4b1a 280 else
darienf 3:36de8b9e4b1a 281 {
darienf 3:36de8b9e4b1a 282 sw[3] = 0;
darienf 3:36de8b9e4b1a 283 sw[12] = 0;
darienf 3:36de8b9e4b1a 284 }
darienf 3:36de8b9e4b1a 285 //Logic for panel 3
darienf 3:36de8b9e4b1a 286 if (cboEmuxPol.SelectedIndex == 0)
darienf 3:36de8b9e4b1a 287 {
darienf 3:36de8b9e4b1a 288 sw[7] = 0;
darienf 3:36de8b9e4b1a 289 sw[8] = 0;
darienf 3:36de8b9e4b1a 290 if (cboEmuxOpenp.SelectedIndex == 0)
darienf 3:36de8b9e4b1a 291 {
darienf 3:36de8b9e4b1a 292 sw[6] = 1;
darienf 3:36de8b9e4b1a 293 }
darienf 3:36de8b9e4b1a 294 else
darienf 3:36de8b9e4b1a 295 {
darienf 3:36de8b9e4b1a 296 sw[6] = 0;
darienf 3:36de8b9e4b1a 297 }
darienf 3:36de8b9e4b1a 298 if (cboEmuxOpenn.SelectedIndex == 0)
darienf 3:36de8b9e4b1a 299 {
darienf 3:36de8b9e4b1a 300 sw[9] = 1;
darienf 3:36de8b9e4b1a 301 }
darienf 3:36de8b9e4b1a 302 else
darienf 3:36de8b9e4b1a 303 {
darienf 3:36de8b9e4b1a 304 sw[9] = 0;
darienf 3:36de8b9e4b1a 305 }
darienf 3:36de8b9e4b1a 306 }
darienf 3:36de8b9e4b1a 307 else
darienf 3:36de8b9e4b1a 308 {
darienf 3:36de8b9e4b1a 309 sw[6] = 0;
darienf 3:36de8b9e4b1a 310 sw[9] = 0;
darienf 3:36de8b9e4b1a 311 if (cboEmuxOpenp.SelectedIndex == 0)
darienf 3:36de8b9e4b1a 312 {
darienf 3:36de8b9e4b1a 313 sw[7] = 1;
darienf 3:36de8b9e4b1a 314 }
darienf 3:36de8b9e4b1a 315 else
darienf 3:36de8b9e4b1a 316 {
darienf 3:36de8b9e4b1a 317 sw[7] = 0;
darienf 3:36de8b9e4b1a 318 }
darienf 3:36de8b9e4b1a 319 if (cboEmuxOpenn.SelectedIndex == 0)
darienf 3:36de8b9e4b1a 320 {
darienf 3:36de8b9e4b1a 321 sw[8] = 1;
darienf 3:36de8b9e4b1a 322 }
darienf 3:36de8b9e4b1a 323 else
darienf 3:36de8b9e4b1a 324 {
darienf 3:36de8b9e4b1a 325 sw[8] = 0;
darienf 3:36de8b9e4b1a 326 }
darienf 3:36de8b9e4b1a 327 }
darienf 3:36de8b9e4b1a 328 //Logic for panel 4
darienf 3:36de8b9e4b1a 329 if (cboEnRbias.SelectedIndex == 1)
darienf 3:36de8b9e4b1a 330 {
darienf 3:36de8b9e4b1a 331 if (cboRbiasp.SelectedIndex == 1)
darienf 3:36de8b9e4b1a 332 sw[4] = 1;
darienf 3:36de8b9e4b1a 333 else
darienf 3:36de8b9e4b1a 334 sw[4] = 0;
darienf 3:36de8b9e4b1a 335 if (cboRbiasn.SelectedIndex == 1)
darienf 3:36de8b9e4b1a 336 sw[13] = 1;
darienf 3:36de8b9e4b1a 337 else
darienf 3:36de8b9e4b1a 338 sw[13] = 0;
darienf 3:36de8b9e4b1a 339 }
darienf 3:36de8b9e4b1a 340 else
darienf 3:36de8b9e4b1a 341 {
darienf 3:36de8b9e4b1a 342 sw[4] = 0;
darienf 3:36de8b9e4b1a 343 sw[13] = 0;
darienf 3:36de8b9e4b1a 344 }
darienf 3:36de8b9e4b1a 345 //Logic 5
darienf 3:36de8b9e4b1a 346 if (cboCalEnVcal.SelectedIndex == 1)
darienf 3:36de8b9e4b1a 347 {
darienf 3:36de8b9e4b1a 348 if (cboEmuxCalPSel.SelectedIndex == 1 | cboEmuxCalPSel.SelectedIndex == 2 |
darienf 3:36de8b9e4b1a 349 cboEmuxCalPSel.SelectedIndex == 3)
darienf 3:36de8b9e4b1a 350 sw[5] = 1;
darienf 3:36de8b9e4b1a 351 else
darienf 3:36de8b9e4b1a 352 {
darienf 3:36de8b9e4b1a 353 sw[5] = 0;
darienf 3:36de8b9e4b1a 354 }
darienf 3:36de8b9e4b1a 355 if (cboEmuxCalNSel.SelectedIndex == 1 | cboEmuxCalNSel.SelectedIndex == 2 |
darienf 3:36de8b9e4b1a 356 cboEmuxCalNSel.SelectedIndex == 3)
darienf 3:36de8b9e4b1a 357 sw[14] = 1;
darienf 3:36de8b9e4b1a 358 else
darienf 3:36de8b9e4b1a 359 {
darienf 3:36de8b9e4b1a 360 sw[14] = 0;
darienf 3:36de8b9e4b1a 361 }
darienf 3:36de8b9e4b1a 362 }
darienf 3:36de8b9e4b1a 363 else
darienf 3:36de8b9e4b1a 364 {
darienf 3:36de8b9e4b1a 365 sw[5] = 0;
darienf 3:36de8b9e4b1a 366 sw[14] = 0;
darienf 3:36de8b9e4b1a 367 }
darienf 3:36de8b9e4b1a 368 }
darienf 3:36de8b9e4b1a 369
darienf 3:36de8b9e4b1a 370 private void redrawSwitches()
darienf 3:36de8b9e4b1a 371 {
darienf 3:36de8b9e4b1a 372 // Dispose all Images
darienf 3:36de8b9e4b1a 373 if (picSw1.Image != null)
darienf 3:36de8b9e4b1a 374 picSw1.Image.Dispose();
darienf 3:36de8b9e4b1a 375 if (picSw2.Image != null)
darienf 3:36de8b9e4b1a 376 picSw2.Image.Dispose();
darienf 3:36de8b9e4b1a 377 if (picSw3.Image != null)
darienf 3:36de8b9e4b1a 378 picSw3.Image.Dispose();
darienf 3:36de8b9e4b1a 379 if (picSw4.Image != null)
darienf 3:36de8b9e4b1a 380 picSw4.Image.Dispose();
darienf 3:36de8b9e4b1a 381 if (picSw5.Image != null)
darienf 3:36de8b9e4b1a 382 picSw5.Image.Dispose();
darienf 3:36de8b9e4b1a 383 if (picSw6.Image != null)
darienf 3:36de8b9e4b1a 384 picSw6.Image.Dispose();
darienf 3:36de8b9e4b1a 385 if (picSw7.Image != null)
darienf 3:36de8b9e4b1a 386 picSw7.Image.Dispose();
darienf 3:36de8b9e4b1a 387 if (picSw8.Image != null)
darienf 3:36de8b9e4b1a 388 picSw8.Image.Dispose();
darienf 3:36de8b9e4b1a 389 if (picSw9.Image != null)
darienf 3:36de8b9e4b1a 390 picSw9.Image.Dispose();
darienf 3:36de8b9e4b1a 391 if (picSw10.Image != null)
darienf 3:36de8b9e4b1a 392 picSw10.Image.Dispose();
darienf 3:36de8b9e4b1a 393 if (picSw11.Image != null)
darienf 3:36de8b9e4b1a 394 picSw11.Image.Dispose();
darienf 3:36de8b9e4b1a 395 if (picSw12.Image != null)
darienf 3:36de8b9e4b1a 396 picSw12.Image.Dispose();
darienf 3:36de8b9e4b1a 397 if (picSw13.Image != null)
darienf 3:36de8b9e4b1a 398 picSw13.Image.Dispose();
darienf 3:36de8b9e4b1a 399 if (picSw14.Image != null)
darienf 3:36de8b9e4b1a 400 picSw14.Image.Dispose();
darienf 3:36de8b9e4b1a 401
darienf 3:36de8b9e4b1a 402 if (sw[1] == 1)
darienf 3:36de8b9e4b1a 403 picSw1.Image = Properties.Resources.sw1;
darienf 3:36de8b9e4b1a 404 else
darienf 3:36de8b9e4b1a 405 picSw1.Image = null;
darienf 3:36de8b9e4b1a 406 if (sw[2] == 1)
darienf 3:36de8b9e4b1a 407 picSw2.Image = Properties.Resources.sw2;
darienf 3:36de8b9e4b1a 408 else
darienf 3:36de8b9e4b1a 409 picSw2.Image = null;
darienf 3:36de8b9e4b1a 410 if (sw[3] == 1)
darienf 3:36de8b9e4b1a 411 picSw3.Image = Properties.Resources.sw3;
darienf 3:36de8b9e4b1a 412 else
darienf 3:36de8b9e4b1a 413 picSw3.Image = null;
darienf 3:36de8b9e4b1a 414 if (sw[4] == 1)
darienf 3:36de8b9e4b1a 415 picSw4.Image = Properties.Resources.sw4;
darienf 3:36de8b9e4b1a 416 else
darienf 3:36de8b9e4b1a 417 picSw4.Image = null;
darienf 3:36de8b9e4b1a 418 if (sw[5] == 1)
darienf 3:36de8b9e4b1a 419 picSw5.Image = Properties.Resources.sw5;
darienf 3:36de8b9e4b1a 420 else
darienf 3:36de8b9e4b1a 421 picSw5.Image = null;
darienf 3:36de8b9e4b1a 422 if (sw[6] == 1)
darienf 3:36de8b9e4b1a 423 picSw6.Image = Properties.Resources.sw6;
darienf 3:36de8b9e4b1a 424 else
darienf 3:36de8b9e4b1a 425 picSw6.Image = null;
darienf 3:36de8b9e4b1a 426 if (sw[7] == 1)
darienf 3:36de8b9e4b1a 427 picSw7.Image = Properties.Resources.sw7;
darienf 3:36de8b9e4b1a 428 else
darienf 3:36de8b9e4b1a 429 picSw7.Image = null;
darienf 3:36de8b9e4b1a 430 if (sw[8] == 1)
darienf 3:36de8b9e4b1a 431 picSw8.Image = Properties.Resources.sw8;
darienf 3:36de8b9e4b1a 432 else
darienf 3:36de8b9e4b1a 433 picSw8.Image = null;
darienf 3:36de8b9e4b1a 434 if (sw[9] == 1)
darienf 3:36de8b9e4b1a 435 picSw9.Image = Properties.Resources.sw9;
darienf 3:36de8b9e4b1a 436 else
darienf 3:36de8b9e4b1a 437 picSw9.Image = null;
darienf 3:36de8b9e4b1a 438 if (sw[10] == 1)
darienf 3:36de8b9e4b1a 439 picSw10.Image = Properties.Resources.sw10;
darienf 3:36de8b9e4b1a 440 else
darienf 3:36de8b9e4b1a 441 picSw10.Image = null;
darienf 3:36de8b9e4b1a 442 if (sw[11] == 1)
darienf 3:36de8b9e4b1a 443 picSw11.Image = Properties.Resources.sw11;
darienf 3:36de8b9e4b1a 444 else
darienf 3:36de8b9e4b1a 445 picSw11.Image = null;
darienf 3:36de8b9e4b1a 446 if (sw[12] == 1)
darienf 3:36de8b9e4b1a 447 picSw12.Image = Properties.Resources.sw12;
darienf 3:36de8b9e4b1a 448 else
darienf 3:36de8b9e4b1a 449 picSw12.Image = null;
darienf 3:36de8b9e4b1a 450 if (sw[13] == 1)
darienf 3:36de8b9e4b1a 451 picSw13.Image = Properties.Resources.sw13;
darienf 3:36de8b9e4b1a 452 else
darienf 3:36de8b9e4b1a 453 picSw13.Image = null;
darienf 3:36de8b9e4b1a 454 if (sw[14] == 1)
darienf 3:36de8b9e4b1a 455 picSw14.Image = Properties.Resources.sw14;
darienf 3:36de8b9e4b1a 456 else
darienf 3:36de8b9e4b1a 457 picSw14.Image = null;
darienf 3:36de8b9e4b1a 458 }
darienf 3:36de8b9e4b1a 459
darienf 3:36de8b9e4b1a 460
darienf 3:36de8b9e4b1a 461 private InitArgs.EcgInitStart getEcgArgs()
darienf 3:36de8b9e4b1a 462 {
darienf 3:36de8b9e4b1a 463 InitArgs.EcgInitStart initArgs = new CustomControls.InitArgs.EcgInitStart();
darienf 3:36de8b9e4b1a 464
darienf 3:36de8b9e4b1a 465 initArgs.Openp = cboEmuxOpenp.SelectedIndex;
darienf 3:36de8b9e4b1a 466 initArgs.Openn = cboEmuxOpenn.SelectedIndex;
darienf 3:36de8b9e4b1a 467 initArgs.Pol = cboEmuxPol.SelectedIndex;
darienf 3:36de8b9e4b1a 468 initArgs.Calp_sel = cboEmuxCalPSel.SelectedIndex;
darienf 3:36de8b9e4b1a 469 initArgs.Caln_sel = cboEmuxCalNSel.SelectedIndex;
darienf 3:36de8b9e4b1a 470 //initArgs.En_ecg = cboECGChannelEnable.SelectedIndex;
darienf 3:36de8b9e4b1a 471 initArgs.En_ecg = chkEnECG.Checked ? 1 : 0;
darienf 3:36de8b9e4b1a 472 initArgs.E_fit = 15;//0x1F; // TODO
darienf 3:36de8b9e4b1a 473 initArgs.Rate = cboSampleRate.SelectedIndex;
darienf 3:36de8b9e4b1a 474 initArgs.Gain = cboChannelGain.SelectedIndex;
darienf 3:36de8b9e4b1a 475 initArgs.Dhpf = cboDhpf.SelectedIndex;
darienf 3:36de8b9e4b1a 476 initArgs.Dlpf = cboDlpf.SelectedIndex;
darienf 3:36de8b9e4b1a 477
darienf 3:36de8b9e4b1a 478 return initArgs;
darienf 3:36de8b9e4b1a 479 }
darienf 3:36de8b9e4b1a 480
darienf 3:36de8b9e4b1a 481 private void setEcgArgs(InitArgs.EcgInitStart initArgs)
darienf 3:36de8b9e4b1a 482 {
darienf 3:36de8b9e4b1a 483 cboEmuxOpenp.SelectedIndex = initArgs.Openp;
darienf 3:36de8b9e4b1a 484 cboEmuxOpenn.SelectedIndex = initArgs.Openn;
darienf 3:36de8b9e4b1a 485 cboEmuxPol.SelectedIndex = initArgs.Pol;
darienf 3:36de8b9e4b1a 486 cboEmuxCalPSel.SelectedIndex = initArgs.Calp_sel;
darienf 3:36de8b9e4b1a 487 cboEmuxCalNSel.SelectedIndex = initArgs.Caln_sel;
darienf 3:36de8b9e4b1a 488 //initArgs.En_ecg = cboECGChannelEnable.SelectedIndex;
darienf 3:36de8b9e4b1a 489 //initArgs.En_ecg = chkEnECG.Checked == true ? 1 : 0;
darienf 3:36de8b9e4b1a 490 //initArgs.E_fit = 15;//0x1F;
darienf 3:36de8b9e4b1a 491 cboSampleRate.SelectedIndex = initArgs.Rate;
darienf 3:36de8b9e4b1a 492 cboChannelGain.SelectedIndex = initArgs.Gain;
darienf 3:36de8b9e4b1a 493 cboDhpf.SelectedIndex = initArgs.Dhpf;
darienf 3:36de8b9e4b1a 494 cboDlpf.SelectedIndex = initArgs.Dlpf;
darienf 3:36de8b9e4b1a 495 }
darienf 3:36de8b9e4b1a 496
darienf 3:36de8b9e4b1a 497 private InitArgs.FMSTRInitStart getFMSTRArgs()
darienf 3:36de8b9e4b1a 498 {
darienf 3:36de8b9e4b1a 499 InitArgs.FMSTRInitStart initArgs = new InitArgs.FMSTRInitStart();
darienf 3:36de8b9e4b1a 500
darienf 3:36de8b9e4b1a 501 initArgs.En_rbias = cboEnRbias.SelectedIndex;
darienf 3:36de8b9e4b1a 502 initArgs.Rbiasv = cboRbiasv.SelectedIndex;
darienf 3:36de8b9e4b1a 503 initArgs.Rbiasp = cboRbiasp.SelectedIndex;
darienf 3:36de8b9e4b1a 504 initArgs.Rbiasn = cboRbiasn.SelectedIndex;
darienf 3:36de8b9e4b1a 505 initArgs.Fmstr = cboMasterClock.SelectedIndex;
darienf 3:36de8b9e4b1a 506
darienf 3:36de8b9e4b1a 507 return initArgs;
darienf 3:36de8b9e4b1a 508 }
darienf 3:36de8b9e4b1a 509
darienf 3:36de8b9e4b1a 510 private void setFMSTRArgs(InitArgs.FMSTRInitStart initArgs)
darienf 3:36de8b9e4b1a 511 {
darienf 3:36de8b9e4b1a 512 cboEnRbias.SelectedIndex = initArgs.En_rbias;
darienf 3:36de8b9e4b1a 513 cboRbiasv.SelectedIndex = initArgs.Rbiasv;
darienf 3:36de8b9e4b1a 514 cboRbiasp.SelectedIndex = initArgs.Rbiasp;
darienf 3:36de8b9e4b1a 515 cboRbiasn.SelectedIndex = initArgs.Rbiasn;
darienf 3:36de8b9e4b1a 516 cboMasterClock.SelectedIndex = initArgs.Fmstr;
darienf 3:36de8b9e4b1a 517 }
darienf 3:36de8b9e4b1a 518
darienf 3:36de8b9e4b1a 519 }
darienf 3:36de8b9e4b1a 520 }