// Algoritam trazenja static bool Search() { LcdConsole.WriteLine("Trazenje predmeta..."); lMotor.ResetTacho(); // Resetuje tacho motora zbog okretanja na kraju rMotor.ResetTacho(); Thread movement = new Thread(SearchMove); movement.IsBackground = true; // Background thread se gasi kada se main zavrsi movement.Start(); progress = 0; while (ir.Read() > C.irScanTreshold && progress < tableLenght) { LcdConsole.WriteLine(ir.Read().ToString()); if (color.Read() == 0) { movement.Abort(); motors.Brake(); throw new Exception("Vrednost senzora za boju je 0!"); } Thread.Sleep(200); } movement.Abort(); motors.Brake(); Thread.Sleep(C.motorBrakeSleepTime); if (progress == tableLenght) { return(false); } else { return(true); } }
public static void Main(string[] args) { ButtonEvents buts = new ButtonEvents(); bool run = true; buts.EscapePressed += () => { run = false; }; MotorSync motori = new MotorSync(MotorPort.OutB, MotorPort.OutD); EV3IRSensor ir = new EV3IRSensor(SensorPort.In3, IRMode.Proximity); Thread bg = new Thread(Scan); bg.Start(); while (run && ir.Read() > 80) { LcdConsole.WriteLine(ir.Read().ToString()); Thread.Sleep(200); } bg.Abort(); motori.Brake(); motori.Off(); }
public void Brake() { Log.Debug("motors brake"); sync.Brake(); }