static void Main(string [] args) { Console.WriteLine("Welcome to Raspberry Extensions tests"); //Push Switch or button connected to Gpio27 var button = new IoTButton(Connectors.GPIO27); button.ButtonDown += delegate { Console.WriteLine($"DOWN!!!"); }; button.ButtonUp += delegate { Console.WriteLine($"UP!!!"); }; button.Clicked += delegate { count++; Console.WriteLine($"PRESSED THE BUTTON!!! {count}/{maxCount}"); }; while (count < maxCount) { button.Update(); Thread.Sleep(delayTime); } Console.WriteLine("Finished execution."); }
public async Task OKFromLIFX_Real() { EventData data = new EventData(Encoding.UTF8.GetBytes("Test Message")); IoTButton.client = new Lazy <HttpClient>(() => { return(new HttpClient()); }); await IoTButton.ButtonPressAsync(data, logger); }
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(); }; }
public async Task OKFromLIFX_Mock() { EventData data = new EventData(Encoding.UTF8.GetBytes("Test Message")); mockHttpMessageHandler.Setup(m => m.Send(It.IsAny <HttpRequestMessage>())).Returns( new HttpResponseMessage { StatusCode = System.Net.HttpStatusCode.OK, Content = new StringContent("[]", Encoding.UTF8, "application/json") }); IoTButton.client = new Lazy <HttpClient>(() => { return(new HttpClient(mockHttpMessageHandler.Object)); }); await IoTButton.ButtonPressAsync(data, logger); }
public ButtonTest() { var button = new IoTButton(Connectors.GPIO17); button.Clicked += delegate { count++; Console.WriteLine("You clicked the button! {0}/{1}", count, max); }; while (count < max) { button.Update(); Thread.Sleep(250); } button.Dispose(); }
public SoundPlayerTest() { var musicPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var button = new IoTButton(Connectors.GPIO27); var soundPlayer = new IoTSoundPlayer(); button.Clicked += delegate { count++; soundPlayer.Play(Path.Combine(musicPath, $"sound{count}.wav")); }; while (count < max) { button.Update(); Thread.Sleep(250); } button.Dispose(); }