Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        public VerticalGauge(DisplayModule displayModule, int x, int y, int height, int width, DisplayModule.Color topCol, DisplayModule.Color btmCol)
        {
            _displayModule = displayModule;
            _x             = x;
            _y             = y;
            _height        = height;
            _width         = width;

            _top = 0;
            _btm = height;

            _topCol = topCol;
            _btmCol = btmCol;

            _backRect = _displayModule.AddRectSprite(DisplayModule.Color.White, x, _y, width + 2, _top + _btm + 5);

            _topRect = _displayModule.AddRectSprite(_topCol, _x + 1, _y + 1, _width, _top + 1);

            _btmRect = _displayModule.AddRectSprite(_btmCol, _x + 1, _y + 1 + _top + 1, _width, _btm + 1);
        }
        public HorizGauge(DisplayModule displayModule, int x, int y, int height, int width, DisplayModule.Color topCol, DisplayModule.Color btmCol)
        {
            _displayModule = displayModule;
            _x             = x;
            _y             = y;
            _height        = height;
            _width         = width;

            _left = 0;
            _rght = width;

            _leftCol = topCol;
            _rghtCol = btmCol;

            _backRect = _displayModule.AddRectSprite(DisplayModule.Color.White, x, _y, _left + _rght + 4, _height + 2);

            _leftRect = _displayModule.AddRectSprite(_leftCol, _x + 1, _y + 1, _left + 1, _height);

            _rghtRect = _displayModule.AddRectSprite(_rghtCol, _x + 1 + _left + 1, _y + 1, _rght + 1, _height);
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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");
        }
Ejemplo n.º 6
0
        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");
        }
Ejemplo n.º 7
0
        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");
        }