Exemple #1
0
        /// <summary>
        /// Update the status and/or progress bar.
        /// </summary>
        public void ProvideFeedback(Teensy sender,
                                    string status,
                                    uint bytesUploaded,
                                    uint uploadSize)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <Teensy,
                                   string,
                                   uint,
                                   uint>(ProvideFeedback),
                       sender,
                       status,
                       bytesUploaded,
                       uploadSize);
            }
            else
            {
                _status.Text = status;

                if (bytesUploaded > 0)
                {
                    _progress.Maximum = (int)uploadSize;
                    _progress.Value   = (int)bytesUploaded;
                }

                Refresh();
            }
        }
Exemple #2
0
        /// <summary>
        /// Notification that a Teensy connection state changed.
        /// </summary>
        private void TeensyConnectionStateChanged(Teensy teensy)
        {
            // This may be called from a background thread. Deal with this.
            if (InvokeRequired)
            {
                Invoke(new Action <Teensy>(TeensyConnectionStateChanged),
                       teensy);
            }
            else
            {
                // Refresh the listbox.
                var index    = _teensys.Items.IndexOf(teensy);
                var selected = _teensys.SelectedItem;

                _teensys.Items.RemoveAt(index);
                _teensys.Items.Insert(index, teensy);

                if (selected != null)
                {
                    _teensys.SelectedItem = selected;
                }

                SetUiState();
            }
        }
 // not sure when this is called. On init, before start?
 void Awake()
 {
     m_Instance = this;
     QualitySettings.vSyncCount  = 0;
     Application.targetFrameRate = 60;
     Debug.Log("Waking up");
 }
Exemple #4
0
 public DebugWindow()
 {
     InitializeComponent();
     _teensy = new Teensy("COM3");
     logic = new Logic(_teensy);
     ReloadTracks();
     RefreshPictureBoxes();
 }
Exemple #5
0
 public Form1()
 {
     InitializeComponent();
     _teensy = new Teensy("COM3");
     _logic = new Logic(_teensy);
     captureThread = new Thread(new ParameterizedThreadStart(cv.StartCapturing));
     captureThread.Name = "captureThread";
     captureThread.Start(_logic);
     liveViewTimer = new Timer();
     liveViewTimer.Interval = 20;
     liveViewTimer.Tick += new EventHandler(liveViewTimer_Tick);
     liveViewTimer.Start();
 }
 // kill it with fire!
 void OnDestroy()
 {
     Debug.Log("On Destroy");
     _alive = false;
     if (readThread.ThreadState == ThreadState.Running)
     {
         readThread.Join();
     }
     if (_serialPort.IsOpen)
     {
         _serialPort.Close();
     }
     m_Instance = null;
 }
Exemple #7
0
        /// <summary>
        /// Notification of a Teensy added to the system.
        /// </summary>
        private void TeensyAdded(Teensy teensy)
        {
            // This may be called from a background thread. Deal with this.
            if (InvokeRequired)
            {
                Invoke(new Action <Teensy>(TeensyAdded), teensy);
            }
            else
            {
                // Add to listbox.
                _teensys.Items.Add(teensy);

                // Hook into events we care about.
                teensy.FeedbackProvided       += ProvideFeedback;
                teensy.ConnectionStateChanged += TeensyConnectionStateChanged;

                if (SelectedTeensy == null)
                {
                    _teensys.SelectedItem = teensy;
                }

                SetUiState();
            }
        }