Пример #1
0
 private void EngineSerial_serialPortEvent(object sender, ArgPins e)
 {
     if (e.PIN == -1)
     {
         serialConsole.BeginInvoke(new MethodInvoker(() => serialConsole.Text += e.STATUS + "\n"));
     }
     else if (e.PIN < arduino.digitalPins.Length)
     {
         if (e.STATUS == "ON")
         {
             arduino.digitalPins[e.PIN] = true;
             grImages[e.PIN].Image      = (Bitmap)(arduino_to_envo_desktop.Properties.Resources.green);
         }
         else if (e.STATUS == "OFF")
         {
             arduino.digitalPins[e.PIN] = false;
             grImages[e.PIN].Image      = (Bitmap)(arduino_to_envo_desktop.Properties.Resources.red);
         }
     }
     else if (e.PIN >= arduino.analogPins.Length)
     {
         analogTextBox[arduino.digitalPins.Length - e.PIN].BeginInvoke(new MethodInvoker(() => analogTextBox[arduino.digitalPins.Length - e.PIN].Text = e.STATUS));
         arduino.analogPins[arduino.digitalPins.Length - e.PIN] = Int32.Parse(e.STATUS);
     }
     serialConsole.BeginInvoke(new MethodInvoker(() => serialConsole.SelectionStart = serialConsole.Text.Length));
     serialConsole.BeginInvoke(new MethodInvoker(() => serialConsole.ScrollToCaret()));
 }
Пример #2
0
 private void eventParse(int pin, string status)
 {
     if (serialPortEvent != null)
     {
         ap = new ArgPins(status, pin);
         serialPortEvent(this, ap);
     }
 }