Example #1
0
        public void UpdateState(PololuMaestroState state)
        {
            DeviceSerialNumber = state.SerialNumber;
            IsConnected = state.Connected;

            if (Servos == null || Servos.Count != state.Channels.Count)
            {
                Servos = new ObservableCollection<ServoStateViewModel>();
                for (int i = 0; i < state.Channels.Count; i++)
                {
                    var vm = new ServoStateViewModel();
                    vm.PropertyChanged += OnServoStatePropertyChanged;
                    Servos.Add(vm);
                }
            }

            try
            {
                _updatingServoState = true;

                for (int i = 0; i < _servos.Count; i++)
                    Servos[i].Update(state.Channels[i]);
            }
            finally
            {
                _updatingServoState = false;
            }
        }
Example #2
0
 private void SetNeutralPosition(ServoStateViewModel vm)
 {
     _service.SetServoState(vm.Index, (ushort) (vm.Neutral*4), vm.Speed, vm.Acceleration);
 }