示例#1
0
        private TetrisApp()
        {
            // Create the object that configures the GPIO pins to buttons.
            GPIOButtonInputProvider inputProvider = new GPIOButtonInputProvider(null);

            // Assign GPIO / Key functions to GPIOButtonInputProvider
#if ESP32   // This is an example mapping, work them out for your needs!
            inputProvider.AddButton(12, Button.VK_LEFT, true);
            inputProvider.AddButton(13, Button.VK_RIGHT, true);
            inputProvider.AddButton(34, Button.VK_UP, true);
            inputProvider.AddButton(35, Button.VK_SELECT, true);
            inputProvider.AddButton(36, Button.VK_DOWN, true);

            DisplayControl.Initialize(new SpiConfiguration(1, 22, 21, 18, 5), new ScreenConfiguration(0, 0, 320, 240));
#elif STM32F769I_DISCO // This is an example (working) button map, work the actual pins out for your need!
            //WARNING: Invalid pin mappings will never be returned, and may need you to reflash the device!
            inputProvider.AddButton(PinNumber('J', 0), Button.VK_LEFT, true);
            inputProvider.AddButton(PinNumber('J', 1), Button.VK_RIGHT, true);
            inputProvider.AddButton(PinNumber('J', 3), Button.VK_UP, true);
            inputProvider.AddButton(PinNumber('J', 4), Button.VK_DOWN, true);
            inputProvider.AddButton(PinNumber('A', 6), Button.VK_SELECT, true);

            DisplayControl.Initialize(new SpiConfiguration(), new ScreenConfiguration()); //TODO: surely this should "actually" be I2C?!
#else
            throw new System.Exception("Unknown button and/or display mapping!");
#endif

            // Create ExtendedWeakReference for high score table
            highScoreEWD = ExtendedWeakReference.RecoverOrCreate(
                typeof(TetrisApp),
                0,
                ExtendedWeakReference.c_SurvivePowerdown);
            // Set persistence priority
            highScoreEWD.Priority = (int)ExtendedWeakReference.PriorityLevel.Important;

            // Try to recover previously saved HighScore
            HighScore = (HighScoreTable)highScoreEWD.Target;

            // If nothing was recovered - create new
            if (HighScore == null)
            {
                HighScore = new HighScoreTable();
            }
        }
示例#2
0
        private TetrisApp()
        {
            // Create the object that configures the GPIO pins to buttons.
            GpioButtonInputProvider inputProvider = new GpioButtonInputProvider(null);

            // Create ExtendedWeakReference for high score table
            highScoreEWD = ExtendedWeakReference.RecoverOrCreate(
                typeof(TetrisApp),
                0,
                ExtendedWeakReference.c_SurvivePowerdown);
            // Set persistance priority
            highScoreEWD.Priority = (int)ExtendedWeakReference.PriorityLevel.Important;

            // Try to recover previously saved HighScore
            HighScore = (HighScoreTable)highScoreEWD.Target;

            // If nothing was recovered - create new
            if (HighScore == null)
            {
                HighScore = new HighScoreTable();
            }
        }
示例#3
0
        private TetrisApp()
        {
            // Create the object that configures the GPIO pins to buttons.
            GPIOButtonInputProvider inputProvider = new GPIOButtonInputProvider(null);

            // Assign GPIO / Key functions to GPIOButtonInputProvider
            // Esp32
            inputProvider.AddButton(12, Button.VK_LEFT, true);
            inputProvider.AddButton(13, Button.VK_RIGHT, true);
            inputProvider.AddButton(34, Button.VK_UP, true);
            inputProvider.AddButton(35, Button.VK_SELECT, true);
            inputProvider.AddButton(36, Button.VK_DOWN, true);

            // STM32
            //inputProvider.AddButton(PinNumber('A', 0), Button.VK_LEFT, true);
            //inputProvider.AddButton(PinNumber('A', 1), Button.VK_RIGHT, true);
            //inputProvider.AddButton(PinNumber('A', 2), Button.VK_UP, true);
            //inputProvider.AddButton(PinNumber('A', 3), Button.VK_SELECT, true);
            //inputProvider.AddButton(PinNumber('A', 4), Button.VK_DOWN, true);


            // Create ExtendedWeakReference for high score table
            highScoreEWD = ExtendedWeakReference.RecoverOrCreate(
                typeof(TetrisApp),
                0,
                ExtendedWeakReference.c_SurvivePowerdown);
            // Set persistence priority
            highScoreEWD.Priority = (int)ExtendedWeakReference.PriorityLevel.Important;

            // Try to recover previously saved HighScore
            HighScore = (HighScoreTable)highScoreEWD.Target;

            // If nothing was recovered - create new
            if (HighScore == null)
            {
                HighScore = new HighScoreTable();
            }
        }