Hi,there
i try to create a Airplane attitude.
here is my serial port, that read from gyro.
actully its work but, my picture is slow moving and im not smooth moving.
how can i make it smooth??
First time i send Serial Like (Pitch Angle) in hex: 68 04 00 01 05
with Timer = 80;
BaudRate = 9600;
i will recive Like : 68 07 00 81 00 04 62 EE
Also
68 04 00 04 08 for Pitch,Roll,Heading and this code that will read three Angle Make it More Slow !!!!!
How can i make rotation smooth ???
protected override void OnPaint(PaintEventArgs paintEvnt)
{
base.OnPaint(paintEvnt);
paintEvnt.Graphics.Clip = new Region(new Rectangle(0, 0, 300, 300));
paintEvnt.Graphics.FillRegion(Brushes.Black, paintEvnt.Graphics.Clip);
paintEvnt.Graphics.SmoothingMode = SmoothingMode.HighQuality;
Graphics gfx = paintEvnt.Graphics;
RotateAndTranslate(paintEvnt, mybitmap1, RollAngle, 0, ptBoule, (double)(4 * PitchAngle), ptRotation, 1);
RotateAndTranslate2(paintEvnt, mybitmap3, YawAngle, RollAngle, 0, ptHeading, (double)(4 * PitchAngle), ptRotation, 1);
gfx.DrawImage(mybitmap2, 0, 0);
gfx.DrawImage(mybitmap4, 75, 125);
Graphics g = CreateGraphics();
if (serialPort1.IsOpen == true)
{
g.FillEllipse(Brushes.Green, 20, 350, 20, 20);
}
else
g.FillEllipse(Brushes.Red, 20, 310, 20, 20);
}
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
int bytes = serialPort1.BytesToRead;
byte[] buffer = new byte[bytes];
serialPort1.Read(buffer, 0, bytes);
Log(LogMsgType.Incoming, ByteArrayToHexString(buffer));
if (bytes > 7 )
{
if (buffer[4] == 0)
PitchAngle = Convert.ToDouble(buffer[5]);
else
PitchAngle = -1.0 * Convert.ToDouble(buffer[5]);
Invalidate();
}
}