Exemplo n.º 1
0
        private LcdWriter()
        {
            _serialInterface = new SerialLcd(SerialPorts.COM2);

            ThreadUtil.Start(() =>
            {
                while (true)
                {
                    _serialInterface.ClearDisplay();
                    _serialInterface.SetCursorPosition(1, 1);

                    lock (_lockObject)
                    {
                        _serialInterface.Write(_lcdDisplay);
                    }

                    mutex.WaitOne();
                }
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// Runs an indefinite loop marking when a button was pushed
 /// </summary>
 /// <param name="action"></param>
 public static void OnBoardButtonPushed(ButtonPushed action)
 {
     ThreadUtil.Start(() =>
     {
         try
         {
             var button = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled);
             while (true)
             {
                 var pushed = !button.Read();
                 if (pushed != _lastStatus)
                 {
                     _lastStatus = pushed;
                     action(pushed);
                 }
                 Thread.Sleep(50);
             }
         }
         catch (Exception ex)
         {
         }
     });
 }