protected byte Read8(Register register) { Buffer[0] = (byte)register; I2c.Write(I2C.Speed.FourHundredkHz, Address, Buffer, length: 1); I2c.Read(I2C.Speed.FourHundredkHz, Address, Buffer, length: 1); return(Buffer[0]); }
private static void ButtonPressCallback() { if (I2C.I2CGlobalError) { return; } var data = BitConverter.ToString(_device75.Read(0)); switch (data) { case "FF-F9": { Notify(Buttons.S); break; } case "DF-FB": { Notify(Buttons.N1); break; } case "EF-FB": { Notify(Buttons.V4); break; } case "7F-FB": { Notify(Buttons.V5); break; } case "FF-E3": { Notify(Buttons.V2); break; } case "BF-FB": { Notify(Buttons.V1); break; } case "FF-DB": { Notify(Buttons.N2); break; } case "FF-BB": { Notify(Buttons.Start); break; } case "FF-FA": { Notify(Buttons.Enc); break; } //case "FF-FB": { Notike($"BtnV3"); break; } case "FF-7B": { Notify(Buttons.V6); break; } default: { /*System.Windows.Forms.MessageBox.Show($"Iterput {data} \n");*/ break; } } }
public static void Init() { _device75 = new I2C(0x75); if (I2C.I2CGlobalError) { return; } _device75.Write(6, 0xFBF8); //0x0100 _device75.Read(0); _interputPin = Pi.Gpio[30]; _interputPin.PinMode = GpioPinDriveMode.Input; _interputPin.RegisterInterruptCallback(EdgeDetection.FallingEdge, ButtonPressCallback); }
private void Read() { _Blocks.Clear(); // Clear the list of all previous blocks. byte[] bytes = new byte[64]; // Create a new array to hold the byte data from the Pixy via I2C. Port.Read(Address, 64, bytes); // Read the bytes from the Pixy into the array buffer. int i = 0; for (; i < bytes.Length; i++) { // Set the bytes to be greater than 0. int byte1 = bytes[i]; if (byte1 < 0) { byte1 += 256; } int byte2 = bytes[i]; if (byte2 < 0) { byte2 += 256; } // Check if the end bytes have been received. if (byte1 == 0x55 && byte2 == 0xaa) { break; } } if (i == 63) { return; } else if (i == 0) { i += 2; } for (int byteOffset = i; byteOffset < bytes.Length - BlockSize - 1;) { int byte1 = bytes[byteOffset]; if (byte1 < 0) { byte1 += 256; } int byte2 = bytes[byteOffset++]; if (byte2 < 0) { byte2 += 256; } // Check if the end bytes have been received. if (byte1 == 0x55 && byte2 == 0xaa) { byte[] temp = new byte[BlockSize]; for (int tempOffset = 0; tempOffset < BlockSize; tempOffset++) { temp[tempOffset] = bytes[byteOffset + tempOffset]; } PixyBlock block = BytesToBlock(temp); if (block.Signature == 1) { Blocks.Add(block); byteOffset += BlockSize - 1; } else { byteOffset++; } } else { byteOffset++; } } }
protected byte Read8() { I2c.Read(I2C.Speed.OneHundredkHz, (UInt16)SensorAddress, Buffer, length: 1); return(Buffer[0]); }
public void Read() { I2c.Write(I2C.Speed.FourHundredkHz, Address, Buffer, length: 0); Thread.Sleep(60); I2c.Read(I2C.Speed.FourHundredkHz, Address, Buffer); }