private static void Regprint_old(string label, byte register) { byte return_value; USBHID.ReadI2CValue(0x30, register, out return_value); // write a line of text to the file tw.WriteLine(register.ToString("X").PadLeft(2, '0') + " 0x" + return_value.ToString("X").PadLeft(2, '0') + " " + Convert.ToString(return_value, 2).PadLeft(8, '0') + " " + label); }
private static void Regprint(string label, byte register) { byte return_value; USBHID.ReadI2CValue(0x30, register, out return_value); string indicator = (return_value == regs[register] ? " " : "*"); // write a line of text to the file sb.Append(indicator + register.ToString("X").PadLeft(2, '0') + " 0x" + return_value.ToString("X").PadLeft(2, '0') + " " + Convert.ToString(return_value, 2).PadLeft(8, '0') + " " + label + "\n"); regs[register] = return_value; }
private void btnI2CRead_Click(object sender, EventArgs e) { byte addr = byte.Parse(txtI2CAddr.Text, NumberStyles.HexNumber); byte b1 = byte.Parse(txtI2CByte1.Text, NumberStyles.HexNumber); byte b2; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val = USBHID.ReadI2CValue(addr, b1, out b2); t1.Stop(); Debug.WriteLine("I2C Read: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); txtI2CResult.Text = b2.ToString("X").PadLeft(2, '0'); }