ChrisSeto.Fpga.FpgaPpmReaderDriver.GetChannel C# (CSharp) Method

GetChannel() public method

public GetChannel ( Channels channel ) : int
channel Channels
return int
        public int GetChannel(Channels channel)
        {
            //Odd high
            //Even low

            byte[] msb = new byte[]
            {
                (byte)((int)channel << 1)
            };

            byte[] lsb = new byte[]
            {
                (byte)(((int)channel << 1) + 1)
            };

            byte[] msbOut = new byte[1];
            byte[] lsbOut = new byte[1];

            I2CDevice.I2CTransaction[] transaction = new I2CDevice.I2CTransaction[]
            {
                I2CDevice.CreateWriteTransaction(msb),
                I2CDevice.CreateReadTransaction(msbOut),
                I2CDevice.CreateWriteTransaction(lsb),
                I2CDevice.CreateReadTransaction(lsbOut),
            };

            int output = ((((int) msbOut[0]) << 8) | (lsbOut[0]));

            return output;
        }

Usage Example

Beispiel #1
0
        public static void Main()
        {
            fpga = new FpgaPpmReaderDriver(0x3c);

            while (true)
            {
                Debug.Print(fpga.GetChannel(FpgaPpmReaderDriver.Channels.Channel0).ToString());

                Thread.Sleep(100);
            }
        }