/// <summary> /// 初始化第二键盘 /// </summary> private void InitSecondKeyBoard() { UInt32 LastErrCode; byte[] sdk_version = new byte[POC_API.HIT_MAX_LIB_VER_STR_LENGTH]; LastErrCode = POC_API.poc_get_version(POC_API.POC_KEYBOARD_PID_SECOND, sdk_version); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("SecondKeyBoard Fails to get SDK version " + TranslateErrorCode(LastErrCode)); return; } Console.WriteLine("SecondKeyBoard Version" + System.Text.Encoding.ASCII.GetString(sdk_version)); LastErrCode = POC_API.poc_init(POC_API.POC_KEYBOARD_PID_SECOND); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("SecondKeyBoard Fails to init library " + TranslateErrorCode(LastErrCode)); return; } else { sdk_init_second_once = true; } byte[] fw_version = new byte[POC_API.HIT_MAX_FW_VER_STR_LENGTH]; LastErrCode = POC_API.poc_get_firmware_version(POC_API.POC_KEYBOARD_PID_SECOND, fw_version); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { Console.WriteLine("SecondKeyBoard Firmware Version:Unknown"); } else { Console.WriteLine("SecondKeyBoard Firmware Version:" + System.Text.Encoding.ASCII.GetString(fw_version)); } byte[] board_name = new byte[POC_API.HIT_MAX_BOARD_NAME_STR_LENGTH]; LastErrCode = POC_API.poc_get_board_name(POC_API.POC_KEYBOARD_PID_SECOND, board_name); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { Console.WriteLine("SecondKeyBoard Board Name:Unknown"); } else { Console.WriteLine("SecondKeyBoard Board Name:" + System.Text.Encoding.ASCII.GetString(board_name)); } unsafe { OnKeycodeDelegateCallbackSecond = new POC_API.keycode_event_callback(keycode_event); } LastErrCode = POC_API.poc_set_keycode_callback(POC_API.POC_KEYBOARD_PID_SECOND, OnKeycodeDelegateCallbackSecond); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails poc set keycode callback: " + LastErrCode.ToString("X8")); } }
// Set/Get Peripheral control bool AccessPeripheralCtrl(bool bSet) { UInt16 LastErrCode; PeripheralCtrl_API.PERIPHERAL_TYPE nType = peripheralCtrlItemTable[ComboPeripheralCtrl.SelectedIndex].index; int nEnable; if (bSet) { nEnable = ComboPeripheralCtrlValue.SelectedIndex; LastErrCode = PeripheralCtrl_API.PeripheralCtrl_SetPeripheralControl(nType, nEnable); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to set peripheral control " + LastErrCode.ToString("X4")); return(false); } } else { LastErrCode = PeripheralCtrl_API.PeripheralCtrl_GetPeripheralControl(nType, out nEnable); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to get peripheral control " + LastErrCode.ToString("X4")); return(false); } ComboPeripheralCtrlValue.SelectedIndex = (nEnable == 1? 1:0); } return(true); }
private void buttonWakeupThSet_Click(object sender, EventArgs e) { UInt16 LastErrCode; UInt32 mg; try { mg = Convert.ToUInt32(textBoxWakeupThresholdValue.Text); } catch { MessageBox.Show("format error"); return; } LastErrCode = GSensor_API.GSENSOR_SetWakeupThreshold(mg); if (LastErrCode == IMC_ERR_INVALID_ARGUMENT) { MessageBox.Show("Threshold over range [63,16000) mg"); return; } if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to GSENSOR_GetWakeupThreshold " + LastErrCode.ToString("X4")); return; } }
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 PeripheralCtrl_Load(object sender, EventArgs e) { UInt16 LastErrCode; byte[] byLibVersion = new byte[PeripheralCtrl_API.IMC_LIB_VERSION_SIZE]; LastErrCode = PeripheralCtrl_API.PeripheralCtrl_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); // Initialize the Peripheral Control library. LastErrCode = PeripheralCtrl_API.PeripheralCtrl_Initialize(); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to start up the PeripheralCtrl library " + LastErrCode.ToString("X4")); return; } for (int i = 0; i < (int)PeripheralCtrl_API.PERIPHERAL_TYPE.PERIPHERAL_SIZE; i++) { ComboPeripheralCtrl.Items.Add(peripheralCtrlItemTable[i].name); } ComboPeripheralCtrl.SelectedIndex = 0; ComboPeripheralCtrlValue.Items.Add(strPeripheralCtrlValue[0]); ComboPeripheralCtrlValue.Items.Add(strPeripheralCtrlValue[1]); ComboPeripheralCtrlValue.SelectedIndex = 0; }
public void SetRearViewSource(byte source) { if (curr_rearview_src == source) { return; } UInt16 LastErrCode; LastErrCode = PeripheralCtrl_API.PeripheralCtrl_SetRearViewSource(source); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to switch to desktop" + LastErrCode.ToString("X4")); return; } curr_rearview_src = source; if (curr_rearview_src == PeripheralCtrl_API.REAR_VIEW_SRC_SYSTEM) { btnMainSrc.Enabled = false; btnExtSrc.Enabled = true; } else { btnMainSrc.Enabled = true; btnExtSrc.Enabled = false; } }
private void RearViewForm_Load(object sender, EventArgs e) { UInt16 LastErrCode; byte[] byLibVersion = new byte[PeripheralCtrl_API.IMC_LIB_VERSION_SIZE]; LastErrCode = PeripheralCtrl_API.PeripheralCtrl_GetLibVersion(byLibVersion); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to get library version " + LastErrCode.ToString("X4")); return; } tbLibVersion.Text = System.Text.Encoding.Default.GetString(byLibVersion); // Initialize the Peripheral Control library. LastErrCode = PeripheralCtrl_API.PeripheralCtrl_Initialize(); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to start up the PeripheralCtrl library " + LastErrCode.ToString("X4")); return; } byte curr_source; LastErrCode = PeripheralCtrl_API.PeripheralCtrl_GetRearViewSource(out curr_source); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to get RearView Source " + LastErrCode.ToString("X4")); return; } SetRearViewSource(PeripheralCtrl_API.REAR_VIEW_SRC_SYSTEM); cbAutoSwitchTime.SelectedIndex = 0; int auto_switch = 0; LastErrCode = PeripheralCtrl_API.PeripheralCtrl_GetAutoRearView(out auto_switch); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to get auto RearView " + LastErrCode.ToString("X4")); return; } if (auto_switch == 0) { checkBoxAutoSwitchBaseDI.Checked = false; } else { checkBoxAutoSwitchBaseDI.Checked = true; } init_once = true; }
private void HotKey_Closed(object sender, EventArgs e) { bool bResult; int LastErrCode; bResult = SUSI_API.SusiDllUnInit(); if (bResult != true) { LastErrCode = SUSI_API.SusiDllGetLastError(); MessageBox.Show(LastErrCode.ToString()); } }
private void buttonGsensorResSet_Click(object sender, EventArgs e) { UInt16 LastErrCode; GSensor_API.IMC_GSENSOR_RES res = (GSensor_API.IMC_GSENSOR_RES)(comboBoxGsensorResValue.SelectedIndex); LastErrCode = GSensor_API.GSENSOR_SetResolution(res); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to GSENSOR_SetResolution " + LastErrCode.ToString("X4")); return; } }
private void buttonWakeupThGet_Click(object sender, EventArgs e) { UInt16 LastErrCode; UInt32 mg; LastErrCode = GSensor_API.GSENSOR_GetWakeupThreshold(out mg); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to GSENSOR_GetWakeupThreshold " + LastErrCode.ToString("X4")); return; } textBoxWakeupThresholdValue.Text = mg.ToString(); }
/// <summary> /// 获取主键盘LED灯状态 /// </summary> /// <param name="ledNumber">键盘灯编号 0 1 2</param> /// <returns></returns> public byte GetMainKeyboardLedStatus(int ledNumber) { if (!sdk_init_main_once) { return(0); } UInt32 LastErrCode; byte ledStatus; switch (ledNumber) { case 0: //LED 1 LastErrCode = POC_API.poc_get_led_status(POC_API.POC_KEYBOARD_PID, POC_API.led_enum.POC_LED_PIN1, out ledStatus); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to get HIT_LED_PIN 1, " + LastErrCode.ToString("X8")); } break; case 1: //LED 2 LastErrCode = POC_API.poc_get_led_status(POC_API.POC_KEYBOARD_PID, POC_API.led_enum.POC_LED_PIN2, out ledStatus); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to get HIT_LED_PIN 2, " + LastErrCode.ToString("X8")); } break; case 2: //LED 3 LastErrCode = POC_API.poc_get_led_status(POC_API.POC_KEYBOARD_PID, POC_API.led_enum.POC_LED_PIN3, out ledStatus); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to get HIT_LED_PIN 3, " + LastErrCode.ToString("X8")); } break; default: ledStatus = 0; break; } return(ledStatus); }
/// <summary> /// 同时关闭第二键盘LED /// </summary> public void CloseSecondKeyBoardAllLed() { if (!sdk_init_second_once) { return; } UInt32 LastErrCode; bool[] LedID = new bool[6] { false, false, false, false, false, false }; LastErrCode = POC_API.poc_set_all_led_status(POC_API.POC_KEYBOARD_PID_SECOND, POC_SECONDBOARD_LED_NUM, LedID); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { MessageBox.Show("Fails to set all led " + LastErrCode.ToString("X8")); } }
private void checkBoxAutoSwitchBaseDI_CheckedChanged(object sender, EventArgs e) { UInt16 LastErrCode; if (!init_once) { return; } int auto_switch = (checkBoxAutoSwitchBaseDI.Checked ? 1 : 0); LastErrCode = PeripheralCtrl_API.PeripheralCtrl_SetAutoRearView(auto_switch); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to set auto switch " + LastErrCode.ToString("X4")); return; } }
private void SetHotKey5Btn_Click(object sender, EventArgs e) { bool bResult = false; int LastErrCode; if (platform_name == "TREK-72x") { bResult = SUSI_API.SusiIICHotKeyREGSetting(4, (byte)Convert.ToInt16(HotKey5MapTxt.Text)); } else { bResult = SUSI_API.SusiVCHotKeyREGSetting(4, (byte)Convert.ToInt16(HotKey5MapTxt.Text)); } if (bResult != true) { LastErrCode = SUSI_API.SusiDllGetLastError(); MessageBox.Show(LastErrCode.ToString()); } }
private void TkBarGSensorStatus_ValueChanged(object sender, EventArgs e) { UInt16 LastErrCode; if (TkBarGSensorStatus.Value == 1) { LastErrCode = GSensor_API.GSENSOR_Initialize(GSensor_PORT_NUMBER); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to init SDK " + LastErrCode.ToString("X4")); return; } GSensorGetValueTimer.Interval = 500; GSensorGetValueTimer.Enabled = true; checkBoxAlarmActive.Enabled = true; unsafe { fixed(void *pEvent = &GSensorAlarmEvent) { if ((LastErrCode = GSensor_API.GSENSOR_SetAlarmEvent(pEvent)) != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to GSENSOR_SetAlarmEvent " + LastErrCode.ToString("X4")); Environment.Exit(-1); } } } } else { GSensorGetValueTimer.Enabled = false; checkBoxAlarmActive.Enabled = false; LastErrCode = GSensor_API.GSENSOR_Deinitialize(); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to De-init SDK"); return; } } }
private void checkBoxAlarmActive_CheckedChanged(object sender, EventArgs e) { UInt16 LastErrCode; if (checkBoxAlarmActive.Checked) { LastErrCode = GSensor_API.GSENSOR_AlarmEnabled(1); GSensorAlarmActive = true; } else { GSensorAlarmActive = false; LastErrCode = GSensor_API.GSENSOR_AlarmEnabled(0); } if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to GSENSOR_AlarmEnabled " + LastErrCode.ToString("X4")); return; } }
/// <summary> /// 同时打开第二键盘LED /// </summary> /// <param name="ledCount">1 2 3 4 5 6 </param> public void OpenSecondKeyBoardAllLed(int ledCount) { if (!sdk_init_second_once) { return; } UInt32 LastErrCode; bool[] LedID = new bool[6]; for (int i = 0; i < ledCount; i++) { LedID[i] = true; } LastErrCode = POC_API.poc_set_all_led_status(POC_API.POC_KEYBOARD_PID_SECOND, POC_SECONDBOARD_LED_NUM, LedID); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { MessageBox.Show("Fails to set all led " + LastErrCode.ToString("X8")); } return; }
private void HotKey_Load(object sender, EventArgs e) { bool bResult; int LastErrCode; bResult = SUSI_API.SusiDllInit(); if (bResult != true) { LastErrCode = SUSI_API.SusiDllGetLastError(); MessageBox.Show(LastErrCode.ToString()); } UInt32 Size; SUSI_IMC_API.IMC_CORE_GETPLATFORMNAME Parm_PN = new SUSI_IMC_API.IMC_CORE_GETPLATFORMNAME(); unsafe { Parm_PN.PlatformName = null; Parm_PN.size = &Size; if (IMC_ERR_NO_ERROR == SUSI_IMC_API.CORE_GetPlatformName(ref Parm_PN)) { UnicodeEncoding encodeW = new UnicodeEncoding(); Size = Size * 2; byte[] name = new byte[Size]; fixed(byte *p = name) { Parm_PN.PlatformName = (char *)p; SUSI_IMC_API.CORE_GetPlatformName(ref Parm_PN); platform_name = encodeW.GetString(name, 0, (int)Size); } } else { return; } } }
private void GSensorGetValueTimer_Tick(object sender, EventArgs e) { if (GSensorAlarmActive) { return; } UInt16 LastErrCode; GSensor_API.IMC_GSENSOR_DATA data; LastErrCode = GSensor_API.GSENSOR_GetData(out data); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to get value " + LastErrCode.ToString("X4")); return; } else { EditGSensorXValue.Text = data.x_mg.ToString(); EditGSensorYValue.Text = data.y_mg.ToString(); EditGSensorZValue.Text = data.z_mg.ToString(); } }
/// <summary> /// 设置第二键盘LED灯 /// </summary> /// <param name="ledNumber">0 1 2 3 4 5</param> public bool SetSecondKeyboardLedStatus(int ledNumber, bool isOpen) { if (!sdk_init_second_once) { return(false); } UInt32 LastErrCode; bool result = false; switch (ledNumber) { case 0: if (isOpen) { LastErrCode = POC_API.poc_led_on(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN1); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } else { LastErrCode = POC_API.poc_led_off(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN1); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } break; case 1: if (isOpen) { LastErrCode = POC_API.poc_led_on(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN2); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } else { LastErrCode = POC_API.poc_led_off(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN2); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } break; case 2: if (isOpen) { LastErrCode = POC_API.poc_led_on(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN3); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } else { LastErrCode = POC_API.poc_led_off(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN3); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } break; case 3: if (isOpen) { LastErrCode = POC_API.poc_led_on(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN4); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } else { LastErrCode = POC_API.poc_led_off(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN4); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } break; case 4: if (isOpen) { LastErrCode = POC_API.poc_led_on(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN5); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } else { LastErrCode = POC_API.poc_led_off(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN5); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } break; case 5: if (isOpen) { LastErrCode = POC_API.poc_led_on(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN6); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } else { LastErrCode = POC_API.poc_led_off(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN6); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to set HIT_LED_PIN " + LastErrCode.ToString("X8")); } else { result = true; } } break; } return(result); }
/// <summary> /// 获取第二键盘LED灯状态 /// </summary> /// <param name="ledNumber">0 1 2 3 4 5</param> /// <returns></returns> public byte GetSecondKeyboardLedStatus(int ledNumber) { if (!sdk_init_second_once) { return(0); } UInt32 LastErrCode; byte ledStatus; switch (ledNumber) { case 0: //LED 1 LastErrCode = POC_API.poc_get_led_status(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN1, out ledStatus); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to get HIT_LED_PIN 1, " + LastErrCode.ToString("X8")); } break; case 1: //LED 2 LastErrCode = POC_API.poc_get_led_status(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN2, out ledStatus); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to get HIT_LED_PIN 2, " + LastErrCode.ToString("X8")); } break; case 2: //LED 3 LastErrCode = POC_API.poc_get_led_status(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN3, out ledStatus); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to get HIT_LED_PIN 3, " + LastErrCode.ToString("X8")); } break; case 3: //LED 4 LastErrCode = POC_API.poc_get_led_status(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN4, out ledStatus); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to get HIT_LED_PIN 4, " + LastErrCode.ToString("X8")); } break; case 4: //LED 5 LastErrCode = POC_API.poc_get_led_status(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN5, out ledStatus); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to get HIT_LED_PIN 5, " + LastErrCode.ToString("X8")); } break; case 5: //LED 6 LastErrCode = POC_API.poc_get_led_status(POC_API.POC_KEYBOARD_PID_SECOND, POC_API.led_enum.POC_LED_PIN6, out ledStatus); if (LastErrCode != POC_API.POC_ERR_NO_ERROR) { //弹框 Console.WriteLine("Fails to get HIT_LED_PIN 6, " + LastErrCode.ToString("X8")); } break; default: ledStatus = 0; break; } //if (ledStatus == 1) //{ // SecondKeyBoardArr[ledNumber] = true; //} return(ledStatus); }
private void IICWRCombineBtn_Click(object sender, EventArgs e) { if ((IICReadNumTextBox.Text == "") || (IICWriteNumTextBox.Text == "") || (IICSlaveAddressTextBox.Text == "")) { MessageBox.Show("Invalid Value !!!"); return; } if ((Convert.ToInt16(IICSlaveAddressTextBox.Text, 16) < 0) || (Convert.ToInt16(IICReadNumTextBox.Text) < 0) || (Convert.ToInt16(IICWriteNumTextBox.Text) < 0)) { MessageBox.Show("Invalid Value !!!"); return; } byte SlaveAddr = Convert.ToByte(IICSlaveAddressTextBox.Text, 16); byte ReadNum = Convert.ToByte(IICReadNumTextBox.Text, 16); UInt32 WriteNum = Convert.ToUInt32(IICWriteNumTextBox.Text); UInt16 LastErrCode; IIC_API.IMC_IIC_WRITE_READ_COMBINE Parm_IICRW = new IIC_API.IMC_IIC_WRITE_READ_COMBINE(); unsafe { if (IICPrimaryRdBtn.Checked == true) { Parm_IICRW.IICType = (uint)IIC_API.BusType.Primary; } else if (IICSmbusIICRdBtn.Checked == true) { Parm_IICRW.IICType = (uint)IIC_API.BusType.SmbusIIC; } else { MessageBox.Show("IIC not support all type!"); return; } Parm_IICRW.SlaveAddress = SlaveAddr; Parm_IICRW.ReadLen = ReadNum; Parm_IICRW.WriteLen = WriteNum; byte[] ResultIICR = new byte[ReadNum]; byte[] ResultIICW = new byte[WriteNum]; HexStringToByteArray(IICInputTextBox.Text, ref ResultIICW); fixed(byte *pResultIICR = ResultIICR) fixed(byte *pResultIICW = ResultIICW) { Parm_IICRW.WriteBuf = pResultIICW; Parm_IICRW.ReadBuf = pResultIICR; LastErrCode = IIC_API.IIC_WriteReadCombine(ref Parm_IICRW); } if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("IMC_IIC_WriteReadCombine fail!", LastErrCode.ToString()); return; } else { IICResultTextBox.Text = ""; string tempString = ""; for (int i = 0; i < ReadNum; i++) { tempString += Convert.ToString(ResultIICR[i], 16) + " "; } IICResultTextBox.Text = tempString; } } }