Esempio n. 1
0
        //Method to read the raw color data
        public async Task<ColorData> getRawData()
        {
            //Create an object to store the raw color data
            ColorData colorData = new ColorData();

            //Make sure the I2C device is initialized
            

            byte[] WriteBuffer = new byte[] { 0x00 };
            byte[] ReadBuffer = new byte[] { 0x00, 0x00 };

            //Read and store the clear data


            //Read and store the red data


            //Read and store the green data


            //Read and store the blue data


            //Output the raw data to the debug console


            //Return the data
            return colorData;
        }
Esempio n. 2
0
        //Method to read the raw color data
        public async Task<ColorData> getRawData()
        {
            //Create an object to store the raw color data
            ColorData colorData = new ColorData();

            //Make sure the I2C device is initialized
            if (!Init) await begin();

            byte[] WriteBuffer = new byte[] { 0x00 };
            byte[] ReadBuffer = new byte[] { 0x00, 0x00 };

            //Read and store the clear data
            WriteBuffer[0] = TCS34725_CDATAL | TCS34725_COMMAND_BIT;
            colorSensor.WriteRead(WriteBuffer, ReadBuffer);
            colorData.Clear = ColorFromBuffer(ReadBuffer);

            //Read and store the red data
            WriteBuffer[0] = TCS34725_RDATAL | TCS34725_COMMAND_BIT;
            colorSensor.WriteRead(WriteBuffer, ReadBuffer);
            colorData.Red = ColorFromBuffer(ReadBuffer);

            //Read and store the green data
            WriteBuffer[0] = TCS34725_GDATAL | TCS34725_COMMAND_BIT;
            colorSensor.WriteRead(WriteBuffer, ReadBuffer);
            colorData.Green = ColorFromBuffer(ReadBuffer);

            //Read and store the blue data
            WriteBuffer[0] = TCS34725_BDATAL | TCS34725_COMMAND_BIT;
            colorSensor.WriteRead(WriteBuffer, ReadBuffer);
            colorData.Blue = ColorFromBuffer(ReadBuffer);

            //Output the raw data to the debug console
            Debug.WriteLine("Raw Data - red: {0}, green: {1}, blue: {2}, clear: {3}", 
                            colorData.Red, colorData.Green, colorData.Blue, colorData.Clear);

            //Return the data
            return colorData;
        }