Exemplo n.º 1
0
        public void InitHardware()
        {
            Console.WriteLine("Init sensor...");

            sensor          = new SHT31D(Device.CreateI2cBus());
            sensor.Updated += Sensor_Updated;
        }
Exemplo n.º 2
0
        public static void Main()
        {
            //
            //  Create a new SHT31D object that will generate interrupts when
            //  the temperature changes by more than +/- 0.1C or the humidity
            //  changes by more than 1%.
            //
            SHT31D sht31d = new SHT31D(temperatureChangeNotificationThreshold: 0.1F,
                                       humidityChangeNotificationThreshold: 1.0F);

            //
            //  Hook up the two interrupt handlers to display the changes in
            //  temperature and humidity.
            //
            sht31d.HumidityChanged += (s, e) =>
            {
                Debug.Print("Current humidity: " + e.CurrentValue.ToString("f2"));
            };

            sht31d.TemperatureChanged += (s, e) =>
            {
                Debug.Print("Current temperature: " + e.CurrentValue.ToString("f2"));
            };
            //
            //  Main program loop can now go to sleep as the work
            //  is being performed by the interrupt handlers.
            //
            Thread.Sleep(Timeout.Infinite);
        }
Exemplo n.º 3
0
        public static void Main()
        {
            SHT31D sht31d = new SHT31D(updateInterval: 0);

            Debug.Print("SHT31D Temperature / Humidity Test");
            while (true)
            {
                sht31d.Update();
                Debug.Print("Temperature: " + sht31d.Temperature.ToString("f2") + ", Humidity: " + sht31d.Humidity.ToString("f2"));
                Thread.Sleep(1000);
            }
        }
Exemplo n.º 4
0
        public void InitHardware()
        {
            Console.WriteLine("Initialize hardware...");
            blueLed = Device.CreateDigitalOutputPort(Device.Pins.OnboardLedBlue);

            sensor          = new SHT31D(Device.CreateI2cBus());
            sensor.Updated += Sensor_Updated;

            var st7789 = new ST7789(Device, Device.CreateSpiBus(),
                                    Device.Pins.D02, Device.Pins.D01, Device.Pins.D00,
                                    135, 240);

            display             = new GraphicsLibrary(st7789);
            display.CurrentFont = new Font12x20();
            display.Rotation    = GraphicsLibrary.RotationType._90Degrees;
        }