Exemplo n.º 1
0
 static SpaceService()
 {
     GreenLed = new IoTPin(Connectors.GPIO27);
     GreenLed.SetDirection(IoTPinDirection.DirectionOutInitiallyLow);
     RedLed = new IoTPin(Connectors.GPIO22);
     RedLed.SetDirection(IoTPinDirection.DirectionOutInitiallyLow);
 }
        public static void Main(string [] args)
        {
            var weatherZipCode = Environment.GetEnvironmentVariable("LOCAL_ZIPCODE");
            var weatherContry  = Environment.GetEnvironmentVariable("LOCAL_COUNTRY");

            var geopoint = ReadLocalGeoPoint();
            var dht      = new DhtSensor(Connectors.GPIO4, DhtModel.Dht11);

            dht.Start();

            GreenLed.Value = true;
            RedLed.Value   = false;

            GreenLed = new IoTPin(Connectors.GPIO27);
            GreenLed.SetDirection(IoTPinDirection.DirectionOutInitiallyLow);
            RedLed = new IoTPin(Connectors.GPIO22);
            RedLed.SetDirection(IoTPinDirection.DirectionOutInitiallyLow);

            while (true)
            {
                var count = GetFiresAroundYou(geopoint);
                if (count > 0)
                {
                    if (!alertDectected)
                    {
                        RedLed.Value   = true;
                        GreenLed.Value = false;
                        var currentWeather = weatherService.GetWeather(weatherZipCode, weatherContry, WeatherMeasure.Metric);
                        Speak($"Warning! {count} has been detected near your position");
                        Speak($"The current humidity is {currentWeather.Humidity} percent and a temperature of {currentWeather.Temperature} degrees, with a wind of {currentWeather.Wind} meters per hour");
                        alertDectected = true;
                    }
                }
                else
                {
                    if (alertDectected)
                    {
                        RedLed.Value   = false;
                        GreenLed.Value = true;
                        alertDectected = false;
                    }
                }
                Thread.Sleep(5000);
            }
        }
 public IoTRfTransmitter(Connectors gpio)
 {
     pin = new IoTPin(gpio);
     pin.SetDirection(IoTPinDirection.DirectionOutInitiallyLow);
     pin.SetActiveType(IoTActiveType.ActiveLow);
 }
 public RfTransmitter(Connectors gpio)
 {
     pin = new IoTPin(gpio);
     pin.SetDirection(IoTPinDirection.DirectionOutInitiallyLow);
 }