Beispiel #1
0
        static void WriteDeviceItemInputParserResult(Reports.Input.DeviceItemInputParser parser)
        {
#if SHOW_CHANGES_ONLY
            while (parser.HasChanged)
            {
                int changedIndex      = parser.GetNextChangedIndex();
                var previousDataValue = parser.GetPreviousValue(changedIndex);
                var dataValue         = parser.GetValue(changedIndex);

                Console.WriteLine(string.Format("  {0}: {1} -> {2}",
                                                (Usage)dataValue.Usages.FirstOrDefault(), previousDataValue.GetPhysicalValue(), dataValue.GetPhysicalValue()));
            }
#else
            if (parser.HasChanged)
            {
                int valueCount = parser.ValueCount;

                for (int valueIndex = 0; valueIndex < valueCount; valueIndex++)
                {
                    var dataValue = parser.GetValue(valueIndex);
                    Console.Write(string.Format("  {0}: {1}",
                                                (Usage)dataValue.Usages.FirstOrDefault(), dataValue.GetPhysicalValue()));
                }

                Console.WriteLine();
            }
#endif
        }
Beispiel #2
0
        static void WriteDeviceItemInputParserResult(Reports.Input.DeviceItemInputParser parser)
        {
            int valueCount = parser.ValueCount;

            for (int valueIndex = 0; valueIndex < valueCount; valueIndex++)
            {
                var dataValue = parser.GetValue(valueIndex).GetLogicalValue();

                var topMask    = 0b1111_0000_0000_0000;
                var bottomMask = 0b0000_1111_1111_1111;

                var exp      = (dataValue & topMask) >> 12;
                var mantissa = dataValue & bottomMask;
                var lux      = 0.01 * Math.Pow(2, exp) * mantissa;

                Console.Write(string.Format("lux: {0}", lux));
            }

            Console.WriteLine();
        }