Ejemplo n.º 1
0
 /// <summary>
 /// Event when button "Wall Follow Mode" is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// created by hngiap
 private void wallFollowBtn_Click(object sender, EventArgs e)
 {
     RFserialPort.Write("W");
     randomWalkBtn.Enabled     = true;
     wallFollowBtn.Enabled     = false;
     workingStatusTextBox.Text = "Automatic: Wall Follow!";
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Event when button "Connect" is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// created by hngiap
 private void connectBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (portComboBox.Text == "" || baudrateComboBox.Text == "")
         {
             MessageBox.Show("Please choose Port and Baud Rate to continue!");
         }
         else
         {
             RFserialPort.PortName = portComboBox.Text;
             RFserialPort.BaudRate = Convert.ToInt32(baudrateComboBox.Text);
             RFserialPort.Open();
             connectBtn.Enabled                = false;
             disconnectBtn.Enabled             = true;
             connectionStatusTextBox.Text      = "Connected!";
             connectionStatusTextBox.BackColor = Color.Green;
             automaticModeBtn.Enabled          = true;
             manualControlBox.Enabled          = true;
             workingStatusTextBox.Text         = "Manual Control Mode!";
             batteryStatusProgressBar.Value    = 60;
         }
     }
     catch (UnauthorizedAccessException)
     {
         MessageBox.Show("Some errors occuured. Please try again!");
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Event when button "Automatic Mode" is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// created by hngiap
 private void automaticModeBtn_Click(object sender, EventArgs e)
 {
     RFserialPort.Write("A");
     manualModeBtn.Enabled       = true;
     manualControlBox.Enabled    = false;
     automaticModeBtn.Enabled    = false;
     automaticControlBox.Enabled = true;
     randomWalkBtn.Enabled       = false;
     wallFollowBtn.Enabled       = true;
     workingStatusTextBox.Text   = "Automatic: Random Walk!";
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Event when button "Disconnect" is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// created by hngiap
 private void disconnectBtn_Click(object sender, EventArgs e)
 {
     try
     {
         RFserialPort.Close();
         //RFserialPort.Write("M");
         ResetControlApp();
         //RFserialPort.Write("S");
     }
     catch (UnauthorizedAccessException)
     {
         MessageBox.Show("Some errors occuured. Please try again!");
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Event when RF module received a message
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// created by hngiap
 private void RFserialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     dataInput = RFserialPort.ReadExisting();
     this.Invoke(new EventHandler(ShowData));
 }
Ejemplo n.º 6
0
 private void turnRightBtn_MouseUp(object sender, MouseEventArgs e)
 {
     RFserialPort.Write("S");
 }
Ejemplo n.º 7
0
 private void turnLeftBtn_MouseDown(object sender, MouseEventArgs e)
 {
     RFserialPort.Write("L");
 }
Ejemplo n.º 8
0
 private void backwardBtn_MouseUp(object sender, MouseEventArgs e)
 {
     RFserialPort.Write("S");
 }
Ejemplo n.º 9
0
 private void forwardBtn_MouseDown(object sender, MouseEventArgs e)
 {
     RFserialPort.Write("F");
 }