Пример #1
0
        public static void Main()
        {
            //
            //  Create a new HIH6130 and set the temperature change threshold to half a degree.
            //
            HIH6130 hih6130 = new HIH6130(temperatureChangeNotificationThreshold: 0.5F);

            //
            //  Hook up the temperature interrupt handler.
            //
            hih6130.TemperatureChanged += (s, e) =>
            {
                Debug.Print("Temperature changed: " + e.CurrentValue.ToString("f2"));
            };
            //
            //  Hook up the humidity interrupt handler.
            //
            hih6130.HumidityChanged += (s, e) =>
            {
                Debug.Print("Humidity changed: " + e.CurrentValue.ToString("f2"));
            };
            //
            //  Now put the main application to sleep.  The temperature changes will be dealt
            //  with by the event handler above.
            //
            Thread.Sleep(Timeout.Infinite);
        }
Пример #2
0
        public static void Main()
        {
            //
            //  Create a new HIH6130 in polling mode.
            //
            HIH6130 hih6130 = new HIH6130(updateInterval: 0);

            //
            //  Loop continuously updating the sensor readings and displaying
            //  them on the debug console.
            //
            while (true)
            {
                hih6130.Update();
                Debug.Print("Temperature: " + hih6130.Temperature.ToString("f2") +
                            "C, Humidity: " + hih6130.Humidity.ToString("f2") + "%");
                Thread.Sleep(1000);
            }
        }