Пример #1
0
        public static void InitListeners()
        {
            EntranceRSw1.ValueChanged += (sender, args) =>
            {
                if (IsAlarmActivated && EntranceRSw1.Read() == GpioPinValue.Low)
                {
                    TriggerAlarm("terraza");
                }
            };

            TerraceRSw2.ValueChanged += (sender, args) =>
            {
                if (IsAlarmActivated && TerraceRSw2.Read() == GpioPinValue.Low)
                {
                    TriggerAlarm("entrada");
                }
            };

            GarageRSw3.ValueChanged += (sender, args) =>
            {
                if (IsAlarmActivated && GarageRSw3.Read() == GpioPinValue.Low)
                {
                    TriggerAlarm("garaje");
                }
            };

            LightSensor.ValueChanged += (sender, args) => { AutoLights(); };

            LivingRoomCurtain.ValueChanged += (sender, args) =>
            {
                if (LivingRoomCurtain.Read() == GpioPinValue.Low && GroundFloorPage.Current != null)
                {
                    Debug.WriteLine("living_room_curatain state changed");
                    DevicePage.Current.EnableCurtainButton("living_room_curtain");
                }
            };

            BedroomCurtain.ValueChanged += (sender, args) =>
            {
                if (BedroomCurtain.Read() == GpioPinValue.Low && FirstFloorPage.Current != null)
                {
                    Debug.WriteLine("bedroom_curatain state changed");
                    DevicePage.Current.EnableCurtainButton("bedroom_curtain");
                }
            };

            BathroomCurtain.ValueChanged += (sender, args) =>
            {
                if (BathroomCurtain.Read() == GpioPinValue.Low && FirstFloorPage.Current != null)
                {
                    Debug.WriteLine("bathroom_curatain state changed");
                    DevicePage.Current.EnableCurtainButton("bathroom_curtain");
                }
            };

            GarageDoor.ValueChanged += (sender, args) =>
            {
                if (GarageDoor.Read() == GpioPinValue.Low && GroundFloorPage.Current != null)
                {
                    Debug.WriteLine("garage_door state changed");
                    DevicePage.Current.EnableDoorButton("garage_door");
                }
            };
        }