static void Drive() { float x = _gamepad.GetAxis(0); float y = -1 * _gamepad.GetAxis(1); float twist = _gamepad.GetAxis(2); Deadband(ref x); Deadband(ref y); Deadband(ref twist); float leftThrot = y + twist; float rightThrot = y - twist; left.Set(leftThrot); leftSlave.Set(leftThrot); right.Set(-rightThrot); rightSlave.Set(-rightThrot); stringBuilder.Append("\t"); stringBuilder.Append(x); stringBuilder.Append("\t"); stringBuilder.Append(y); stringBuilder.Append("\t"); stringBuilder.Append(twist); }
public static void Main() { /* create a gamepad object */ CTRE.Gamepad myGamepad = new CTRE.Gamepad(new CTRE.UsbHostDevice()); /* create a talon, the Talon Device ID in HERO LifeBoat is zero */ CTRE.TalonSrx myTalon = new CTRE.TalonSrx(0); /* simple counter to print and watch using the debugger */ int counter = 0; /* loop forever */ while (true) { /* added inside the while loop */ if (myGamepad.GetConnectionStatus() == CTRE.UsbDeviceConnection.Connected) { /* print the axis value */ Debug.Print("axis:" + myGamepad.GetAxis(1)); /* pass axis value to talon */ myTalon.Set(myGamepad.GetAxis(1)); /* allow motor control */ CTRE.Watchdog.Feed(); } /* increment counter */ ++counter; /* try to land a breakpoint here */ /* wait a bit */ System.Threading.Thread.Sleep(10); } }
static void Drive() { if (null == _gamepad) { _gamepad = new CTRE.Gamepad(CTRE.UsbHostDevice.GetInstance()); } float x = _gamepad.GetAxis(0); float y = -1 * _gamepad.GetAxis(1); float twist = _gamepad.GetAxis(2); Deadband(ref x); Deadband(ref y); Deadband(ref twist); float leftThrot = y + twist; float rightThrot = y - twist; left.Set(leftThrot); leftSlave.Set(leftThrot); right.Set(-rightThrot); rightSlave.Set(-rightThrot); stringBuilder.Append("\t"); stringBuilder.Append(x); stringBuilder.Append("\t"); stringBuilder.Append(y); stringBuilder.Append("\t"); stringBuilder.Append(twist); }
public static void Main() { leftDrive = new CTRE.TalonSrx(1); rightDrive = new CTRE.TalonSrx(2); leftDrive.SetInverted(true); leftDrive.SetControlMode(CTRE.TalonSrx.ControlMode.kPercentVbus); rightDrive.SetControlMode(CTRE.TalonSrx.ControlMode.kPercentVbus); leftDrive.SetFeedbackDevice(CTRE.TalonSrx.FeedbackDevice.QuadEncoder); rightDrive.SetFeedbackDevice(CTRE.TalonSrx.FeedbackDevice.QuadEncoder); leftDrive.ConfigEncoderCodesPerRev(560); rightDrive.ConfigEncoderCodesPerRev(560); leftDrive.SetSensorDirection(true); leftDrive.SetEncPosition(0); rightDrive.SetEncPosition(0); CTRE.Gamepad gamePad = new CTRE.Gamepad(new CTRE.UsbHostDevice()); /* loop forever */ while (true) { if (gamePad.GetConnectionStatus() == CTRE.UsbDeviceConnection.Connected) { CheesyDrive(gamePad.GetAxis(1), gamePad.GetAxis(2)); CTRE.Watchdog.Feed(); Debug.Print("" + leftDrive.GetPosition() + ":" + rightDrive.GetPosition()); } else { Debug.Print("No Driver Pad"); } /* wait a bit */ System.Threading.Thread.Sleep(10); } }
void Loop10Ms() { /* get all the buttons */ FillBtns(ref _btns); /* get the left y stick, invert so forward is positive */ float leftY = kJoystickScaler * _gamepad.GetAxis(1); Deadband(ref leftY); /* debounce the transition from nonzero => zero axis */ float filteredY = leftY; if (filteredY != 0) { /* put in a ramp to prevent the user from flipping their mechanism */ _talon.SetVoltageRampRate(12.0f); /* V per sec */ /* directly control the output */ _talon.SetControlMode(CTRE.TalonSrx.ControlMode.kPercentVbus); _talon.Set(filteredY); } else if (_talon.GetControlMode() == CTRE.TalonSrx.ControlMode.kPercentVbus) { _targetPosition = _talon.GetPosition(); /* user has let go of the stick, lets closed-loop whereever we happen to be */ EnableClosedLoop(); } /* if a button is pressed while stick is let go, servo position */ if (filteredY == 0) { if (_btns[1]) { _targetPosition = _talon.GetPosition(); /* twenty rotations forward */ EnableClosedLoop(); } else if (_btns[4]) { _targetPosition = +10.0f; /* twenty rotations forward */ EnableClosedLoop(); } else if (_btns[2]) { _targetPosition = -10.0f; /* twenty rotations reverese */ EnableClosedLoop(); } } /* copy btns => btnsLast */ System.Array.Copy(_btns, _btnsLast, _btns.Length); }
public static void Main() { CTRE.Gamepad _gamepad = new CTRE.Gamepad(new CTRE.UsbHostDevice()); //0 - left x //1 - left y //2 - right x // //5 - LB //6 - RB ledSpike.SetControlMode(CTRE.TalonSrx.ControlMode.kVoltage); ledSpike.SetCurrentLimit(1); while (true) { float y = -_gamepad.GetAxis(1); float turn = _gamepad.GetAxis(2); Deadband(ref y); Deadband(ref turn); if (_gamepad.GetConnectionStatus() == CTRE.UsbDeviceConnection.Connected) { if (_gamepad.GetButton(5)) { ArcadeDrive(y, turn); /* feed watchdog to keep Talon's enabled */ CTRE.Watchdog.Feed(); } if (_gamepad.GetButton(6)) { ledSpike.Set(3.5f); CTRE.Watchdog.Feed(); } else { ledSpike.Set(0); } } /* run this task every 10ms */ Thread.Sleep(10); } }
void Drive() { FillBtns(ref _btns); float y = -1 * _gamepad.GetAxis(1); Deadband(ref y); _talon.ProcessMotionProfileBuffer(); /* button handler, if btn5 pressed launch MP, if btn7 pressed, enter voltage mode */ if (_btns[5] && !_btnsLast[5]) { /* disable MP to clear IsLast */ _talon.SetControlMode(CTRE.TalonSrx.ControlMode.kMotionProfile); _talon.Set(0); CTRE.Watchdog.Feed(); Thread.Sleep(10); /* buffer new pts in HERO */ CTRE.TalonSrx.TrajectoryPoint point = new CTRE.TalonSrx.TrajectoryPoint(); _talon.ClearMotionProfileHasUnderrun(); _talon.ClearMotionProfileTrajectories(); for (uint i = 0; i < MotionProfile.kNumPoints; ++i) { point.position = (float)MotionProfile.Points[i][0]; point.velocity = (float)MotionProfile.Points[i][1]; point.timeDurMs = MotionProfile.kDurationMs; point.isLastPoint = (i + 1 == MotionProfile.kNumPoints) ? true : false; point.zeroPos = (i == 0) ? true : false; point.velocityOnly = false; point.profileSlotSelect = 0; _talon.PushMotionProfileTrajectory(point); } /* send the first few pts to Talon */ for (int i = 0; i < 5; ++i) { CTRE.Watchdog.Feed(); Thread.Sleep(10); _talon.ProcessMotionProfileBuffer(); } /*start MP */ _talon.Set(1); } else if (_btns[7] && !_btnsLast[7]) { _talon.SetControlMode(CTRE.TalonSrx.ControlMode.kVoltage); } /* if in voltage mode, update output voltage */ if (_talon.GetControlMode() == CTRE.TalonSrx.ControlMode.kVoltage) { _talon.Set(14.0f * y); } /* copy btns => btnsLast */ System.Array.Copy(_btns, _btnsLast, _btns.Length); }
/** spin in this routine forever */ public void RunForever() { /* config our talon, don't continue until it's successful */ int initStatus = SetupConfig(); /* configuration */ while (initStatus != 0) { Instrument.PrintConfigError(); initStatus = SetupConfig(); /* (re)config*/ } /* robot loop */ while (true) { /* get joystick params */ float leftY = -1f * _gamepad.GetAxis(1); bool btnTopLeftShoulder = _gamepad.GetButton(5); bool btnBtmLeftShoulder = _gamepad.GetButton(7); Deadband(ref leftY); /* keep robot enabled if gamepad is connected and in 'D' mode */ if (_gamepad.GetConnectionStatus() == CTRE.UsbDeviceConnection.Connected) { CTRE.Watchdog.Feed(); } /* set the control mode based on button pressed */ if (btnTopLeftShoulder) { _mode = CTRE.TalonSrx.ControlMode.kPercentVbus; } if (btnBtmLeftShoulder) { _mode = CTRE.TalonSrx.ControlMode.kMotionMagic; } /* calc the Talon output based on mode */ if (_mode == CTRE.TalonSrx.ControlMode.kPercentVbus) { float output = leftY; // [-1, +1] percent duty cycle _talon.SetControlMode(_mode); _talon.Set(output); } else if (_mode == CTRE.TalonSrx.ControlMode.kMotionMagic) { float servoToRotation = leftY * 10;// [-10, +10] rotations _talon.SetControlMode(_mode); _talon.Set(servoToRotation); } /* instrumentation */ Instrument.Process(_talon); /* wait a bit */ System.Threading.Thread.Sleep(5); } }
static void Drive() { if (null == _gamepad) { _gamepad = new CTRE.Gamepad(CTRE.UsbHostDevice.GetInstance()); } float x = _gamepad.GetAxis(0); // Positive is strafe-right, negative is strafe-left float y = -1 * _gamepad.GetAxis(1); // Positive is forward, negative is reverse float turn = _gamepad.GetAxis(2); // Positive is turn-right, negative is turn-left Deadband(ref x); Deadband(ref y); Deadband(ref turn); float leftFrnt_throt = y + x + turn; // left front moves positive for forward, strafe-right, turn-right float leftRear_throt = y - x + turn; // left rear moves positive for forward, strafe-left, turn-right float rghtFrnt_throt = y - x - turn; // right front moves positive for forward, strafe-left, turn-left float rghtRear_throt = y + x - turn; // right rear moves positive for forward, strafe-right, turn-left /* normalize here, there a many way to accomplish this, this is a simple solution */ Normalize(ref leftFrnt_throt); Normalize(ref leftRear_throt); Normalize(ref rghtFrnt_throt); Normalize(ref rghtRear_throt); /* everything up until this point assumes positive spins motor so that robot moves forward. * But typically one side of the robot has to drive negative (red LED) to move robor forward. * Assuming the left-side has to be negative to move robot forward, flip the left side */ leftFrnt_throt *= -1; leftRear_throt *= -1; leftFrnt.Set(leftFrnt_throt); leftRear.Set(leftRear_throt); rghtFrnt.Set(rghtFrnt_throt); rghtRear.Set(rghtRear_throt); }
public static void Main() { uint period = 50000; //period between pulses // I noticed that the normal 1000 to 2000 ms delay does not allow full range on the servo I'm using // so I'm setting up high/low and center values to give a fuller range // eventually create a Servo class with these values and a PWM uint servoLow = 600; uint servoHi = 2400; uint servoCenter = (uint)((servoLow + servoHi) / 2); uint duration = servoCenter; float y; // CTRE.GamepadValues val = new CTRE.GamepadValues(); PWM servo = new PWM(CTRE.HERO.IO.Port3.PWM_Pin7, period, duration, PWM.ScaleFactor.Microseconds, false); servo.Start(); //starts the signal /* loop forever */ while (true) { /* use gamepad axis to set servo */ y = _gamepad.GetAxis(1); duration = (uint)(servoLow + (y + 1) / 2 * (servoHi - servoLow)); // delta has a new duration. Limit it and put it back into duration servo.Duration = duration; /* feed watchdog to keep Talon's enabled if Gamepad is inserted. */ // also display data if (_gamepad.GetConnectionStatus() == CTRE.UsbDeviceConnection.Connected) { CTRE.Watchdog.Feed(); stringBuilder.Append("\t"); stringBuilder.Append(servo.Duration); Debug.Print(stringBuilder.ToString()); stringBuilder.Clear(); } else { // put the servo to the center before the watchdog starves. servo.Duration = servoCenter; } /* run this task every 20ms */ Thread.Sleep(20); } }
static void Run() { float x = _gamepad.GetAxis(1); Deadband(ref x); //Set the Maximum Current Limit for the Talon (in Amps) talon.SetCurrentLimit(10); //Enable the Current Limiting Feature. talon.EnableCurrentLimit(true); talon.Set(x); float current = talon.GetOutputCurrent(); stringBuilder.Append("\t"); stringBuilder.Append(current); stringBuilder.Append("\t"); }
public void RunForever() { /* enable XInput, if gamepad is in DInput it will disable robot. This way you can * use X mode for drive, and D mode for disable (instead of vice versa as the * stock HERO implementation traditionally does). */ CTRE.UsbHostDevice.EnableXInputDevices(); while (true) { if (_gamepad.GetConnectionStatus() == CTRE.UsbDeviceConnection.Connected) { CTRE.Watchdog.Feed(); } /* get buttons */ bool[] btns = new bool[_buttons.Length]; for (uint i = 1; i < 20; ++i) { btns[i] = _gamepad.GetButton(i); } /* get sticks */ for (uint i = 0; i < _sticks.Length; ++i) { _sticks[i] = _gamepad.GetAxis(i); } /* yield for a bit, and track timeouts */ System.Threading.Thread.Sleep(10); if (_rumblingTimeMs < 5000) { _rumblingTimeMs += 10; } /* update the Talon using the shoulder analog triggers */ _tal.Set((_sticks[5] - _sticks[4]) * 0.60f); /* fire some solenoids based on buttons */ _driver.Set(0, _buttons[1]); _driver.Set(1, _buttons[2]); _driver.Set(2, _buttons[3]); _driver.Set(3, _buttons[4]); /* rumble state machine */ switch (_rumblinSt) { /* rumbling is disabled, require some off time to save battery */ case 0: _gamepad.SetLeftRumble(0); _gamepad.SetRightRumble(0); if (_rumblingTimeMs < 100) { /* waiting for off-time */ } else if ((btns[1] && !_buttons[1])) /* button off => on */ { /* off time long enough, user pressed btn */ _rumblingTimeMs = 0; _rumblinSt = 1; _gamepad.SetLeftRumble(0xFF); } else if ((btns[2] && !_buttons[2])) /* button off => on */ { /* off time long enough, user pressed btn */ _rumblingTimeMs = 0; _rumblinSt = 1; _gamepad.SetRightRumble(0xFF); } break; /* already vibrating, track the time */ case 1: if (_rumblingTimeMs > 500) { /* vibrating too long, turn off now */ _rumblingTimeMs = 0; _rumblinSt = 0; _gamepad.SetLeftRumble(0); _gamepad.SetRightRumble(0); } else if ((btns[3] && !_buttons[3])) /* button off => on */ { /* immedietely turn off */ _rumblingTimeMs = 0; _rumblinSt = 0; _gamepad.SetLeftRumble(0); _gamepad.SetRightRumble(0); } else if ((btns[1] && !_buttons[1])) /* button off => on */ { _gamepad.SetLeftRumble(0xFF); } else if ((btns[2] && !_buttons[2])) /* button off => on */ { _gamepad.SetRightRumble(0xFF); } break; } /* this will likley be replaced with a strongly typed interface, * control the LEDs on the center XBOX emblem. */ if (btns[5] && !_buttons[5]) { _gamepad.SetLEDCode(6); } if (btns[6] && !_buttons[6]) { _gamepad.SetLEDCode(7); } if (btns[7] && !_buttons[7]) { _gamepad.SetLEDCode(8); } if (btns[8] && !_buttons[8]) { _gamepad.SetLEDCode(9); } /* build line to print */ StringBuilder sb = new StringBuilder(); foreach (float stick in _sticks) { sb.Append(Format(stick)); sb.Append(","); } sb.Append("-"); for (uint i = 1; i < _buttons.Length; ++i) { if (_buttons[i]) { sb.Append("b" + i + ","); } } /* print useful info */ sb.AppendLine(); Debug.Print(sb.ToString()); /* save button states for button-change states */ _buttons = btns; } }
public static void Main() { /* Inital brightness of LED strip when color cycling */ float _Brightness = 0.5f; /* Flashes LED strip */ bool On = true; /* Variable for timing the flashes */ byte i = 0; while (true) { /* Determines if controller is connected */ if (_Gamepad.GetConnectionStatus() == CTRE.UsbDeviceConnection.Connected) { /* Controller connected for Controller Mode */ OperationState = States.Controller; } else { /* Controller disconnected for Pigeon IMU Mode */ OperationState = States.Pigeon; } if (OperationState == States.Controller) { /* X-Axis of left joystick for hue */ float LeftX = _Gamepad.GetAxis(0); /* Y-Axis of left joystick for hue (Stick inverted) */ float LeftY = -1f * _Gamepad.GetAxis(1); /* Y-Axis of right stick for brightness (Stick inverted)*/ float RightY = -1f * _Gamepad.GetAxis(5); /* Deadband the 3 joysticks */ Deadband(ref LeftX); Deadband(ref LeftY); Deadband(ref RightY); if (LeftX != 0 || LeftY != 0) { /** Left joystick in use, stop color cycling and giver user control */ /* Grab brightness from the right joystick ([-1,1] + 1 * 0.5 => [0,1]) */ float Brightness = (RightY + 1f) * 0.5f; /* Update brightness for color cylcing */ _Brightness = Brightness; /* Update LED strip with left joystick, right joystick, and brightness */ UpdateLedStrip(Brightness, LeftX, LeftY); } else { /** Left joystick not in use, start color cycling */ /* You can change the sequence in ColorSequencer.cs by ordering the premade colors or creating your own values */ _ColorSequencer.Process(); /* Go through a color sequence at half brightness when idle */ UpdateLedStrip(_Brightness, _ColorSequencer.Red, _ColorSequencer.Green, _ColorSequencer.Blue); } } else if (OperationState == States.Pigeon) { /* Check status of Pigeon to see if it is connected */ CTRE.PigeonImu.PigeonState _PigeonState = _Pigeon.GetState(); if (_PigeonState == CTRE.PigeonImu.PigeonState.Ready) { /** Pigeon connected, giver user tilt control */ /* Pull Yaw, Pitch, and Roll from Pigeon */ float[] YPR = new float[3]; _Pigeon.GetYawPitchRoll(YPR); float Yaw = YPR[0]; float Pitch = YPR[1]; float Roll = YPR[2]; /* Mulitply Pitch and Roll by PI and divide by 180 to get radians for trig functions */ float CPitch = Pitch * (float)System.Math.PI / 180; float CRoll = Roll * (float)System.Math.PI / 180; /* Find sine of Pitch and Roll */ CPitch = (float)System.Math.Sin(CPitch); CRoll = (float)System.Math.Sin(CRoll); /* Calculate inverse tangent of Pitch and Roll */ float Value = (float)System.Math.Atan2(CPitch, CRoll); /* Convert back into degrees */ Value = Value * (float)(180 / System.Math.PI); /* Limit the value */ if (Value < 0) { Value += 360; } /* Update LED strip */ UpdateLedStrip_Pigeon(Value); } else { /* Pigeon is not Ready/Available, so flash us */ i++; if (i >= 40) { On = !On; i = 0; } /* Decide if strip is white or off */ if (On == true) { /* White */ UpdateLedStrip(1, 255, 255, 255); } else if (On == false) { /* Off */ UpdateLedStrip(1, 0, 0, 0); } } } /** Quick sleep */ Thread.Sleep(5); } }
////////////////// Function where all the code is executed /////////////////// public static void Main() { // Invert the Motors to the correct direction InitializeMotors(); // Everything in the While Loop will continuously run until the robot is turned off while (true) { // If the Controller is connected to the HERO Development Board, the user can drive the robot if (controller.GetConnectionStatus() == CTRE.UsbDeviceConnection.Connected) { // Get the Joystick Values and Deadband them // Since moving the Joysticks up on the y-axis is in the negative direction, the value of the // left Joystick Y Axis is multiplied by -1 so it's treated as being positive deadbandedLeftJoystickYAxisValue = -DeadbandJoystick(controller.GetAxis(LEFT_Y_AXIS_INDEX)); deadbandedLeftJoystickXAxisValue = DeadbandJoystick(controller.GetAxis(LEFT_X_AXIS_INDEX)); deadbandedRightJoystickXAxisValue = DeadbandJoystick(controller.GetAxis(RIGHT_X_AXIS_INDEX)); // Button used to switch between different Driving Modes // The Button is programmed as a toggle between the two Driving Modes if (controller.GetButton(buttonSelect)) { if (selectButtonPressed == false) { arcadeDriveSelection = !arcadeDriveSelection; selectButtonPressed = true; } } else { selectButtonPressed = false; } if (arcadeDriveSelection == ARCADE_DRIVE) { // If the Right X Axis Joystick Value does not equal zero, the robot will rotate. // Control with the Left Joystick will be disabled if the user decides to rotate the robot // This essentially allows the user to rotate the robot if he/she moves the Right X Axis Joystick Value out // of the Deadband if (deadbandedRightJoystickXAxisValue != 0.0f) { RotateRobot(deadbandedRightJoystickXAxisValue); } // If the Right X Axis Joystick Value is zero, control the direction and magnitude of the speed // of the robot with the Left Joystick else { DriveKiwiBotWithJoystickValuesNoRotation(deadbandedLeftJoystickYAxisValue, deadbandedLeftJoystickXAxisValue); } } else if (arcadeDriveSelection == DRIVING_WITH_STEERING) { DriveRobotWithSteeringControl(deadbandedLeftJoystickYAxisValue, deadbandedRightJoystickXAxisValue); } } // If the Controller is not connected to the HERO Development Board, the user cannot move the robot else { StopAllMotors(); } // Update the Motor Powers calculated in the above code CTRE.Watchdog.Feed(); // Wait 10ms // All the code in the While Loop will execute every 10ms System.Threading.Thread.Sleep(10); } }
public float GetAxis(Axis axis) { return(controller.GetAxis((uint)axis)); }
public void RunForever() { _leftY = new VerticalGauge(_displayModule, 5, 5, 30, 10, DisplayModule.Color.Cyan, DisplayModule.Color.Blue); _rightY = new VerticalGauge(_displayModule, 135, 5, 30, 10, DisplayModule.Color.Yellow, DisplayModule.Color.Red); _leftX = new HorizGauge(_displayModule, 35, 30, 10, 30, DisplayModule.Color.Green, DisplayModule.Color.Magenta); _rightX = new HorizGauge(_displayModule, 85, 30, 10, 30, DisplayModule.Color.Blue, DisplayModule.Color.Orange); _leftCrossHair = _displayModule.AddResourceImageSprite( DisplayModule_Example.Properties.Resources.ResourceManager, DisplayModule_Example.Properties.Resources.BinaryResources.ch2, Bitmap.BitmapImageType.Jpeg, 30, 100); _rightCrossHair = _displayModule.AddResourceImageSprite( DisplayModule_Example.Properties.Resources.ResourceManager, DisplayModule_Example.Properties.Resources.BinaryResources.ch2, Bitmap.BitmapImageType.Jpeg, 100, 100); _labelTitle = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 40, 0, 80, 16); _labelBtn = _displayModule.AddLabelSprite(_smallFont, DisplayModule.Color.White, 30, 50, 100, 15); while (true) { UpdateGauge(_leftX, _gamepad.GetAxis(0)); UpdateGauge(_leftY, _gamepad.GetAxis(1)); UpdateGauge(_rightX, _gamepad.GetAxis(2)); UpdateGauge(_rightY, _gamepad.GetAxis(5)); _leftCrossHair.SetPosition((int)(30 + 15 * _gamepad.GetAxis(0)), 100 + (int)(15 * _gamepad.GetAxis(1))); _rightCrossHair.SetPosition((int)(100 + 15 * _gamepad.GetAxis(2)), 100 + (int)(15 * _gamepad.GetAxis(5))); if (_gamepad.GetConnectionStatus() == CTRE.UsbDeviceConnection.Connected) { _labelTitle.SetText("Connected"); _labelTitle.SetColor(DisplayModule.Color.Green); } else { _labelTitle.SetText("No Gamepad"); _labelTitle.SetColor(DisplayModule.Color.Red); } int idx = GetFirstButton(_gamepad); if (idx < 0) { _labelBtn.SetColor((DisplayModule.Color) 0xA0A0A0); // gray RGB _labelBtn.SetText("No Buttons"); } else { switch (idx % 4) { case 0: _labelBtn.SetColor(DisplayModule.Color.Cyan); break; case 1: _labelBtn.SetColor(DisplayModule.Color.Green); break; case 2: _labelBtn.SetColor(DisplayModule.Color.Red); break; case 3: _labelBtn.SetColor(DisplayModule.Color.Yellow); break; } _labelBtn.SetText("Pressed Button " + idx); } Thread.Sleep(10); } }