forked from sharpbrick/powered-up
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExampleTechnicMediumAngularMotorGrey.cs
44 lines (29 loc) · 1.16 KB
/
ExampleTechnicMediumAngularMotorGrey.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Threading.Tasks;
using SharpBrick.PoweredUp;
namespace Example;
public class ExampleTechnicMediumAngularMotorGrey : BaseExample
{
public override async Task ExecuteAsync()
{
using var technicMediumHub = Host.FindByType<TechnicMediumHub>();
await technicMediumHub.VerifyDeploymentModelAsync(modelBuilder => modelBuilder
.AddHub<TechnicMediumHub>(hubBuilder => hubBuilder
.AddDevice<TechnicMediumAngularMotorGrey>(technicMediumHub.A)
)
);
var motor = technicMediumHub.A.GetDevice<TechnicMediumAngularMotorGrey>();
await motor.GotoPositionAsync(45, 50, 100);
await Task.Delay(2000);
await motor.SetZeroAsync();
await Task.Delay(2000);
await motor.StartSpeedForDegreesAsync(90, 50, 100);
await Task.Delay(2000);
// align physical and reset position to it.
await motor.GotoPositionAsync(0, 50, 100);
await Task.Delay(2000);
// does not reset back to marked position on device
await motor.GotoRealZeroAsync();
await Task.Delay(2000);
await technicMediumHub.SwitchOffAsync();
}
}