private void numUP_Input0_ValueChanged(object sender, EventArgs e) { reg[inputBF[0]].BFValue = (uint)Math.Round((double)this.numUP_Input0.Value * Math.Pow(2, 23)); myRegOp.RegWrite(reg); myRegOp.UpdateRegSettingSource(); }
private void numUP_Input_ValueChanged(object sender, EventArgs e) { reg[inputBF].BFValue = (uint)Math.Round((double)this.numUP_Input.Value * Math.Pow(2, format_FractionalCount)); myRegOp.RegWrite(reg); myRegOp.UpdateRegSettingSource(); }
private void btn_Update_Click(object sender, EventArgs e) { try { regList[0]["ae[25:0]"].BFValue = ae; regList[0]["(1-ae)[25:0]"].BFValue = we; regList[1]["aa[25:0]"].BFValue = aa; regList[1]["(1-aa)[25:0]"].BFValue = wa; regList[2]["ad[25:0]"].BFValue = ad; regList[2]["(1-ad)[25:0]"].BFValue = wd; regList[3].RegValue = T_ThresholddB; regList[4].RegValue = K_slopedB; regList[5].RegValue = O_offsetdB; regList[6][bf_DRC_EN].BFValue = DRC_EN ? 1u : 0u; myRegOp.RegWrite(regList.ToArray()); myRegOp.UpdateRegSettingSource(); } catch { MessageBox.Show("Update failed!!!"); } }
private void rdbtn_CHL_Source_CheckedChanged(object sender, EventArgs e) { if (regMap == null) { return; } uint bfValue = 0; bfValue = rdbtn_CHL_SourceL.Checked ? 0u : (rdbtn_CHL_SourceR.Checked ? 1u : 2u); if (regMap[0x20]["SDIN_TO_CH1"].BFValue != bfValue) { regMap[0x20]["SDIN_TO_CH1"].BFValue = bfValue; myRegOp.RegWrite(regMap[0x20]); myRegOp.UpdateRegSettingSource(); } }
private void btn_Download_Param_Click(object sender, EventArgs e) { #region GUI control switch (mode) { case 0: this.grb_2p0.Visible = true; this.grb_2p1.Visible = false; this.grb_PBTL.Visible = false; //this.grb_2p0.Location = new Point(12, 12); //this.Size = new Size(this.grb_2p0.Width + 40, this.grb_2p0.Height + 60); //this.MaximumSize = this.Size; //this.MinimumSize = this.Size; if (!CheckOutputUnique(cmb_2p0_Out1, cmb_2p0_Out2, cmb_2p0_Out3, cmb_2p0_Out4)) { MessageBox.Show("Please make sure all output item is unique and try again!"); return; } break; case 1: this.grb_2p0.Visible = false; this.grb_2p1.Visible = true; this.grb_PBTL.Visible = false; //this.grb_2p1.Location = new Point(12, 12); //this.Size = new Size(this.grb_2p1.Width + 40, this.grb_2p1.Height + 60); //this.MaximumSize = this.Size; //this.MinimumSize = this.Size; if (!CheckOutputUnique(cmb_2p1_Out1, cmb_2p1_Out2, cmb_2p1_Out3, cmb_2p1_Out4)) { MessageBox.Show("Please make sure all output item is unique and try again!"); return; } break; case 2: this.grb_2p0.Visible = false; this.grb_2p1.Visible = false; this.grb_PBTL.Visible = true; //this.grb_PBTL.Location = new Point(12, 12); //this.Size = new Size(this.grb_PBTL.Width + 40, this.grb_PBTL.Height + 60); //this.MaximumSize = this.Size; //this.MinimumSize = this.Size; if (!CheckOutputUnique(cmb_PBTL_Out1, cmb_PBTL_Out2, cmb_PBTL_Out3, cmb_PBTL_Out4)) { MessageBox.Show("Please make sure all output item is unique and try again!"); return; } break; } #endregion Register tempReg = regMap[0x25]; switch (mode) { case 0: // 2.0 PWM 1 3 2 4 RegSetting(this.cmb_2p0_Out1.SelectedIndex, 0x00); RegSetting(this.cmb_2p0_Out2.SelectedIndex, 0x02); RegSetting(this.cmb_2p0_Out3.SelectedIndex, 0x01); RegSetting(this.cmb_2p0_Out4.SelectedIndex, 0x03); break; case 1: // 2.1 PWM 1 2 3 4 RegSetting(this.cmb_2p1_Out1.SelectedIndex, 0x00); RegSetting(this.cmb_2p1_Out2.SelectedIndex, 0x01); RegSetting(this.cmb_2p1_Out3.SelectedIndex, 0x02); RegSetting(this.cmb_2p1_Out4.SelectedIndex, 0x03); break; case 2: // PBTL PWM 1 1 3 3 RegSetting(this.cmb_PBTL_Out1.SelectedIndex, 0x00); RegSetting(this.cmb_PBTL_Out2.SelectedIndex, 0x00); RegSetting(this.cmb_PBTL_Out3.SelectedIndex, 0x02); RegSetting(this.cmb_PBTL_Out4.SelectedIndex, 0x02); break; } //Console.WriteLine("Reg25 Reg:" + tempReg.RegValueString); //Console.WriteLine("OutA:"+ tempReg.GetBFValue("MUX_TO_OUT_A")); //Console.WriteLine("OutB:" + tempReg.GetBFValue("MUX_TO_OUT_B")); //Console.WriteLine("OutC:" + tempReg.GetBFValue("MUX_TO_OUT_C")); //Console.WriteLine("OutD:" + tempReg.GetBFValue("MUX_TO_OUT_D")); myRegOp.RegWrite(0x25); myRegOp.UpdateRegSettingSource(); }
private void btn_WriteReg_Click(object sender, EventArgs e) { myRegOp.RegWrite(this.regAddrList, true, false, false); }
private void btn_Write_Click(object sender, EventArgs e) { if (regMap == null) { MessageBox.Show("Pease open excel/proj file first"); return; } if (myDongle.IsOpen) { #region Count is how many registers //string[] tempValues = this.txt_Display.Text.Split(new string[] { "-", "\t", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); //byte[] wrValues = new byte[tempValues.Length]; //byte tempValue; //for (int ix = 0; ix < tempValues.Length; ix++) //{ // if (byte.TryParse(tempValues[ix], System.Globalization.NumberStyles.HexNumber, null, out tempValue)) // wrValues[ix] = tempValue; // else // MessageBox.Show("One or more data wrong"); //} //byte currentRegAddr = startAddr; //int finishCount = 0; //int ix_bytes = 0; //byte[] regData; //int bytesCount = 0; //while (currentRegAddr <= 0xFF && finishCount < rwCount && ix_bytes < wrValues.Length) //{ // if (regMap.Contain(currentRegAddr)) // { // //currentReg = regMap[currentRegAddr]; // bytesCount = regMap[currentRegAddr].ByteCount; // regData = new byte[bytesCount]; // for (int ix = 0; ix < bytesCount && ix_bytes < wrValues.Length; ix++) // { // regData[ix] = wrValues[ix_bytes++]; // } // if (RegWrite(currentRegAddr, regData)) // { // finishCount++; // } // else // { // break; // } // } // currentRegAddr++; //} #endregion #region Count is how many bytes //this.txt_Display.Text.Split(new string[] { "-", " ", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string log = ""; string[] tempStrings = this.txt_Display.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None); //byte[] wrValues = new byte[tempValues.Length]; List <byte> wrValuesList = new List <byte> { }; wrValuesList.Clear(); byte tempValue; string[] tempDatas; for (int ix = 0; ix < tempStrings.Length; ix++) { if (tempStrings[ix].StartsWith("/*") || tempStrings[ix] == null || tempStrings[ix] == "") { continue; } log = ""; tempDatas = tempStrings[ix].Split(new string[] { "-", " " }, StringSplitOptions.RemoveEmptyEntries); for (int ix_byte = 0; ix_byte < tempDatas.Length; ix_byte++) { if (byte.TryParse(tempDatas[ix_byte], System.Globalization.NumberStyles.HexNumber, null, out tempValue)) { wrValuesList.Add(tempValue); } else { log += String.Format("\"{0}\"", tempDatas[ix_byte]); } } if (log != "") { MessageBox.Show(String.Format("Line {0} has some wrong data: {1}", ix + 1, log)); return; } } // Real Count is the smaller one of count value in GUI and real data count int realCount = wrValuesList.Count <= rwCount ? wrValuesList.Count: rwCount; byte[] wrValues;// = new byte[realCount]; if (realCount <= rwCount) { wrValues = wrValuesList.ToArray(); } else { wrValues = new byte[rwCount]; Array.Copy(wrValuesList.ToArray(), 0, wrValues, 0, wrValues.Length); } if (myRegOp.RegWrite(startAddr, wrValues, true, false, false)) { //MessageBox.Show(String.Format("{0} bytes have been written.", realCount)); } else { //MessageBox.Show("Write Failed!"); } #endregion } else { MessageBox.Show("Can't find Dongle"); } }
private void btn_Script_Excute_Click(object sender, EventArgs e) { try { byte addr = 0x00; byte value = 0x00; byte[] data; //byte[] reg = new byte[2]; string[] AllCommands = this.richtxt_ScriptView.Text.Split('\n'); string[] parameters; SCRIPT_COMMAND cmdType; bool firstRW = true; int wrCount = 0; for (int i = 0; i < AllCommands.Length; i++) { cmdType = SCRIPT_COMMAND.None; #region TI Script parameters = AllCommands[i].TrimEnd().Split(":; ".ToCharArray()); if (parameters == null || parameters.Length <= 1) // if this line is null or comments { continue; } else if (parameters[0].Contains("~")) // if this line is comments { continue; } else { if (byte.TryParse(parameters[0].TrimStart('X'), System.Globalization.NumberStyles.HexNumber, null, out addr)) { data = new byte[parameters.Length - 1]; for (int ix_data = 1; ix_data < parameters.Length; ix_data++) { if (!byte.TryParse(parameters[ix_data], System.Globalization.NumberStyles.HexNumber, null, out data[ix_data - 1])) { MessageBox.Show(String.Format("Wrong data at line {0} : {1}", i + 1, parameters[ix_data])); return; } } cmdType = SCRIPT_COMMAND.TI_WRITE; } else { MessageBox.Show(String.Format("Wrong data at line {0} : {1}", i + 1, parameters[0])); return; } } #endregion if (cmdType == SCRIPT_COMMAND.None) { cmdType = ScriptDecodeCommand(AllCommands[i], out parameters); } if (cmdType != SCRIPT_COMMAND.None) { switch (cmdType) { case SCRIPT_COMMAND.TI_WRITE: if (wrCount++ % 10 == 0) { if (myRegOp != null) { myRegOp.RegWrite(addr, data, firstRW, false, false); firstRW = false; } else { dg.writeRegBurst(addr, data, data.Length); } } else { myRegOp.RegWrite_NoAck(addr, data); } //Thread.Sleep(200); break; #region Old Commands case SCRIPT_COMMAND.SINGLE_WRITE: //I2CWrite_Single_OneWire(parameters[0], parameters[1]); //reg[0] = Convert.ToByte(parameters[0], 16); //reg[1] = Convert.ToByte(parameters[1], 16); addr = Convert.ToByte(parameters[0], 16); value = Convert.ToByte(parameters[1], 16); dg.writeRegSingle(addr, value); Thread.Sleep(200); //dg.writeRegBlockSingle(reg, 1); break; case SCRIPT_COMMAND.SINGLE_READ: //tempU32 = oneWrie_device.I2CRead_Single(dev_addr, uint.Parse(parameters[0], NumberStyles.HexNumber)); //if (tempU32 <= 0xFF) //{ // ScriptResult(AllCommands[i], true); // DisplayOperateMes("Reg 0x" + parameters[0] + " == " + tempU32.ToString("X2")); //} //else // ScriptResult(AllCommands[i], false); break; case SCRIPT_COMMAND.BURST_WRITE: addr = Convert.ToByte(parameters[0], 16); byte length = Convert.ToByte(parameters[1], 16); data = new byte[parameters.Length - 2]; for (int j = 0; j < data.Length; j++) { data[j] = Convert.ToByte(parameters[2 + j], 16); } dg.writeRegBurst(addr, data, length); Thread.Sleep(200); break; case SCRIPT_COMMAND.BURST_READ: //data = new uint[uint.Parse(parameters[1], NumberStyles.HexNumber)]; //tempU32 = oneWrie_device.I2CRead_Burst(dev_addr, uint.Parse(parameters[0], NumberStyles.HexNumber), uint.Parse(parameters[1], NumberStyles.HexNumber), data); //if (tempU32 == 0) //{ // ScriptResult(AllCommands[i], true); // opMsg = ""; // for (int j = 0; j < data.Length; ) // { // opMsg += data[j++].ToString("X2") + " "; // if (j % 10 == 0) // opMsg += "\r\n"; // } // DisplayOperateMes(opMsg); //} break; case SCRIPT_COMMAND.SET_RSTB: value = Convert.ToByte(parameters[0], 16); if (dg.IsOpen) { if (value == 1) { dg.setUserIO(DMDongle.USERIOGROUP.GROUP_A, DMDongle.USERIOPIN.USR_IO_1); } else if (value == 0) { dg.resetUserIO(DMDongle.USERIOGROUP.GROUP_A, DMDongle.USERIOPIN.USR_IO_1); } } Thread.Sleep(200); break; case SCRIPT_COMMAND.SET_VALID: value = Convert.ToByte(parameters[0], 16); if (dg.IsOpen) { if (value == 1) { dg.setUserIO(DMDongle.USERIOGROUP.GROUP_A, DMDongle.USERIOPIN.USR_IO_0); } else if (value == 0) { dg.resetUserIO(DMDongle.USERIOGROUP.GROUP_A, DMDongle.USERIOPIN.USR_IO_0); } } Thread.Sleep(200); break; case SCRIPT_COMMAND.DELAY: UInt32 delay = Convert.ToUInt32(parameters[0]); Thread.Sleep(value); //Thread.Sleep(200); break; #endregion default: break; } } } //myRegOp.PowerOn(); } catch { MessageBox.Show("Excute script failed, please check the device address and commands!"); } }