/** Initialize Display Module elements */ static void InitDisplayModule() { _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( Hero_DisplayBoard.Properties.Resources.ResourceManager, Hero_DisplayBoard.Properties.Resources.BinaryResources.ch2, Bitmap.BitmapImageType.Jpeg, 30, 100); _rightCrossHair = _DisplayModule.AddResourceImageSprite( Hero_DisplayBoard.Properties.Resources.ResourceManager, Hero_DisplayBoard.Properties.Resources.BinaryResources.ch2, Bitmap.BitmapImageType.Jpeg, 100, 100); _labelTitle = _DisplayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 40, 0, 80, 16); _labelRow1 = _DisplayModule.AddLabelSprite(_smallFont, DisplayModule.Color.White, 30, 46, 100, 15); _labelRow2 = _DisplayModule.AddLabelSprite(_smallFont, DisplayModule.Color.White, 30, 58, 100, 15); _labelRow3 = _DisplayModule.AddLabelSprite(_smallFont, DisplayModule.Color.White, 30, 70, 100, 15); }
public void DisplayInit() { if (displayModeRefresh == false) { image = display.AddResourceImageSprite(Properties.Resources.ResourceManager, Properties.Resources.BinaryResources.img, Bitmap.BitmapImageType.Jpeg, 44, 16); title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 36, 99, 100, 30); title.SetText("TAS Robotics"); displayModeRefresh = true; } }
public Display() { cd_connected = new ChangeDetector(); cd_enabled = new ChangeDetector(); cd_voltage = new ChangeDetector(); cd_limit = new ChangeDetector(); cd_barrelStatus = new ChangeDetector[Shooter.NUMBER_OF_BARRELS]; cd_barrelPSI = new ChangeDetector[Shooter.NUMBER_OF_BARRELS]; for (int i = 0; i < Shooter.NUMBER_OF_BARRELS; i++) { cd_barrelStatus[i] = new ChangeDetector(); cd_barrelPSI[i] = new ChangeDetector(); } DisplayModule _displayModule = new DisplayModule(CTRE.HERO.IO.Port1, DisplayModule.OrientationType.Portrait); /* lets pick a font */ Font _bigFont = Properties.Resources.GetFont(Properties.Resources.FontResources.Freesans_bold_18); int size = 20; int f_y = 0; _labelConnected = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, f_y, 128, size); f_y += size; _labelEnabled = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, f_y, 128, size); f_y += size; _labelVoltage = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, f_y, 128, size); f_y += size; _label_limit = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, f_y, 128, size); _labelBarrelStatus = new DisplayModule.LabelSprite[Shooter.NUMBER_OF_BARRELS]; _labelBarrelPSI = new DisplayModule.LabelSprite[Shooter.NUMBER_OF_BARRELS]; f_y = 80; _labelBarrelStatus[0] = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, f_y, 64, size); _labelBarrelStatus[1] = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 64, f_y, 64, size); f_y += size; _labelBarrelPSI[0] = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, f_y, 64, size); _labelBarrelPSI[1] = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 64, f_y, 64, size); if (false) { // if we are Landscape, then DisplayHeight is the X screen dimension, and DisplayWidth is the Y dimension for (int x = 0; x < _displayModule.DisplayWidth; x += 16) { _displayModule.AddRectSprite(DisplayModule.Color.White, x, 0, 1, _displayModule.DisplayHeight); } for (int y = 0; y < _displayModule.DisplayHeight; y += 16) { _displayModule.AddRectSprite(DisplayModule.Color.White, 0, y, _displayModule.DisplayWidth, 1); } } RSL_1 = new OutputPort(CTRE.HERO.IO.Port5.Pin6, false); }
public void DisplayMotion() { if (displayModeRefresh == false) { display.Clear(); title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 38, 17, 120, 15); label1 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 20, 72, 130, 15); label2 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 20, 92, 130, 15); rect1 = display.AddRectSprite(DisplayModule.Color.White, 20, 52, 120, 10); displayModeRefresh = true; } if (title == null || label1 == null || label2 == null || rect1 == null) { display.Clear(); title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 38, 17, 120, 15); label1 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 20, 72, 130, 15); label2 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 20, 92, 130, 15); rect1 = display.AddRectSprite(DisplayModule.Color.White, 20, 52, 120, 10); } string colorString = "0x00"; string red, blue, green; int colorInt = (int)System.Math.Round(output / 4096 / analog0 * 100); if (colorInt > 0) { blue = (100 - colorInt).ToString("X2"); green = "ff"; red = (100 - colorInt).ToString("X2"); } else if (colorInt < 0) { blue = (100 + colorInt).ToString("X2"); green = (100 + colorInt).ToString("X2"); red = "ff"; } else { blue = "ff"; green = "ff"; red = "ff"; } colorString = colorString + blue + green + red; rect1.SetColor((DisplayModule.Color)Convert.ToInt32(colorString, 16)); label1.SetText("Ticks: " + ((int)System.Math.Round(output)).ToString()); label2.SetText("Rotations: " + ((double)(output / 4096)).ToString()); title.SetText("Motion Magic"); }
public static void Main() { //CSK 10/22/2019 .Follow method tells the follower motor to do whatever the lead motor does //The //Simplifies code a little bit leftdrive2.Follow(leftdrive1, FollowerType.PercentOutput); rightdrive2.Follow(rightdrive1, FollowerType.PercentOutput); //brushlessTest.Follow(rightdrive1, FollowerType.PercentOutput); #if (HASDISPLAY) _AMLogo = _displayModule.AddResourceImageSprite(Properties.Resources.ResourceManager, Properties.Resources.BinaryResources.andymark_logo_160x26, Bitmap.BitmapImageType.Jpeg, 0, 0); _labelTitle = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, 28, 160, 15); _labelBtn = _displayModule.AddLabelSprite(_smallFont, DisplayModule.Color.Cyan, 30, 60, 100, 10); _leftCrossHair = _displayModule.AddResourceImageSprite(Properties.Resources.ResourceManager, Properties.Resources.BinaryResources.crosshair, Bitmap.BitmapImageType.Jpeg, lftCrossHairOrigin, 100); _rightCrossHair = _displayModule.AddResourceImageSprite(Properties.Resources.ResourceManager, Properties.Resources.BinaryResources.crosshair, Bitmap.BitmapImageType.Jpeg, rtCrossHairOrigin, 100); _labelThrottle = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, 45, 75, 15); _labelSteering = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 80, 45, 75, 15); #endif /* loop forever */ while (true) { if (_gamepad.GetConnectionStatus() == CTRE.Phoenix.UsbDeviceConnection.Connected) { /* feed watchdog to keep Talon's enabled */ CTRE.Phoenix.Watchdog.Feed(); } /* drive robot using gamepad */ Drive(); } }
/* main functions */ private static void runForever() //runs forever { byte [] readData = new byte[4]; eeprom.ReadBytes(eepromAddr, readData, 4); uint selectedAuton = (uint)(readData[0] % autonList.Length); //inialize the selected auton to 0 uint lastSelect = 0; //last selected auton bool pressed = false; //button debounce stuff bool lastPress = false; //button debounce stuff DisplayModule.LabelSprite header = displayModule.AddLabelSprite(SMALLFONT, WHITE, 5, 5, 118, 16); //Makes text object for headers header.SetText("Selected Actual"); //spaces for spacing DisplayModule.LabelSprite[] list = new DisplayModule.LabelSprite[autonList.Length]; //array of text objects for (int i = 0; i < autonList.Length; i++) { list[i] = displayModule.AddLabelSprite(SMALLFONT, WHITE, 18, 26 + 13 * i, 91, 13); //Makes text object for list of autons list[i].SetText(autonList[i]); //sets text to the string on top } check = displayModule.AddResourceImageSprite(Properties.Resources.ResourceManager, Properties.Resources.BinaryResources._checked, Bitmap.BitmapImageType.Jpeg, 5, 29 + 13 * (int)selectedAuton); //generates a cursor arrow retcheck = displayModule.AddResourceImageSprite(Properties.Resources.ResourceManager, Properties.Resources.BinaryResources.green_check, Bitmap.BitmapImageType.Jpeg, 110, 29 + 13 * (int)selectedAuton); //generates a green check from RIO while (true) //loop forever { pressed = HeroButton.Read(); //checks for button press if (pressed != lastPress && pressed == true) { selectedAuton++; //move to next auton selectedAuton = selectedAuton % (uint)list.Length; //wraps the cursor around byte [] toWrite = new byte[4]; toWrite[0] = (byte)selectedAuton; eeprom.WriteBytes(eepromAddr, toWrite, 4); } lastPress = pressed; //debounce sendAuton(selectedAuton, 1, 100); //send 1 byte every 100ms, 0-255 auton mode uint rioAuton = (uint)loadAuton(1); //get 1 byte for RIO auton return disp(list, selectedAuton, lastSelect, rioAuton); lastSelect = selectedAuton; } }
public void DisplaySettings() { if (displayModeRefresh == false) { title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 28, 17, 120, 15); label1 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 14, 52, 140, 15); label2 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 14, 72, 140, 15); label3 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 14, 92, 140, 15); displayModeRefresh = true; } if (title == null || label1 == null || label2 == null || label3 == null) { display.Clear(); title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 28, 17, 120, 15); label1 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 14, 52, 140, 15); label2 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 14, 72, 140, 15); label3 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 14, 92, 140, 15); } label1.SetText("Max Rotations: " + analog0.ToString()); label2.SetText("Velocity: " + analog1.ToString()); label3.SetText("Acceleration: " + analog2.ToString()); title.SetText("Motion Settings"); }
public static void Main() { // Game Controller GameController gamepad = new GameController(UsbHostDevice.GetInstance()); // NinaB Font Font ninaB = Properties.Resources.GetFont(Properties.Resources.FontResources.NinaB); // Initializing a display module: DisplayModule(port, orientation) DisplayModule displayModule = new DisplayModule(CTRE.HERO.IO.Port8, DisplayModule.OrientationType.Landscape); while (true) { // Connect the game controller first so that the sprites show up if (gamepad.GetConnectionStatus() == UsbDeviceConnection.Connected) { // Erases everything on the display displayModule.Clear(); // Adding labels: [Display Module Name].AddLabelSprite(font, colour, x_pos, y_pos, width, height) DisplayModule.LabelSprite title = displayModule.AddLabelSprite(ninaB, DisplayModule.Color.White, 27, 17, 120, 15); DisplayModule.LabelSprite x_label = displayModule.AddLabelSprite(ninaB, DisplayModule.Color.White, 80, 65, 80, 15); DisplayModule.LabelSprite y_label = displayModule.AddLabelSprite(ninaB, DisplayModule.Color.White, 80, 85, 80, 15); // Adding rectangles: [Display Module Name].AddRectSprite(colour, x_pos, y_pos, width, height) DisplayModule.RectSprite x_rect = displayModule.AddRectSprite(DisplayModule.Color.White, 20, 55, 18, 55); DisplayModule.RectSprite y_rect = displayModule.AddRectSprite(DisplayModule.Color.White, 47, 55, 18, 55); // Everything gets cleared when the game controller is unplugged while (gamepad.GetConnectionStatus() == UsbDeviceConnection.Connected) { // Declares and resets the joystick double x_value = gamepad.GetAxis(0); double y_value = -gamepad.GetAxis(1); if (x_value < 0.05 && x_value > -0.05) { x_value = 0; } if (y_value < 0.05 && y_value > -0.05) { y_value = 0; } // Changes the color of the rectangle (x-value of the left joystick): [Rectangle Name].SetColor(colour) if (x_value > 0.05) { x_rect.SetColor(DisplayModule.Color.Green); } else if (x_value < -0.05) { x_rect.SetColor(DisplayModule.Color.Red); } else { x_rect.SetColor(DisplayModule.Color.White); } // Changes the color of the rectangle (y-value of the left joystick): [Rectangle Name].SetColor(colour) if (y_value > 0.05) { y_rect.SetColor(DisplayModule.Color.Green); } else if (y_value < -0.05) { y_rect.SetColor(DisplayModule.Color.Red); } else { y_rect.SetColor(DisplayModule.Color.White); } // Sets the text that the label displays: [Label Name].SetText(text: string) title.SetText("Joystick Control"); x_label.SetText("X: " + x_value.ToString()); y_label.SetText("Y: " + y_value.ToString()); } } else { // Erases everything on the display displayModule.Clear(); // Adding images: [Display Module Name].AddResourceImageSprite(resource_manager, img_ID, img_type, x_pos, y_pos) DisplayModule.ResourceImageSprite image = displayModule.AddResourceImageSprite(Properties.Resources.ResourceManager, Properties.Resources.BinaryResources.img, Bitmap.BitmapImageType.Jpeg, 44, 16); // Adding labels: [Display Module Name].AddLabelSprite(font, colour, x_pos, y_pos, width, height) DisplayModule.LabelSprite text = displayModule.AddLabelSprite(ninaB, DisplayModule.Color.White, 36, 99, 100, 30); // Sets the text that the label displays: [Label Name].SetText(text: string) text.SetText("TAS Robotics"); // Keeps the image and text while the gamepad is unplugged while (gamepad.GetConnectionStatus() == UsbDeviceConnection.NotConnected) { } } System.Threading.Thread.Sleep(100); } }
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() == 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); } }
public static void Main() { /* Start the compressor */ _pcm.StartCompressor(); /* Tracking variables */ bool lastCompState = false; bool CompState = false; int compStartCount = 0; long now = DateTime.Now.Ticks; /* Display Module Elements */ DisplayModule.LabelSprite _labelTitle = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, 0, 120, 16); DisplayModule.LabelSprite _labelCnt = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, 16, 120, 16); while (true) { /* Always enable actuators during this test */ CTRE.Phoenix.Watchdog.Feed(); /* Simple gamepad control */ if (_gamepad.GetButton(2)) { _talon.Set(ControlMode.PercentOutput, -1.0f); } else if (_gamepad.GetButton(4)) { _talon.Set(ControlMode.PercentOutput, +1.0f); } else { float y = _gamepad.GetAxis(1); CTRE.Phoenix.Util.Deadband(ref y); _talon.Set(ControlMode.PercentOutput, y); } #if false //Switch the compressor on/off //now = DateTime.Now.Ticks; //switch (switchState) //{ // case true: // if (now - lastSwitch > kOnTime) // { // switchState = false; // lastSwitch = now; // } // break; // case false: // if (now - lastSwitch > kOffTime) // { // switchState = true; // lastSwitch = now; // } // break; // default: // break; //} //_pcm.SetSolenoidOutput(0, switchState); #endif /* Compressor Control */ _pcm.SetSolenoidOutput(0, _pcm.GetPressureSwitchValue()); //Debug.Print("" + _pcm.GetPressureSwitchValue()); /* Compressor Check */ _pcm.GetLowLevelObject().GetCompressorOn(out CompState); if (CompState && !lastCompState) { compStartCount++; } lastCompState = CompState; /* Display Module Output */ _labelTitle.SetText("Comp Start Count:"); _labelCnt.SetText("" + compStartCount); Thread.Sleep(5); } }
public static void Main() { //vvvCSK 10/28/2019 Copied from CTRE HeroPixyDrive examplevvv /* Forword/Backward Scalor */ const float kScalarX = 0.50f; /* Left/Right Scalor */ const float kScalarY = 0.50f; /* Turning Scalor */ const float kScalarTwist = 0.30f; /* Ramp Rate */ const float kVoltageRampSec = 0.25f; //^^^CSK 10/28/2019 Copied from CTRE HeroPixyDrive example^^^ /* Configure Talons to operate in percentage VBus mode, and Ramp Up Voltage*/ #if TALONSRX foreach (TalonSRX temp in Talons) #else foreach (VictorSPX temp in Victors) #endif { temp.Set(ControlMode.PercentOutput, 0); temp.ConfigOpenloopRamp(kVoltageRampSec); } //^^^CSK 10/28/2019 Copied from CTRE HeroPixyDrive example^^^ #if (HASDISPLAY) _AMLogo = _displayModule.AddResourceImageSprite(Properties.Resources.ResourceManager, Properties.Resources.BinaryResources.andymark_logo_160x26, Bitmap.BitmapImageType.Jpeg, 0, 0); _labelTitle = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 0, 28, 160, 15); _labelBtn = _displayModule.AddLabelSprite(_smallFont, DisplayModule.Color.Cyan, 30, 60, 100, 10); _leftCrossHair = _displayModule.AddResourceImageSprite(Properties.Resources.ResourceManager, Properties.Resources.BinaryResources.crosshair, Bitmap.BitmapImageType.Jpeg, lftCrossHairOrigin, 100); _rightCrossHair = _displayModule.AddResourceImageSprite(Properties.Resources.ResourceManager, Properties.Resources.BinaryResources.crosshair, Bitmap.BitmapImageType.Jpeg, rtCrossHairOrigin, 100); //CSK 10/29/2019 This tells the display where to put the motor "speed" info on the screen _labelFrontMotors = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 2, 30, 134, 15); _labelRearMotors = _displayModule.AddLabelSprite(_bigFont, DisplayModule.Color.White, 7, 45, 128, 15); #endif /* loop forever */ while (true) { if (_gamepad.GetConnectionStatus() == CTRE.Phoenix.UsbDeviceConnection.Connected) { /* feed watchdog to keep Talon's enabled */ CTRE.Phoenix.Watchdog.Feed(); } /* Regular mecanum drive that is scaled and Gamepad joysticks have been adjusted */ //CSK 10/30/2019 With "standard" AM FRC wiring (M+ to redline terminal with bump) rotation is counter clockwise //Based on this wiring signs have been applied to make motion match the joystick control expectations float X = -1 * _gamepad.GetAxis(LEFT_JOY_X); float Y = _gamepad.GetAxis(LEFT_JOY_Y); float Twist = -1 * _gamepad.GetAxis(RIGHT_JOY_X); MecanumDrive(Y * kScalarY, X * kScalarX, Twist * kScalarTwist); } }
public void DisplayPiston() { if (displayModeRefresh == false) { title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 36, 17, 120, 15); label1 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 70, 56, 80, 15); label2 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 70, 76, 80, 15); label3 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 70, 96, 80, 15); rect1 = display.AddRectSprite(DisplayModule.Color.White, 10, 55, 18, 55); rect2 = display.AddRectSprite(DisplayModule.Color.White, 37, 55, 18, 55); displayModeRefresh = true; } if (title == null || label1 == null || label2 == null || label3 == null || rect1 == null || rect2 == null) { display.Clear(); title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 36, 17, 120, 15); label1 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 70, 56, 80, 15); label2 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 70, 76, 80, 15); label3 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 70, 96, 80, 15); rect1 = display.AddRectSprite(DisplayModule.Color.White, 10, 55, 18, 55); rect2 = display.AddRectSprite(DisplayModule.Color.White, 37, 55, 18, 55); } if (pistonState == true) { rect1.SetColor(DisplayModule.Color.Blue); label1.SetText("State: Out"); } else { rect1.SetColor(DisplayModule.Color.White); label1.SetText("State: In"); } string colorString = "0x00"; string red, blue, green; int colorInt = (int)System.Math.Round(yAxisB * 100); if (colorInt > 0) { blue = (100 - colorInt).ToString("X2"); green = "ff"; red = (100 - colorInt).ToString("X2"); } else if (colorInt < 0) { blue = (100 + colorInt).ToString("X2"); green = (100 + colorInt).ToString("X2"); red = "ff"; } else { blue = "ff"; green = "ff"; red = "ff"; } colorString = colorString + blue + green + red; rect2.SetColor((DisplayModule.Color)Convert.ToInt32(colorString, 16)); label2.SetText("Speed: " + (int)System.Math.Round(yAxisB * 1000)); label3.SetText("Sleep: " + tSleep.ToString() + "ms"); title.SetText("Pneumatic Control"); }
public void DisplayValues() { if (displayModeRefresh == false) { title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 37, 17, 120, 15); label1 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 15, 44, 120, 15); label2 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 15, 64, 120, 15); label3 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 15, 84, 120, 15); label4 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 15, 104, 120, 15); rect1 = display.AddRectSprite(DisplayModule.Color.White, 128, 44, 15, 15); rect2 = display.AddRectSprite(DisplayModule.Color.White, 128, 64, 15, 15); rect3 = display.AddRectSprite(DisplayModule.Color.White, 128, 84, 15, 15); rect4 = display.AddRectSprite(DisplayModule.Color.White, 128, 104, 15, 15); displayModeRefresh = true; } if (title == null || label1 == null || label2 == null || label3 == null || label4 == null || rect1 == null || rect2 == null || rect3 == null || rect4 == null) { display.Clear(); title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 37, 17, 120, 15); label1 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 15, 44, 120, 15); label2 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 15, 64, 120, 15); label3 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 15, 84, 120, 15); label4 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 15, 104, 120, 15); rect1 = display.AddRectSprite(DisplayModule.Color.White, 128, 44, 15, 15); rect2 = display.AddRectSprite(DisplayModule.Color.White, 128, 64, 15, 15); rect3 = display.AddRectSprite(DisplayModule.Color.White, 128, 84, 15, 15); rect4 = display.AddRectSprite(DisplayModule.Color.White, 128, 104, 15, 15); } if (xState == true) { rect1.SetColor(DisplayModule.Color.Green); } else { rect1.SetColor(DisplayModule.Color.White); } if (yState == true) { rect2.SetColor(DisplayModule.Color.Green); } else { rect2.SetColor(DisplayModule.Color.White); } if (aState == true) { rect3.SetColor(DisplayModule.Color.Green); } else { rect3.SetColor(DisplayModule.Color.White); } if (bState == true) { rect4.SetColor(DisplayModule.Color.Green); } else { rect4.SetColor(DisplayModule.Color.White); } label1.SetText("Button X: " + ((int)System.Math.Round(xSave)).ToString()); label2.SetText("Button Y: " + ((int)System.Math.Round(ySave)).ToString()); label3.SetText("Button B: " + ((int)System.Math.Round(bSave)).ToString()); label4.SetText("Button A: " + ((int)System.Math.Round(aSave)).ToString()); title.SetText("Motion Values"); }
public void DisplayOutput() { if (displayModeRefresh == false) { title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 34, 17, 120, 15); label1 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 80, 56, 80, 15); label2 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 80, 76, 80, 15); label3 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 80, 96, 80, 15); rect1 = display.AddRectSprite(DisplayModule.Color.White, 20, 55, 18, 55); rect2 = display.AddRectSprite(DisplayModule.Color.White, 47, 55, 18, 55); displayModeRefresh = true; } if (title == null || label1 == null || label2 == null || label3 == null || rect1 == null || rect2 == null) { display.Clear(); title = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 34, 17, 120, 15); label1 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 80, 55, 80, 15); label2 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 80, 75, 80, 15); label3 = display.AddLabelSprite(ninaB, DisplayModule.Color.White, 80, 95, 80, 15); rect1 = display.AddRectSprite(DisplayModule.Color.White, 20, 55, 18, 55); rect2 = display.AddRectSprite(DisplayModule.Color.White, 47, 55, 18, 55); } string colorStringX = "0x00"; string colorStringY = "0x00"; string redX, blueX, greenX; string redY, blueY, greenY; int colorIntX = (int)System.Math.Round(xAxisA * 100); int colorIntY = (int)System.Math.Round(yAxisA * 100); if (colorIntX > 0) { blueX = (100 - colorIntX).ToString("X2"); greenX = "ff"; redX = (100 - colorIntX).ToString("X2"); } else if (colorIntX < 0) { blueX = (100 + colorIntX).ToString("X2"); greenX = (100 + colorIntX).ToString("X2"); redX = "ff"; } else { blueX = "ff"; greenX = "ff"; redX = "ff"; } if (colorIntY > 0) { blueY = (100 - colorIntY).ToString("X2"); greenY = "ff"; redY = (100 - colorIntY).ToString("X2"); } else if (colorIntY < 0) { blueY = (100 + colorIntY).ToString("X2"); greenY = (100 + colorIntY).ToString("X2"); redY = "ff"; } else { blueY = "ff"; greenY = "ff"; redY = "ff"; } colorStringX = colorStringX + blueX + greenX + redX; colorStringY = colorStringY + blueY + greenY + redY; rect1.SetColor((DisplayModule.Color)Convert.ToInt32(colorStringX, 16)); rect2.SetColor((DisplayModule.Color)Convert.ToInt32(colorStringY, 16)); label1.SetText("X: " + xAxisA.ToString()); label2.SetText("Y: " + yAxisA.ToString()); label3.SetText("Angle: " + ((int)System.Math.Round(angle)).ToString()); title.SetText("Motor Control"); }