Ejemplo n.º 1
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            byte[] breaking      = { 0 };
            Stream serialStream1 = simpleSerialPort.Port.BaseStream;

            byte[] bytes1 = FlightControllerMessage.CreateMessage('B', breaking);
            serialStream1.Write(bytes1, 0, bytes1.Length);
        }
Ejemplo n.º 2
0
        private void Button6_Click(object sender, EventArgs e)
        {
            byte[] stop         = { 0 };
            Stream serialStream = simpleSerialPort.Port.BaseStream;

            byte[] bytes = FlightControllerMessage.CreateMessage('P', stop);
            serialStream.Write(bytes, 0, bytes.Length);
        }
Ejemplo n.º 3
0
        private void buttonRestartSynchro_Click(object sender, EventArgs e)
        {
            byte[] breaking      = { 1 };
            Stream serialStream1 = simpleSerialPort.Port.BaseStream;

            byte[] bytes1 = FlightControllerMessage.CreateMessage('R', breaking);
            serialStream1.Write(bytes1, 0, bytes1.Length);
            textBoxNMEA.Text = "";
        }
Ejemplo n.º 4
0
        private void ButtonFlyCommand_Click_1(object sender, EventArgs e)
        {
            byte[] waiting       = { 0 };
            Stream serialStream1 = simpleSerialPort.Port.BaseStream;

            byte[] bytes1 = FlightControllerMessage.CreateMessage('W', waiting);
            serialStream1.Write(bytes1, 0, bytes1.Length);

            byte[] speed        = BitConverter.GetBytes(hScrollBarSpeed.Value);
            Stream serialStream = simpleSerialPort.Port.BaseStream;

            byte[] bytes = FlightControllerMessage.CreateMessage('S', speed);
            serialStream.Write(bytes, 0, bytes.Length);
        }
Ejemplo n.º 5
0
        private void RecordingButton_Click(object sender, EventArgs e)
        {
            Stream serialStream = simpleSerialPort.Port.BaseStream;

            byte[] bytes;
            if (recording)
            {
                //RecordingButton.Text = "REC";
                byte[] stop = { 0 };
                bytes = FlightControllerMessage.CreateMessage('O', stop);
            }
            else
            {
                //RecordingButton.Text = "STOP";
                byte[] rec = { 1 };
                bytes = FlightControllerMessage.CreateMessage('O', rec);
            }
            serialStream.Write(bytes, 0, bytes.Length);
            recording = !recording;
        }
Ejemplo n.º 6
0
        private void textBoxAccel_TextChanged(object sender, EventArgs e)
        {
            if (textBoxAccel.Text != "")
            {
                int  i;
                bool bNum = int.TryParse(textBoxAccel.Text, out i);
                if (bNum)
                {
                    if (Convert.ToInt16(textBoxAccel.Text) >= 1 && Convert.ToInt16(textBoxAccel.Text) <= 10)
                    {
                        hScrollBarAccel.Value = Convert.ToInt16(textBoxAccel.Text);
                        _accel = Convert.ToInt16(textBoxAccel.Text);
                    }
                }

                byte[] accel        = BitConverter.GetBytes(hScrollBarAccel.Value);
                Stream serialStream = simpleSerialPort.Port.BaseStream;
                byte[] bytes        = FlightControllerMessage.CreateMessage('A', accel);
                serialStream.Write(bytes, 0, bytes.Length);
            }
        }
Ejemplo n.º 7
0
        // Need to test communication? Example of a reset command: "#bR@T\r"

        #endregion

        #region GUI

        private void TextBoxYaw_TextChanged(object sender, EventArgs e)
        {
            if (textBoxSpeed.Text != "")
            {
                int  i;
                bool bNum = int.TryParse(textBoxSpeed.Text, out i);
                if (bNum)
                {
                    if (Convert.ToInt16(textBoxSpeed.Text) >= -400 && Convert.ToInt16(textBoxSpeed.Text) <= 400)
                    {
                        hScrollBarSpeed.Value = Convert.ToInt16(textBoxSpeed.Text);
                        _speed = Convert.ToInt16(textBoxSpeed.Text);
                    }
                }
            }

            byte[] speed        = BitConverter.GetBytes(hScrollBarSpeed.Value);
            Stream serialStream = simpleSerialPort.Port.BaseStream;

            byte[] bytes = FlightControllerMessage.CreateMessage('S', speed);
            serialStream.Write(bytes, 0, bytes.Length);
        }