Esempio n. 1
0
 /// <summary>
 /// stop the step motor
 /// </summary>
 /// <param name="l298NMotor">stop the select motor(s) in a safe way</param>
 public void Stop(L298NMotorSelection l298NMotor = L298NMotorSelection.All)
 {
     if (IsInitialized)
     {
         if (l298NMotor == L298NMotorSelection.Motor1)
         {
             StopMotor1();
         }
         else if (l298NMotor == L298NMotorSelection.Motor2)
         {
             StopMotor2();
         }
         else
         {
             Parallel.Invoke(() => StopMotor1(), () => StopMotor2());
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// start the dc motor
 /// </summary>
 /// <param name="isClockwise1">choose the direction between clockwise and counter clockwise</param>
 /// <param name="isClockwise2">choose the direction between clockwise and counter clockwise</param>
 /// <param name="motorSelection">select the motor(s) to start</param>
 /// <param name="speedPercent1">speed in percent for motor 1</param>
 /// <param name="speedPercent2">speed in percent for motor 2</param>
 public void Start(bool isClockwise1 = false, bool isClockwise2 = false,
                   L298NMotorSelection motorSelection = L298NMotorSelection.All,
                   double speedPercent1 = 0.1, double speedPercent2 = 0.1)
 {
     if (IsInitialized)
     {
         if (motorSelection == L298NMotorSelection.Motor1)
         {
             StartMotor1(speedPercent1, isClockwise1);
         }
         else if (motorSelection == L298NMotorSelection.Motor2)
         {
             StartMotor2(speedPercent2, isClockwise2);
         }
         else
         {
             Parallel.Invoke(() => StartMotor1(speedPercent1, isClockwise1),
                             () => StartMotor2(speedPercent2, isClockwise2));
         }
     }
 }