Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MAX14720 MAX30205 USBDevice
PrimitivesView.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.Drawing; 00040 using System.Data; 00041 using System.Linq; 00042 using System.Text; 00043 using System.Windows.Forms; 00044 using System.Globalization; 00045 00046 namespace HealthSensorPlatform.CustomControls 00047 { 00048 public partial class PrimitivesView : UserControl 00049 { 00050 public PrimitivesView() 00051 { 00052 InitializeComponent(); 00053 } 00054 00055 public RPCSupport.RPCClient rpcClient { get; set; } 00056 public RPCSupport.Devices.I2cDevice i2cDevice { get; set; } 00057 public RPCSupport.Devices.SpiDevice spiDevice { get; set; } 00058 public RPCSupport.Devices.MAX30101 max30101 { get; set; } 00059 public RPCSupport.Devices.MAX30205 max30205 { get; set; } 00060 public RPCSupport.Devices.MAX30001 max30001 { get; set; } 00061 public RPCSupport.Devices.LIS2HD lis2hd { get; set; } 00062 00063 private void PrimitivesView_Load(object sender, EventArgs e) 00064 { 00065 00066 } 00067 00068 private void btnRawRpcEnter_Click(object sender, EventArgs e) 00069 { 00070 String request = tbCommandLine.Text + "\r\n"; 00071 String reply = rpcClient.RawRpcCall(request, true); 00072 //txt_Status.Text += request; 00073 //txt_Status.Text += reply + "\r\n"; 00074 } 00075 00076 private void btnI2cReadReg_Click(object sender, EventArgs e) 00077 { 00078 byte instance; 00079 byte slaveAddress; 00080 byte address; 00081 if (byte.TryParse(tbI2cInstance.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out instance)) 00082 { 00083 if (byte.TryParse(tbI2cSlaveAddress.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out slaveAddress)) 00084 { 00085 if (byte.TryParse(tbI2cAddress.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) 00086 { 00087 byte value = i2cDevice.ReadReg(instance, slaveAddress, address); 00088 tbI2cReadData.Text = value.ToString("X2"); 00089 } 00090 } 00091 } 00092 } 00093 00094 private void btnI2cWriteReg_Click(object sender, EventArgs e) 00095 { 00096 byte instance; 00097 byte slaveAddress; 00098 byte address; 00099 byte data; 00100 if (byte.TryParse(tbI2cInstance.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out instance)) 00101 { 00102 if (byte.TryParse(tbI2cSlaveAddress.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out slaveAddress)) 00103 { 00104 if (byte.TryParse(tbI2cAddress.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) 00105 { 00106 if (byte.TryParse(tbI2cWriteData.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out data)) 00107 { 00108 i2cDevice.WriteReg(instance, slaveAddress, address, data); 00109 } 00110 } 00111 } 00112 } 00113 } 00114 00115 private void btnMAX30101ReadReg_Click(object sender, EventArgs e) 00116 { 00117 byte address; 00118 if (byte.TryParse(tbMAX30101Address.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) 00119 { 00120 byte value = max30101.ReadReg(address); 00121 tbMAX30101ReadData.Text = value.ToString("X2"); 00122 } 00123 } 00124 00125 private void btnSpiWriteReg_Click(object sender, EventArgs e) 00126 { 00127 byte data; 00128 byte address; 00129 if (byte.TryParse(tbMAX30101WriteData.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out data)) 00130 { 00131 if (byte.TryParse(tbMAX30101Address.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) 00132 { 00133 max30101.WriteReg(address, data); 00134 } 00135 } 00136 } 00137 00138 private void btnMAX30205ReadReg_Click(object sender, EventArgs e) 00139 { 00140 byte address; 00141 if (byte.TryParse(tbMAX30205Address.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) 00142 { 00143 byte value = max30205.ReadReg(address); 00144 tbMAX30205ReadData.Text = value.ToString("X2"); 00145 } 00146 } 00147 00148 private void btnMAX30205WriteReg_Click(object sender, EventArgs e) 00149 { 00150 byte data; 00151 byte address; 00152 if (byte.TryParse(tbMAX30205WriteData.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out data)) 00153 { 00154 if (byte.TryParse(tbMAX30205Address.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) 00155 { 00156 max30205.WriteReg(address, data); 00157 } 00158 } 00159 } 00160 00161 private void btnLIS2HDReadReg_Click(object sender, EventArgs e) 00162 { 00163 byte address; 00164 if (byte.TryParse(tbLIS2HDAddress.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) 00165 { 00166 byte value = lis2hd.ReadReg(address); 00167 tbLIS2HDReadData.Text = value.ToString("X2"); 00168 } 00169 } 00170 00171 private void btnLIS2HDWriteReg_Click(object sender, EventArgs e) 00172 { 00173 byte data; 00174 byte address; 00175 if (byte.TryParse(tbLIS2HDWriteData.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out data)) 00176 { 00177 if (byte.TryParse(tbLIS2HDAddress.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) 00178 { 00179 lis2hd.WriteReg(address, data); 00180 } 00181 } 00182 } 00183 00184 private void btnSpiReadReg_Click(object sender, EventArgs e) 00185 { 00186 00187 } 00188 00189 private void btnI2cWriteData_Click(object sender, EventArgs e) 00190 { 00191 00192 } 00193 00194 private void btnShowHideRpcLog_Click(object sender, EventArgs e) 00195 { 00196 if (rpcClient.IsRpcLogShown() == false) 00197 { 00198 rpcClient.ShowRpcLog(true); 00199 btnShowHideRpcLog.Text = "Hide RPC Log"; 00200 } 00201 else 00202 { 00203 rpcClient.ShowRpcLog(false); 00204 btnShowHideRpcLog.Text = "Show RPC Log"; 00205 } 00206 } 00207 00208 private void btnMAX30001ReadReg_Click(object sender, EventArgs e) 00209 { 00210 byte address; 00211 if (byte.TryParse(tbMAX30001Address.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) 00212 { 00213 int value = max30001.ReadReg(address); 00214 tbMAX30001ReadData.Text = value.ToString("X4"); 00215 } 00216 } 00217 00218 private void btnMAX30001WriteReg_Click(object sender, EventArgs e) 00219 { 00220 int data; 00221 byte address; 00222 if (int.TryParse(tbMAX30001WriteData.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out data)) 00223 { 00224 if (byte.TryParse(tbMAX30001Address.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) 00225 { 00226 max30001.WriteReg(address, data); 00227 } 00228 } 00229 } 00230 00231 /* 00232 00233 void LogRpcRequest(string request) 00234 { 00235 txt_Status.Text += request; 00236 } 00237 00238 void LogRpcReply(string reply) 00239 { 00240 txt_Status.Text += reply + "\r\n"; 00241 } 00242 00243 private void txt_Status_TextChanged(object sender, EventArgs e) 00244 { 00245 //Scroll to the bottom of the textbox when text is added 00246 txt_Status.SelectionStart = txt_Status.Text.Length; 00247 txt_Status.ScrollToCaret(); 00248 txt_Status.Refresh(); 00249 } 00250 00251 private void btn_Clear_Click(object sender, EventArgs e) 00252 { 00253 //clear the status box 00254 txt_Status.Text = ""; 00255 } 00256 */ 00257 00258 } 00259 }
Generated on Thu Jul 28 2022 18:07:15 by
1.7.2