Darien Figueroa / Mbed 2 deprecated repo3

Dependencies:   mbed MAX14720 MAX30205 USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BioZMux.cs Source File

BioZMux.cs

00001 /*******************************************************************************
00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved.
00003 * 
00004 * This software is protected by copyright laws of the United States and
00005 * of foreign countries. This material may also be protected by patent laws
00006 * and technology transfer regulations of the United States and of foreign
00007 * countries. This software is furnished under a license agreement and/or a
00008 * nondisclosure agreement and may only be used or reproduced in accordance
00009 * with the terms of those agreements. Dissemination of this information to
00010 * any party or parties not specified in the license agreement and/or
00011 * nondisclosure agreement is expressly prohibited.
00012 *
00013 * The above copyright notice and this permission notice shall be included
00014 * in all copies or substantial portions of the Software.
00015 *
00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00017 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00019 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00020 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00021 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00022 * OTHER DEALINGS IN THE SOFTWARE.
00023 *
00024 * Except as contained in this notice, the name of Maxim Integrated
00025 * Products, Inc. shall not be used except as stated in the Maxim Integrated
00026 * Products, Inc. Branding Policy.
00027 *
00028 * The mere transfer of this software does not imply any licenses
00029 * of trade secrets, proprietary technology, copyrights, patents,
00030 * trademarks, maskwork rights, or any other form of intellectual
00031 * property whatsoever. Maxim Integrated Products, Inc. retains all
00032 * ownership rights.
00033 *******************************************************************************
00034 */
00035 
00036 using System;
00037 using System.Collections.Generic;
00038 using System.ComponentModel;
00039 using System.Data;
00040 using System.Drawing;
00041 using System.Linq;
00042 using System.Text;
00043 using System.Windows.Forms;
00044 
00045 namespace HealthSensorPlatform
00046 {
00047     // Code for ECG Input Mux Tab
00048     public partial class HspForm
00049     {
00050         List<RegisterField> bioZInputMuxField = new List<RegisterField>();
00051 
00052         // Needed for dynamic changing of options
00053         RegisterField biozCalFiftyField;
00054 
00055         void initalizeBioZInputMuxFields()
00056         {
00057             string[] enDcloffOptions = { "Disabled*", "ECG Ch.", "BioZ Ch." };
00058             string[] dcloffIpolOptions = { "P: Pull Up, N: Pull Down*", "P: Pull Down, N: Pull Up" };
00059             string[] dcloffImagOptions = { "0 nA/Disabled*", "5 nA", "10 nA", "20 nA", "50 nA", "100 nA" };
00060             string[] dcloffVthOptions = { "VMID ±300 mV*", "VMID ±400 mV", "VMID ±450 mV", "VMID ±500 mV" };
00061 
00062             string[] bmuxOpenpOptions = { "Connected", "Isolated*" };
00063             string[] bmuxOpennOptions = { "Connected", "Isolated*" };
00064 
00065             string[] enRbiasOptions = { "Disabled*", "ECG Bias", "BIOZ Bias" };
00066             string[] rBiasvOptions = { "50MΩ", "100MΩ*", "200MΩ" };
00067             string[] rBiaspOptions = { "Disconnected*", "Connected" };
00068             string[] rBiasnOptions = { "Disconnected*", "Connected" };
00069 
00070             string[] calEnVcalOptions = { "Disabled*", "Enabled" };
00071             string[] calVmodeOptions = { "Unipolar*", "Bipolar" };
00072             string[] calVmagOptions = { "0.25 mV*", "0.50 mV" };
00073             string[] calFcalOptions = { "FMSTR/128 (~256Hz)", "FMSTR/512 (~64Hz)", "FMSTR/2048 (~16Hz)", "FMSTR/8192 (~4Hz)",
00074                                       "FMSTR/2^15 (~1Hz)*", "FMSTR/2^17 (~1/4Hz)",  "FMSTR/2^19 (~1/16Hz)", "FMSTR/2^21 (~1/64Hz)" };
00075             string[] calFiftyOptions = { "Time High", "50%*" };
00076             string[] calThighOptions = new string[2048/8]; // Assume FMSTR = 32768 Hz
00077             for (int i = 0; i < 2048/8; i++)
00078             {
00079                 calThighOptions[i] = (30.52 * i * 8).ToString("F0") + " μs";
00080             }
00081             calThighOptions[0] += "*"; // Default
00082 
00083             string[] calPSelOptions = { "None*", "VMID", "VCALP", "VCALN" };
00084             string[] calNSelOptions = calPSelOptions;
00085 
00086             RegisterField enDcloffField = new RegisterField { Name = "\nEN_DCLOFF", Register = 0x10, Index = 12, Width = 2, Descriptions = enDcloffOptions, Label = lblBioZEnDcloff, Control = cboBioZEnDcloff, Device = max30001 };
00087             RegisterField dcloffIpolField = new RegisterField { Name = "DCLOFF_IPOL", Register = 0x10, Index = 11, Width = 1, Descriptions = dcloffIpolOptions, Label = lblBioZDcloffIpol, Control = cboBioZDcloffIpol, Device = max30001 };
00088             RegisterField dcloffImagField = new RegisterField { Name = "DCLOFF_IMAG", Register = 0x10, Index = 8, Width = 3, Descriptions = dcloffImagOptions, Label = lblBioZDcloffImag, Control = cboBioZDcloffImag, Device = max30001 };
00089             RegisterField dcloffVthField = new RegisterField { Name = "DCLOFF_VTH", Register = 0x10, Index = 6, Width = 2, Descriptions = dcloffVthOptions, Label = lblBioZDcloffVth, Control = cboBioZDcloffVth, Device = max30001 };
00090             bioZInputMuxField.Add(enDcloffField);
00091             bioZInputMuxField.Add(dcloffIpolField);
00092             bioZInputMuxField.Add(dcloffImagField);
00093             bioZInputMuxField.Add(dcloffVthField);
00094 
00095             RegisterField enUlpLonField = new RegisterField { Name = "\nEN_ULP_LON", Register = 0x10, Index = 22, Width = 2, Descriptions = enDcloffOptions, Label = lblBmuxEnUlpLon, Control = cboBmuxEnUlpLon, Device = max30001 };
00096             bioZInputMuxField.Add(enUlpLonField);
00097 
00098             RegisterField bmuxOpenpField = new RegisterField { Name = "BMUX_OPENP", Register = 0x17, Index = 21, Width = 1, Descriptions = bmuxOpenpOptions, Label = lblBioZBmuxOpenp, Control = cboBioZBmuxOpenp, Device = max30001 };
00099             RegisterField bmuxOpennField = new RegisterField { Name = "BMUX_OPENN", Register = 0x17, Index = 20, Width = 1, Descriptions = bmuxOpennOptions, Label = lblBioZBmuxOpenn, Control = cboBioZBmuxOpenn, Device = max30001 };
00100             bioZInputMuxField.Add(bmuxOpenpField);
00101             bioZInputMuxField.Add(bmuxOpennField);
00102 
00103             RegisterField enRbiasField = new RegisterField { Name = "\nEN_RBIAS", Register = 0x10, Index = 4, Width = 2, Descriptions = enDcloffOptions, Label = lblBioZEnRbias, Control = cboBioZEnRbias, Device = max30001 };
00104             RegisterField rBiasvField = new RegisterField { Name = "RBIASV", Register = 0x10, Index = 2, Width = 2, Descriptions = rBiasvOptions, Label = lblBioZRbiasv, Control = cboBioZRbiasv, Device = max30001 };
00105             RegisterField rBiaspField = new RegisterField { Name = "RBIASP", Register = 0x10, Index = 1, Width = 1, Descriptions = rBiaspOptions, Label = lblBioZRbiasp, Control = cboBioZRbiasp, Device = max30001 };
00106             RegisterField rBiasnField = new RegisterField { Name = "RBIASN", Register = 0x10, Index = 0, Width = 1, Descriptions = rBiasnOptions, Label = lblBioZRbiasn, Control = cboBioZRbiasn, Device = max30001 };
00107             bioZInputMuxField.Add(enRbiasField);
00108             bioZInputMuxField.Add(rBiasvField);
00109             bioZInputMuxField.Add(rBiaspField);
00110             bioZInputMuxField.Add(rBiasnField);
00111 
00112             RegisterField calEnVcalField = new RegisterField { Name = "CAL_EN_VCAL", Register = 0x12, Index = 22, Width = 1, Descriptions = calEnVcalOptions, Label = lblBioZCalEnVcal, Control = cboBioZCalEnVcal, Device = max30001 };
00113             RegisterField calVmodeField = new RegisterField { Name = "CAL_VMODE", Register = 0x12, Index = 21, Width = 1, Descriptions = calVmodeOptions, Label = lblBioZCalVMode, Control = cboBioZCalVMode, Device = max30001 };
00114             RegisterField calVmagField = new RegisterField { Name = "CAL_VMAG", Register = 0x12, Index = 20, Width = 1, Descriptions = calVmagOptions, Label = lblBioZCalVmag, Control = cboBioZCalVmag, Device = max30001 };
00115             RegisterField calFcalField = new RegisterField { Name = "CAL_FCAL", Register = 0x12, Index = 12, Width = 3, Descriptions = calFcalOptions, Label = lblBioZCalFcal, Control = cboBioZCalFcal, Device = max30001 };
00116             biozCalFiftyField = new RegisterField { Name = "CAL_FIFTY", Register = 0x12, Index = 11, Width = 1, Descriptions = calFiftyOptions, Label = lblBioZCalFifty, Control = cboBioZCalFifty, Device = max30001 };
00117             RegisterField calThighField = new RegisterField { Name = "CAL_THIGH", Register = 0x12, Index = 3, Width = 8, Descriptions = calThighOptions, Label = lblBioZCalThigh, Control = cboBioZCalThigh, Device = max30001 };
00118             bioZInputMuxField.Add(calEnVcalField);
00119             bioZInputMuxField.Add(calVmodeField);
00120             bioZInputMuxField.Add(calVmagField);
00121             bioZInputMuxField.Add(calFcalField);
00122             bioZInputMuxField.Add(biozCalFiftyField);
00123             bioZInputMuxField.Add(calThighField);
00124 
00125             RegisterField calPSelField = new RegisterField { Name = "BMUX_CALP_SEL", Register = 0x17, Index = 18, Width = 2, Descriptions = calPSelOptions, Label = lblBioZBmuxCalpSel, Control = cboBioZBmuxCalnSel, Device = max30001 };
00126             RegisterField calNSelField = new RegisterField { Name = "BMUX_CALN_SEL", Register = 0x17, Index = 16, Width = 2, Descriptions = calNSelOptions, Label = lblBioZBmuxCalnSel, Control = cboBioZBmuxCalpSel, Device = max30001 };
00127             bioZInputMuxField.Add(calPSelField);
00128             bioZInputMuxField.Add(calNSelField);
00129         }
00130 
00131         void BioZInputMuxUpdateRegisters()
00132         {
00133             internalUpdate = true;
00134             ReadComboBoxesRegisters(bioZInputMuxField);
00135             internalUpdate = false;
00136         }
00137 
00138         private void cboBioZCalFifty_SelectedIndexChanged(object sender, EventArgs e)
00139         {
00140             if (cboCalFifty.SelectedIndex == 1)
00141             {
00142                 cboCalThigh.Enabled = false;
00143             }
00144             else
00145             {
00146                 cboCalThigh.Enabled = true;
00147             }
00148         }
00149 
00150         private void cboBioZEnDcloff_SelectedIndexChanged(object sender, EventArgs e)
00151         {
00152             redrawBioZMuxImage();
00153         }
00154 
00155 
00156         private void cboBioZDcloffIpol_SelectedIndexChanged(object sender, EventArgs e)
00157         {
00158             redrawBioZMuxImage();
00159         }
00160 
00161         private void cboBmuxEnUlpLon_SelectedIndexChanged(object sender, EventArgs e)
00162         {
00163             redrawBioZMuxImage();
00164         }
00165 
00166         private void cboBioZBmuxOpenp_SelectedIndexChanged(object sender, EventArgs e)
00167         {
00168             redrawBioZMuxImage();
00169         }
00170 
00171         private void cboBioZBmuxOpenn_SelectedIndexChanged(object sender, EventArgs e)
00172         {
00173             redrawBioZMuxImage();
00174         }
00175 
00176         private void cboBioZEnRbias_SelectedIndexChanged(object sender, EventArgs e)
00177         {
00178             redrawBioZMuxImage();
00179         }
00180 
00181         private void cboBioZRbiasp_SelectedIndexChanged(object sender, EventArgs e)
00182         {
00183             redrawBioZMuxImage();
00184         }
00185 
00186         private void cboBioZRbiasn_SelectedIndexChanged(object sender, EventArgs e)
00187         {
00188             redrawBioZMuxImage();
00189         }
00190 
00191         private void cboBioZBmuxCalpSel_SelectedIndexChanged(object sender, EventArgs e)
00192         {
00193             redrawBioZMuxImage();
00194         }
00195 
00196         private void cboBioZBmuxCalnSel_SelectedIndexChanged(object sender, EventArgs e)
00197         {
00198             redrawBioZMuxImage();
00199         }
00200 
00201         private void cboBioZCalEnVcal_SelectedIndexChanged(object sender, EventArgs e)
00202         {
00203             redrawBioZMuxImage();
00204         }
00205 
00206 
00207         private void redrawBioZMuxImage()
00208         {
00209             //Lead Off Check
00210             if (picLoff1.Image != null)
00211                 picLoff1.Image.Dispose();
00212             if (picLoff2.Image != null)
00213                 picLoff2.Image.Dispose();
00214             if (cboBioZEnDcloff.SelectedIndex == 2)
00215             {
00216                 
00217                 if (cboBioZDcloffIpol.SelectedIndex == 0)
00218                 {
00219                     picLoff1.Image = null;
00220                     picLoff2.Image = Properties.Resources.bioz_input_muxloff2;
00221                 }
00222                 else
00223                 {
00224                     picLoff1.Image = Properties.Resources.bioz_input_muxloff1;
00225                     picLoff2.Image = null;
00226                 }
00227             }
00228             else
00229             {
00230                 picLoff1.Image = null;
00231                 picLoff2.Image = null;
00232             }
00233 
00234             //Lead On Check Enable
00235             if (picLeadOn.Image != null)
00236                 picLeadOn.Image.Dispose();
00237             if (cboBmuxEnUlpLon.SelectedIndex == 2)
00238             {
00239                 picLeadOn.Image = Properties.Resources.bioz_input_muxlon;
00240             }
00241             else
00242             {
00243                 picLeadOn.Image = null;
00244             }
00245 
00246             //Switches
00247             if (picBioZsw1.Image != null)
00248                 picBioZsw1.Image.Dispose();
00249             if (picBioZsw2.Image != null)
00250                 picBioZsw2.Image.Dispose();
00251             if (cboBioZBmuxOpenp.SelectedIndex == 0) //if BIP "Connected"
00252             {
00253                 picBioZsw1.Image = Properties.Resources.bioz_input_muxsw1;
00254             }
00255             else
00256             {
00257                 picBioZsw1.Image = null;
00258             }
00259             if (cboBioZBmuxOpenn.SelectedIndex == 0) //if BIN "Connected"
00260             {
00261                 picBioZsw2.Image = Properties.Resources.bioz_input_muxsw2;
00262             }
00263             else
00264             {
00265                 picBioZsw2.Image = null;
00266             }
00267 
00268             //Lead Bias
00269             if (picLeadBias1.Image != null)
00270                 picLeadBias1.Image.Dispose();
00271             if (picLeadBias2.Image != null)
00272                 picLeadBias2.Image.Dispose();
00273             if (cboBioZEnRbias.SelectedIndex == 2)
00274             {
00275                 if (cboBioZRbiasp.SelectedIndex == 1)
00276                 {
00277                     picLeadBias1.Image = Properties.Resources.bioz_input_muxlb1;
00278                 }
00279                 else
00280                 {
00281                     picLeadBias1.Image = null;
00282                 }
00283 
00284                 if (cboBioZRbiasn.SelectedIndex == 1)
00285                 {
00286                     picLeadBias2.Image = Properties.Resources.bioz_input_muxlb2;
00287                 }
00288                 else
00289                 {
00290                     picLeadBias2.Image = null;
00291                 }  
00292             }
00293             else
00294             {
00295                 picLeadBias1.Image = null;
00296                 picLeadBias2.Image = null;
00297             }
00298 
00299             //Calibration
00300             if (picBioZCal1.Image != null)
00301                 picBioZCal1.Image.Dispose();
00302             if (picBioZCal2.Image != null)
00303                 picBioZCal2.Image.Dispose();
00304             if (cboBioZCalEnVcal.SelectedIndex == 1)
00305             {
00306                 if (cboBioZBmuxCalpSel.SelectedIndex == 1 | 
00307                     cboBioZBmuxCalpSel.SelectedIndex == 2 |
00308                     cboBioZBmuxCalpSel.SelectedIndex == 3)
00309                 {
00310                     picBioZCal1.Image = Properties.Resources.bioz_input_muxcal1;
00311                 }
00312                 else
00313                 {
00314                     picBioZCal1.Image = null;
00315                 }
00316                 if (cboBioZBmuxCalnSel.SelectedIndex == 1 |
00317                     cboBioZBmuxCalnSel.SelectedIndex == 2 |
00318                     cboBioZBmuxCalnSel.SelectedIndex == 3)
00319                 {
00320                     picBioZCal2.Image = Properties.Resources.bioz_input_muxcal2;
00321                 }
00322                 else
00323                 {
00324                     picBioZCal2.Image = null;
00325                 }
00326             }
00327             else
00328             {
00329                 picBioZCal1.Image = null;
00330                 picBioZCal2.Image = null;
00331             }
00332 
00333 
00334         }
00335 
00336 
00337     }
00338 }