/// <summary> /// /// </summary> /// <param name="gearPwm">PWM port for controlling servo</param> public GearBox(IPwmPort gearPwm) { pwm = gearPwm; ServoConfig config = new ServoConfig(new Angle(0), new Angle(180), 500, 2500, 50); servo = new Servo(pwm, config); }
public IContinuousRotationServo GetContinuousRotatioServo(byte portIndex, ServoConfig servoConfig) { if ((portIndex < 0) || (portIndex > portCount)) { throw new ArgumentException($"Continuous Rotatio Servo num must be between 1 and {portCount}", "num"); } var pwm = pca9685.CreatePwmPort(portIndex); var servo = new ContinuousRotationServo(pwm, servoConfig); return(servo); }
public IContinuousRotationServo GetContinuousRotatioServo(byte num, ServoConfig servoConfig) { if ((num < 0) || (num > _ports)) { throw new ArgumentException($"Continuous Rotatio Servo num must be between 1 and {_ports}", "num"); } IPwmPort pwm = _pca9685.CreatePwmPort(num); ContinuousRotationServo servo = new ContinuousRotationServo(pwm, servoConfig); return(servo); }
/// <summary> /// Basic constructor /// </summary> /// <param name="ver">Vertical movement servo PWM port</param> /// <param name="hor">Horizontal movement servo PWM port</param> /// <param name="s">Inertial Measurement Unit to check current device position</param> public CameraGimbal(IPwmPort ver, IPwmPort hor, IPositionSensor s) { horizontalPort = hor; verticalPort = ver; horizontalCoinfig = new ServoConfig(minServoAngle, maxServoAngle, 370, 2700, 50); verticalConfig = new ServoConfig(minServoAngle, maxServoAngle, 370, 2700, 50); horizontal = new Servo(horizontalPort, horizontalCoinfig); vertical = new Servo(verticalPort, verticalConfig); sensor = s; source = new CancellationTokenSource(); angleDelta = maxServoAngle - maxAngle; quarterCircle = fullCircle / 4; locker = new object(); Test(); #if DEBUG stopwatch = new Stopwatch(); #endif }
public MeadowApp() { var servoConfig = new ServoConfig( minimumAngle: 0, maximumAngle: 180, minimumPulseDuration: 700, maximumPulseDuration: 3000, frequency: 50); servo = new Servo(Device.CreatePwmPort(Device.Pins.D03), servoConfig); servo.RotateTo(0); button = new PushButton(Device, Device.Pins.D04); button.DebounceDuration = new TimeSpan(100); button.Clicked += ButtonClicked; //this.changeTimer.AutoReset = true; this.changeTimer.Elapsed += ChangeTimer_Elapsed; this.changeTimer.Start(); // Keeps the app running Thread.Sleep(Timeout.Infinite); }