private void DIO_Load(object sender, EventArgs e) { UInt16 LastErrCode; byte[] byLibVersion = new byte[DIO_API.IMC_LIB_VERSION_SIZE]; LastErrCode = DIO_API.DIO_GetLibVersion(byLibVersion); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to get library version"); return; } int nRealSize; StaticLibVersionValue.Text = ConvertByte2String(byLibVersion, byLibVersion.Length, out nRealSize); LastErrCode = DIO_API.DIO_Initialize(); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to start up the IO library"); return; } UInt32 voice_source; LastErrCode = DIO_API.DIO_GetVoiceSourceControlPin(out voice_source); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to DIO_GetVoiceSourceControlPin " + LastErrCode.ToString("X4")); } if (voice_source == 1) { radioButtonVoiceSourceMicIN.Checked = true; } else { radioButtonVoiceSourceBluetooth.Checked = true; } UInt32 voice_module; LastErrCode = DIO_API.DIO_GetVoiceModuleSelectPin(out voice_module); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to DIO_GetVoiceModuleSelectPin " + LastErrCode.ToString("X4")); } if (voice_module == 0) { radioButtonMC809X.Checked = true; } else { radioButtonMC73X4.Checked = true; } WriteDOPin(); }
private void DIO_Load(object sender, EventArgs e) { UInt16 LastErrCode; byte[] byLibVersion = new byte[DIO_API.IMC_LIB_VERSION_SIZE]; LastErrCode = DIO_API.DIO_GetLibVersion(byLibVersion); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to get library version"); return; } int nRealSize; StaticLibVersionValue.Text = ConvertByte2String(byLibVersion, byLibVersion.Length, out nRealSize); LastErrCode = DIO_API.DIO_Initialize(); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to start up the IO library"); return; } WriteDOPin(); }
private void DIO_Closed(object sender, EventArgs e) { UInt16 LastErrCode; GetDIOStatusTimer.Enabled = false; GetDIOStatusTimer.Dispose(); LastErrCode = DIO_API.DIO_Deinitialize(); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to deinit the IO library"); return; } }
private bool ReadDIPin(ref DIO_API.PIN_STATUS PinStatus) { UInt16 LastErrCode; // Read data lock (LockReadWrite) { LastErrCode = DIO_API.DIO_ReadDIPin(ref PinStatus); if (LastErrCode != IMC_ERR_NO_ERROR) { //MessageBox.Show("Fails to read IO"); return(false); } } return(true); }
private void checkBoxBluetoothEnable_CheckedChanged(object sender, EventArgs e) { UInt32 bluetooth_enable; if (checkBoxBluetoothEnable.Checked) { bluetooth_enable = 1; } else { bluetooth_enable = 0; } UInt16 LastErrCode = DIO_API.DIO_SetBluetoothEnablePin(bluetooth_enable); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to DIO_SetBluetoothEnablePin " + LastErrCode.ToString("X4")); return; } }
private void radioButtonVoiceSourceBluetooth_CheckedChanged(object sender, EventArgs e) { UInt32 voice_source; if (radioButtonVoiceSourceBluetooth.Checked) { voice_source = 0; } else { voice_source = 1; } UInt16 LastErrCode = DIO_API.DIO_SetVoiceSourceControlPin(voice_source); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to DIO_SetVoiceSourceControlPin " + LastErrCode.ToString("X4")); return; } }
private void radioButtonMC809X_CheckedChanged(object sender, EventArgs e) { UInt32 voice_module; if (radioButtonMC809X.Checked) { voice_module = 0; } else { voice_module = 1; } UInt16 LastErrCode = DIO_API.DIO_SetVoiceModuleSelectPin(voice_module); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to DIO_SetVoiceModuleSelectPin " + LastErrCode.ToString("X4")); return; } }
private bool WriteDOPin() { UInt16 LastErrCode; DIO_API.PIN_STATUS PinStatus = new DIO_API.PIN_STATUS(); PinStatus.bPin0 = RadioDO0.Checked ? true : false; PinStatus.bPin1 = RadioDO1.Checked ? true : false; PinStatus.bPin2 = RadioDO2.Checked ? true : false; PinStatus.bPin3 = RadioDO3.Checked ? true : false; lock (LockReadWrite) { LastErrCode = DIO_API.DIO_WriteDOPin(ref PinStatus); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to write IO"); return(false); } } return(true); }