コード例 #1
0
    private void Start()
    {
        servo = new RCServo();
        servo.Open();
        servo.Attach += OnAttachServo;

        sensorDistance = new DistanceSensor();
        sensorDistance.Open();
        sensorDistance.Attach += OnAttachDistanceSensor;
    }
コード例 #2
0
        public void onConnectClick(object sender, RoutedEventArgs e)
        {
            if (servo == null || servo.Attached)
            {
                UpdateConnectionStatus();
                return;
            }

            try
            {
                servo.Open(CONNECTION_TIMEOUT);
            }
            catch (PhidgetException ex)
            {
                Debug.WriteLine($"Failed to connect phidget with msg {ex}");
            }

            UpdateConnectionStatus();
        }
コード例 #3
0
        public void SetupPhidget()
        {
            servo         = new RCServo();
            servo.Attach += Servo_Attach;
            servo.Detach += Servo_Detach;
            servo.TargetPositionReached += Servo_TargetPositionReached;
            servo.DeviceSerialNumber     = 306371;
            servo.Channel         = 0;
            servo.IsHubPortDevice = false;
            try
            {
                servo.Open(CONNECTION_TIMEOUT);
            }
            catch (PhidgetException e)
            {
                Debug.WriteLine($"Failed to connect phidget with msg {e}");
            }

            UpdateConnectionStatus();
        }