-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Program.cs
42 lines (37 loc) · 1.33 KB
/
Program.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
using Device.AccelStepper_NF;
using nanoFramework.Hardware.Esp32;
using System;
using System.Diagnostics;
using System.Threading;
using static Device.AccelStepper_NF.AccelStepper;
namespace AccelStepperDemo
{
public class Program
{
const int IN1 = 19;
const int IN2 = 21;
const int IN3 = 22;
const int IN4 = 23;
public static void Main()
{
Debug.WriteLine("Hello from nanoFramework!");
// var accelStepper = new AccelStepper(AccelStepper.MotorInterfaceType.FULL4WIRE, IN1, IN3, IN2, IN4, false);
var accelStepper = new AccelStepper(AccelStepper.MotorInterfaceType.FULL4WIRE, IN1, IN3, IN2, IN4, false, new GetMicroSecondsHandler(GetMicroSeconds));
accelStepper.SetMaxSpeed(400.0f);
accelStepper.SetAcceleration(100.0f);
accelStepper.MoveTo(-4069);
accelStepper.EnableOutputs();
while (true)
{
// Change direction at the limits
if (accelStepper.DistanceToGo() == 0)
accelStepper.MoveTo(-accelStepper.CurrentPosition());
accelStepper.Run();
}
}
private static ulong GetMicroSeconds()
{
return HighResTimer.GetCurrent();
}
}
}