private static void InitiGPIO() { // init GPIO 24 for Switch1 GPIO24_Sw1 = TinyGPIO.Export(24); GPIO24_Sw1.Direction = GPIODirection.In; // init GPIO 25 for LED1 GPIO25_LED1 = TinyGPIO.Export(25); GPIO25_LED1.Direction = GPIODirection.Out; }
private static void InternalMain() { Logger.Trace($"======== LAUNCH CLR/H #100 Demo 1 ========"); _MD5 = MD5.Create(); UnlockTimer.Elapsed += UnlockTimer_Elapsed; // GPIO の初期化 Logger.Trace("Initialize GPIO."); Gpio21 = TinyGPIO.Export(port: 21, direction: GPIODirection.Out); // SignalR Hub 接続の開設 Logger.Trace("Connect to SignalR Server."); _HubConn = new HubConnection(AppSettings.Clrh100demo1.Url, useDefaultUrl: true); try { _HubConn.StateChanged += HubConn_StateChanged; _MainHub = _HubConn.CreateHubProxy("MainHub"); _MainHub.On("requestCurrentState", SendCurrentStateToAll); _MainHub.On <bool>("requestRemoteUnlock", isAuthorized => OnRequestRemoteUnlock(isAuthorized)); _HubConn.Start().Wait(); } catch (Exception err) { Logger.Error(err); if (_HubConn.State == ConnectionState.Disconnected) { HubConn_StateChanged(new StateChange(ConnectionState.Connecting, ConnectionState.Disconnected)); } } // NFC タグのスキャンを別スレッドで開始 BeginNFCTagPolling(); // 終了イベント待ち Logger.Trace("Begin wait hanlde..."); _ExitAppEvent.WaitOne(); Logger.Trace("End wait handle."); _HubConn.Dispose(); if (_TagtoolProc != null && !_TagtoolProc.HasExited) { _TagtoolProc.Kill(); } Logger.Trace("Force exit."); }
public ActionResult OnButton(string parameterName) { string result; string consoleResult; var gpio25 = TinyGPIO.Export(25); gpio25.Direction = (GPIODirection)GPIODirection.Out; if (parameterName == "ON") { gpio25.Value = 1; result = "On"; consoleResult = "Turn On LED..."; } else { gpio25.Value = 0; result = "Off"; consoleResult = "Turn Off LED..."; } Console.WriteLine(consoleResult); return(Json(new { success = true, show = result }, JsonRequestBehavior.AllowGet)); }