/// <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!"; }
/// <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!"); } }
/// <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!"; }
/// <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!"); } }
/// <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)); }
private void turnRightBtn_MouseUp(object sender, MouseEventArgs e) { RFserialPort.Write("S"); }
private void turnLeftBtn_MouseDown(object sender, MouseEventArgs e) { RFserialPort.Write("L"); }
private void backwardBtn_MouseUp(object sender, MouseEventArgs e) { RFserialPort.Write("S"); }
private void forwardBtn_MouseDown(object sender, MouseEventArgs e) { RFserialPort.Write("F"); }