private void Emergency() { LockJoystick(); client.MakeDroneStill(); client.Emergency(); }
public async Task MainLoop() { await core.Init(); RenderConsoleLoop(); var shouldLoop = true; while (shouldLoop) { try { var key = Console.ReadKey(true); logger.LogInformation($"{key.Key} pressed"); switch (key.Key) { case ConsoleKey.W: case ConsoleKey.S: case ConsoleKey.A: case ConsoleKey.D: case ConsoleKey.R: case ConsoleKey.F: if (gamePadEnabled == true) { break; } logger.LogInformation($"FlyDirection({MoveMappings[key.Key]}, 30)"); await client.FlyDirection(MoveMappings[key.Key], 30); break; case ConsoleKey.Q: case ConsoleKey.E: if (gamePadEnabled == true) { break; } logger.LogInformation($"RotateDirection({(key.Key == ConsoleKey.E ? "cw" : "ccw")}, 20)"); await client.RotateDirection(key.Key == ConsoleKey.E, 20); break; case ConsoleKey.T: logger.LogInformation("TakeOff()"); await client.TakeOff(); break; case ConsoleKey.L: logger.LogInformation("Land()"); await client.Land(); break; case ConsoleKey.Spacebar: logger.LogInformation("Emergency()"); await client.Emergency(); break; case ConsoleKey.J: if (gamePadEnabled) { gamePad.Close(); gamePadEnabled = false; } else { gamePadEnabled = gamePad.Listen(); } logger.LogInformation($"Gamepad mode is {(gamePadEnabled ? "ON" : "OFF")}"); break; case ConsoleKey.Escape: logger.LogInformation("Closing all of the connections"); core.Close(); shouldLoop = false; break; } } catch (Exception ex) { logger.LogError(ex, "Exception while proccessing key press"); } } logger.LogInformation("Exiting loop"); }