예제 #1
0
 /// <summary>
 /// Places a command packet into the tx queue.
 /// </summary>
 /// <param name="cmd"></param>
 public static void EnqueueCommand(TJCommand cmd)
 {
     EnqueueTXPacket(cmd.ToRawPacket());
 }
예제 #2
0
        // =================================================================== Optical Flow Control Tab ===================================================================
        ///// <summary>
        ///// Called when the camera button is clicked, enable the camera
        ///// </summary>
        //private void btnCamera_Click(object sender, RoutedEventArgs e)
        //{
        //    if (btnCamera == null || btnGetFrame == null)
        //        return;

        //    TJCommand cmd = new TJCommand(TJCommandID.ToggleCameraCmdID);
        //    TJDragonfly.EnqueueCommand(cmd);
        //    if (btnCamera.Content.ToString() == "Enable Camera")
        //    {
        //        btnCamera.Content = "Disable Camera";
        //        btnGetFrame.IsEnabled = true;
        //    }
        //    else
        //    {
        //        btnCamera.Content = "Enable Camera";
        //        btnGetFrame.IsEnabled = false;
        //    }
        //}

        /// <summary>
        /// Called when the get frame button is clicked
        /// </summary>
        private void btnGetFrame_Click(object sender, RoutedEventArgs e)
        {
            //if (btnCamera == null || btnGetFrame == null)
            //    return;

            if (btnGetFrame.IsEnabled)
            {
                TJCommand cmd = new TJCommand(TJCommandID.GetFrameCmdID);
                TJDragonfly.EnqueueCommand(cmd);
            }
        }
예제 #3
0
        // Commented out for now
        // Used for switch communication channel
        //private void btnSetAddress_Click(object sender, RoutedEventArgs e)
        //{
        //    btnSetAddress.IsEnabled = false;

        //    //if (!TJDragonfly.IsConnected)
        //    //    ConnectToDragonfly();

        //    //if (!TJDragonfly.IsConnected)
        //    //    return;

        //    try
        //    {
        //        // Set command to robot to change address
        //        //int neg = -1;
        //        //byte[] robotPacket = new byte[32];
        //        //robotPacket[0] = (byte)TJCommandID.SetAddressCmdID;
        //        //robotPacket[2] = (byte)(cbbRobotID.SelectedIndex);
        //        //robotPacket[3] = (byte)neg;
        //        //robotPacket[4] = (byte)neg;
        //        //robotPacket[5] = (byte)neg;
        //        //TJDragonfly.EnqueueTXPacket(robotPacket);

        //        // Change the nRF address on SDK
        //        switch (chID)
        //        {
        //            case 0:
        //                TJnRFController.SetRFRX((byte)TechJectDF.TJnRFController.nRFChID.chID0); break;
        //            case 1:
        //                TJnRFController.SetRFRX((byte)TechJectDF.TJnRFController.nRFChID.chID1); break;
        //            case 2:
        //                TJnRFController.SetRFRX((byte)TechJectDF.TJnRFController.nRFChID.chID2); break;
        //            case 3:
        //                TJnRFController.SetRFRX((byte)TechJectDF.TJnRFController.nRFChID.chID3); break;
        //            case 4:
        //                TJnRFController.SetRFRX((byte)TechJectDF.TJnRFController.nRFChID.chID4); break;
        //            case 5:
        //                TJnRFController.SetRFRX((byte)TechJectDF.TJnRFController.nRFChID.chID5); break;
        //            default:
        //                break;
        //        }

        //        Thread.Sleep(800);

        //        Console.WriteLine("nRF has been changed to ID " + cbbRobotID.SelectedIndex);
        //    }
        //    catch (Exception)
        //    {
        //        Console.WriteLine("nRF ID change failed, please try again.");
        //    }

        //    btnSetAddress.IsEnabled = true;
        //}

        //private void cbbRobotID_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    chID = (byte)(cbbRobotID.SelectedIndex);
        //}

        /// <summary>
        /// This method responds to any changes in the status of the connection to the dragonfly.
        /// </summary>
        void TJDragonfly_DragonflyConnectionChanged()
        {
            if (TJDragonfly.IsConnected)
            {
                ClearGraphs();
                ClearGraphs2();
                TJDragonfly.DragonflyStateUpdate += UpdateUIState;
                TJDragonfly.DragonflyState2Update += UpdateUIState2;
                TJDragonfly.DragonflyCameraUpdate += UpdateCameraFrame;
                TJDragonfly.DragonflyStartFrame += InitializeFrame;
                TJDragonfly.DragonflyEndFrame += DisplayFrame;
                TJCommand cmd = new TJCommand(TJCommandID.SetTogglesCmdID);
                TJDragonfly.EnqueueCommand(cmd);
                btnConnect.Content = "Disconnect";
            }
            else
            {
                TJDragonfly.DragonflyConnectionChanged -= TJDragonfly_DragonflyConnectionChanged;
                TJDragonfly.DragonflyStateUpdate -= UpdateUIState;
                TJDragonfly.DragonflyState2Update -= UpdateUIState2;
                TJDragonfly.DragonflyCameraUpdate -= UpdateCameraFrame;
                TJDragonfly.DragonflyStartFrame -= InitializeFrame;
                TJDragonfly.DragonflyEndFrame -= DisplayFrame;
                btnConnect.Content = "Connect";
            }
        }
예제 #4
0
 /// <summary>
 /// This method responds to any changes in the status of the connection to the dragonfly.
 /// </summary>
 void TJDragonfly_DragonflyConnectionChanged()
 {
     if (TJDragonfly.IsConnected)
     {
         TJDragonfly.DragonflyBootloaderUpdate += CheckBootloaderStatus;
         TJCommand cmd = new TJCommand(TJCommandID.SetTogglesCmdID);
         TJDragonfly.EnqueueCommand(cmd);
     }
     else
     {
         TJDragonfly.DragonflyConnectionChanged -= TJDragonfly_DragonflyConnectionChanged;
         TJDragonfly.DragonflyBootloaderUpdate -= CheckBootloaderStatus;
     }
 }