Пример #1
0
        public static void CreateBlind(bool inverted, Connectors gpioUp, Connectors gpioDown)
        {
            var relay = new IoTRelay(new [] { gpioUp, gpioDown });

            components.Add(relay);
            components.Add(new IoTBlind(relay, 0, 1));
        }
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.SimpleMain);

            //UI Logic
            ConfigureUI();

            Console.WriteLine("Welcome to Raspberry Extensions tests");
            var relay = new IoTRelay(Connectors.GPIO17, Connectors.GPIO27);

            hubContainer       = new RelayHubTest();
            hubContainer.Step += (sender, step) => {
                RunOnUiThread(() => lblLog.Text = $"Step {step}");
            };
            hubContainer.Finished += delegate {
                RunOnUiThread(() => lblLog.Text = $"Finished");
            };

            hubContainer.Configure(relay);
            try {
                await hubContainer.StartAsync(loop : true);
            } catch (Exception ex) {
                tracer.Error(ex);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            var btnCount = FindViewById <Button> (Resource.Id.btnCount);
            var btnLight = FindViewById <Button> (Resource.Id.btnLight);
            var btnNext  = FindViewById <Button> (Resource.Id.btnNext);

            IIoTButton iotButton = new IoTButton(Connectors.GPIO17);
            IIoTRelay  iotRelay  = new IoTRelay(Connectors.GPIO27);

            HubContext.Configure(iotRelay, iotButton);

            btnCount.Click += delegate {
                btnCount.Text = $"{count++} clicks!";
            };

            //Binds real IoT button with a Android.Button behaviour
            iotButton.Bind(btnCount);

            //Binds Android.Button automatically button with relay toggle action
            btnLight.Bind(iotRelay, 0);

            btnLight.Click += delegate {
                iotRelay.Toggle(0);
            };

            btnNext.Text   = "Back";
            btnNext.Click += delegate {
                Finish();
            };
        }
Пример #4
0
        public RelayTest()
        {
            var relay = new IoTRelay(Connectors.GPIO17, Connectors.GPIO27);

            while (count < max)
            {
                relay.Toggle(0);

                if (count % 2 == 0)
                {
                    var pinValue = relay.GetPinValue(1);
                    relay.EnablePin(1, !pinValue);
                }

                relay.Update();

                Thread.Sleep(500);
                count++;
            }

            relay.Dispose();
        }
Пример #5
0
 public IoTBlind(Connectors gpioUp, Connectors gpioDown)
 {
     Relay = new IoTRelay(gpioUp, gpioDown);
     AddComponent(Relay);
     RelayPortUp = 0; RelayPortDown = 1;
 }