Esempio n. 1
0
        private void bt_disc_Click(object sender, EventArgs e)
        {
            if (SerialComm.Connected())
            {
                SerialComm.Disconnect();
                lb_conn_state.Text      = "Disconnected";
                lb_conn_state.ForeColor = Color.Red;

                #region Button_disable
                bt_disc.Enabled = false;
                bt_conn.Enabled = true;
                //control part
                bt_forward.Enabled = false;
                bt_back.Enabled    = false;
                bt_left.Enabled    = false;
                bt_right.Enabled   = false;
                bt_stop.Enabled    = false;
                bt_homing.Enabled  = false;
                //arm part
                bt_arm_fw.Enabled    = false;
                bt_arm_back.Enabled  = false;
                bt_arm_left.Enabled  = false;
                bt_arm_right.Enabled = false;
                bt_arm_grasp.Enabled = false;
                bt_arm_up.Enabled    = false;
                bt_arm_down.Enabled  = false;
                bt_homing.Enabled    = false;
                tbar_servo1.Enabled  = false;
                tbar_servo2.Enabled  = false;
                tbar_servo3.Enabled  = false;
                tbar_servo4.Enabled  = false;
                #endregion
                this.KeyPreview = false;
            }
        }
Esempio n. 2
0
 private void bt_conn_Click(object sender, EventArgs e)
 {
     try
     {
         SerialComm.port = cb_port.SelectedItem.ToString();
         SerialComm.baud = Convert.ToInt32(cb_baud.SelectedItem.ToString());
         // if (!SerialComm.Connected())
         //{
         bt_conn.Enabled = false;
         SerialComm.Connect();
         if (SerialComm.Connected())
         {
             lb_conn_state.Text      = "Connected";
             lb_conn_state.ForeColor = Color.Green;
             #region Button_enable
             this.KeyPreview = true;
             //control part
             bt_disc.Enabled    = true;
             bt_conn.Enabled    = false;
             bt_stop.Enabled    = true;
             bt_forward.Enabled = true;
             bt_back.Enabled    = true;
             bt_left.Enabled    = true;
             bt_right.Enabled   = true;
             //arm part
             bt_arm_fw.Enabled    = true;
             bt_arm_back.Enabled  = true;
             bt_arm_left.Enabled  = true;
             bt_arm_right.Enabled = true;
             bt_arm_grasp.Enabled = true;
             bt_arm_up.Enabled    = true;
             bt_arm_down.Enabled  = true;
             bt_stop.Enabled      = true;
             bt_homing.Enabled    = true;
             tbar_servo1.Enabled  = true;
             tbar_servo2.Enabled  = true;
             tbar_servo3.Enabled  = true;
             tbar_servo4.Enabled  = true;
             #endregion
         }
         //}
     }
     catch (Exception ex)
     {
         MessageBox.Show("Serial port open error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         lb_conn_state.Text      = "Error!";
         lb_conn_state.ForeColor = Color.Red;
     }
 }
Esempio n. 3
0
 private void Update_degree()
 {
     SerialComm.Send_cmd(CMD + Convert.ToString(servo_deg));
 }
Esempio n. 4
0
 private void Update_PWM()
 {
     SerialComm.Send_cmd(this.SPD_CMD + Convert.ToString(PWM));
 }
Esempio n. 5
0
 public void Backward()
 {
     SerialComm.Send_cmd(Command.BACK_CMD);
 }
Esempio n. 6
0
 public void Forward()
 {
     SerialComm.Send_cmd(Command.FORWARD_CMD);
 }
Esempio n. 7
0
 public void TurnRight()
 {
     SerialComm.Send_cmd(Command.RIGHT_CMD);
 }
Esempio n. 8
0
 public void TurnLeft()
 {
     SerialComm.Send_cmd(Command.LEFT_CMD);
 }
Esempio n. 9
0
 public void Soft_STOP()
 {
     SerialComm.Send_cmd(Command.SOFT_STOP_CMD);
 }
Esempio n. 10
0
 public void Stop()
 {
     SerialComm.Send_cmd(Command.STOP_CMD);
 }