Skip to content

Commit

Permalink
Rename GotoAbsolutePosition to GotoPosition
Browse files Browse the repository at this point in the history
Closes #74 breaking (API removed/renamed)
  • Loading branch information
tthiery committed Aug 17, 2020
1 parent 2129aeb commit 8209f64
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public override async Task ExecuteAsync()
await calibration.ExecuteAsync(motor);
await technicMediumHub.WaitButtonClickAsync();

await motor.GotoAbsolutePositionAsync(CW * 50, 20, 100, SpecialSpeed.Hold, SpeedProfiles.AccelerationProfile);
await motor.GotoPositionAsync(CW * 50, 20, 100, SpecialSpeed.Hold, SpeedProfiles.AccelerationProfile);
await technicMediumHub.WaitButtonClickAsync();

await motor.GotoAbsolutePositionAsync(CCW * 50, 20, 100, SpecialSpeed.Hold, SpeedProfiles.AccelerationProfile);
await motor.GotoPositionAsync(CCW * 50, 20, 100, SpecialSpeed.Hold, SpeedProfiles.AccelerationProfile);
await Task.Delay(5000);

await technicMediumHub.SwitchOffAsync();
Expand Down
4 changes: 2 additions & 2 deletions examples/SharpBrick.PoweredUp.Examples/ExampleMixedBag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ await technicMediumHub.VerifyDeploymentModelAsync(modelBuilder => modelBuilder
// simple motor control
var motor = technicMediumHub.A.GetDevice<TechnicXLargeLinearMotor>();

await motor.GotoAbsolutePositionAsync(CW * 45, 10, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await motor.GotoPositionAsync(CW * 45, 10, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await Task.Delay(2000);
await motor.GotoAbsolutePositionAsync(CCW * 45, 10, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await motor.GotoPositionAsync(CCW * 45, 10, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await Task.Delay(2000);
await motor.StartPowerAsync(100);
await Task.Delay(5000);
Expand Down
4 changes: 2 additions & 2 deletions examples/SharpBrick.PoweredUp.Examples/ExampleMotorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ await technicMediumHub.VerifyDeploymentModelAsync(modelBuilder => modelBuilder

await Task.Delay(10_000);

await motor.GotoAbsolutePositionAsync(45, 10, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await motor.GotoPositionAsync(45, 10, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await Task.Delay(2000);
await motor.GotoAbsolutePositionAsync(-45, 10, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await motor.GotoPositionAsync(-45, 10, 100, SpecialSpeed.Brake, SpeedProfiles.None);

await technicMediumHub.SwitchOffAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ await technicMediumHub.VerifyDeploymentModelAsync(modelBuilder => modelBuilder
// absolute movement to relative to zero point (SetZeroAsync or initial boot position)
await technicMediumHub.RgbLight.SetRgbColorNoAsync(PoweredUpColor.Orange);

await motor.GotoAbsolutePositionAsync(0, 20, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await motor.GotoPositionAsync(0, 20, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await Task.Delay(1000);
await motor.GotoAbsolutePositionAsync(90, 20, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await motor.GotoPositionAsync(90, 20, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await Task.Delay(1000);
await motor.GotoAbsolutePositionAsync(180, 20, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await motor.GotoPositionAsync(180, 20, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await Task.Delay(1000);
await motor.GotoAbsolutePositionAsync(-90, 20, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await motor.GotoPositionAsync(-90, 20, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await Task.Delay(1000);

await motor.GotoRealZeroAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ await technicMediumHub.VerifyDeploymentModelAsync(modelBuilder => modelBuilder

var motorsOnVirtualPort = virtualPort.GetDevice<TechnicXLargeLinearMotor>();

await motorsOnVirtualPort.GotoAbsolutePositionAsync(90, -45, 10, 100, SpecialSpeed.Brake, SpeedProfiles.None);
await motorsOnVirtualPort.GotoPositionAsync(90, -45, 10, 100, SpecialSpeed.Brake, SpeedProfiles.None);

await Task.Delay(3000);

Expand Down
8 changes: 4 additions & 4 deletions src/SharpBrick.PoweredUp/Devices/AbsoluteMotor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected AbsoluteMotor(IPoweredUpProtocol protocol, byte hubId, byte portId)
/// <param name="endState">After time has expired, either Float, Hold or Brake.</param>
/// <param name="profile">The speed profiles used (as flags) for acceleration and deceleration</param>
/// <returns></returns>
public async Task<PortFeedback> GotoAbsolutePositionAsync(int absolutePosition, sbyte speed, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
public async Task<PortFeedback> GotoPositionAsync(int absolutePosition, sbyte speed, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
{
AssertValidSpeed(speed, nameof(speed));
AssertValidMaxPower(maxPower, nameof(maxPower));
Expand Down Expand Up @@ -78,7 +78,7 @@ public async Task<PortFeedback> GotoAbsolutePositionAsync(int absolutePosition,
/// <param name="endState">After time has expired, either Float, Hold or Brake.</param>
/// <param name="profile">The speed profiles used (as flags) for acceleration and deceleration</param>
/// <returns></returns>
public async Task<PortFeedback> GotoAbsolutePositionAsync(int absolutePosition1, int absolutePosition2, sbyte speed, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
public async Task<PortFeedback> GotoPositionAsync(int absolutePosition1, int absolutePosition2, sbyte speed, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
{
AssertValidSpeed(speed, nameof(speed));
AssertValidMaxPower(maxPower, nameof(maxPower));
Expand All @@ -102,7 +102,7 @@ public async Task<PortFeedback> GotoAbsolutePositionAsync(int absolutePosition1,
return response;
}

private async Task<int> GetAbsolutePositionAsync()
private async Task<int> GetPositionAsync()
{
AssertIsConnected();

Expand All @@ -125,7 +125,7 @@ public async Task GotoRealZeroAsync()
{
AssertIsConnected();

var currentPosition = await GetAbsolutePositionAsync();
var currentPosition = await GetPositionAsync();

sbyte speed = 5;

Expand Down

0 comments on commit 8209f64

Please sign in to comment.