Exemplo n.º 1
0
 private void read()
 {
     while (this.serialPort1.IsOpen)
     {
         try
         {
             if (this.serialPort1.BytesToRead > 0)
             {
                 this.message = serialPort1.ReadLine();
                 this.setText(message);
                 if (message.Length > 0 && message.IndexOf("ypr") == 0)
                 {
                     string[] splitMessage = message.Split('\t');
                     double   yaw          = Double.Parse(splitMessage[1]);
                     double   pitch        = Double.Parse(splitMessage[2]);
                     double   roll         = Double.Parse(splitMessage[3]);
                     this.compass.Image   = Compass.DrawCompass(yaw, pitch, this.maxPitch, roll, this.maxRoll, this.compass.Size);
                     this.pitchRoll.Image = PitchRoll.DrawPitchRoll(pitch, roll, this.pitchRoll.Size);
                 }
             }
         }
         catch (TimeoutException) { }
     }
 }