public static void Run() { using (var j = new SenseHatJoystick()) { while (true) { j.Read(); Console.Clear(); if (j.HoldingUp) { Console.Write("U"); } if (j.HoldingDown) { Console.Write("D"); } if (j.HoldingLeft) { Console.Write("L"); } if (j.HoldingRight) { Console.Write("R"); } if (j.HoldingButton) { Console.Write("!"); } } } }
public Joystick(int refreshRate) { _refreshRate = refreshRate; _joyStick = new SenseHatJoystick(); _isRunning = false; lastState = new JoystickState(); Start(); }