예제 #1
0
        void PlayersCount_ButtonPressed(BrainPad.Button.DPad button, BrainPad.Button.State state)
        {
            switch (button)
            {
            case BrainPad.Button.DPad.Up:
                if (players < MAX_PLAYERS)
                {
                    players++;
                    DrawPlayers();
                }
                break;

            case BrainPad.Button.DPad.Down:
                if (players > 2)
                {
                    players--;
                    DrawPlayers();
                }
                break;

            case BrainPad.Button.DPad.Right:
                onCompletionEvent.Set();
                break;
            }
        }
예제 #2
0
 private static void Button_ButtonPressed(BrainPad.Button.DPad button, BrainPad.Button.State state)
 {
     if (BrainPad.Button.IsRightPressed())
     {
         toggle = false;
     }
     else if (BrainPad.Button.IsLeftPressed())
     {
         toggle = true;
     }
 }
예제 #3
0
    void Button_ButtonChanged(BrainPad.Button.DPad button, BrainPad.Button.State state)
    {
        switch (choiceMenu)
        {
        case Menu.Bulb:
            if ((button == BrainPad.Button.DPad.Down) && (state == BrainPad.Button.State.Pressed) && activeDown)
            {
                choiceMenu = Menu.Traffic;
                BrainPad.Display.DrawText(10, 20, "1. Bulb", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 30, "2. Traffic", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Up) && (state == BrainPad.Button.State.Pressed) && activeUp)
            {
                choiceMenu = Menu.Game;
                BrainPad.Display.DrawText(10, 20, "1. Bulb", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 80, "7. Game", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Right) && (state == BrainPad.Button.State.Pressed))
            {
                activeUp   = false; activeDown = false;
                choiceProg = progDemo.Bulb;
            }
            else if ((button == BrainPad.Button.DPad.Left) && (state == BrainPad.Button.State.Pressed) && (choiceProg != progDemo.Attente))
            {
                choiceProg = progDemo.Attente;
                activeUp   = true; activeDown = true;
            }
            break;

        case Menu.Traffic:
            if ((button == BrainPad.Button.DPad.Down) && (state == BrainPad.Button.State.Pressed) && activeDown)
            {
                choiceMenu = Menu.Temperature;
                BrainPad.Display.DrawText(10, 30, "2. Traffic", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 40, "3. Temperature Sensor", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Up) && (state == BrainPad.Button.State.Pressed) && activeUp)
            {
                choiceMenu = Menu.Bulb;
                BrainPad.Display.DrawText(10, 30, "2. Traffic", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 20, "1. Bulb", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Right) && (state == BrainPad.Button.State.Pressed))
            {
                activeUp   = false; activeDown = false;
                choiceProg = progDemo.Traffic;
            }
            else if ((button == BrainPad.Button.DPad.Left) && (state == BrainPad.Button.State.Pressed) && (choiceProg != progDemo.Attente))
            {
                choiceProg = progDemo.Attente;
                activeUp   = true; activeDown = true;
            }
            break;

        case Menu.Temperature:
            if ((button == BrainPad.Button.DPad.Down) && (state == BrainPad.Button.State.Pressed) && activeDown)
            {
                choiceMenu = Menu.Light;
                BrainPad.Display.DrawText(10, 40, "3. Temperature Sensor", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 50, "4. Light Sensor", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Up) && (state == BrainPad.Button.State.Pressed) && activeUp)
            {
                choiceMenu = Menu.Traffic;
                BrainPad.Display.DrawText(10, 40, "3. Temperature Sensor", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 30, "2. Traffic", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Right) && (state == BrainPad.Button.State.Pressed))
            {
                activeUp = false; activeDown = false;
                BrainPad.Display.Clear();
                BrainPad.Display.DrawText(40, 0, "Temperature demo", BrainPad.Color.White);
                choiceProg = progDemo.Temperature;
            }
            else if ((button == BrainPad.Button.DPad.Left) && (state == BrainPad.Button.State.Pressed) && (choiceProg != progDemo.Attente))
            {
                choiceProg = progDemo.Attente;
                BrainPad.Display.DrawText(10, 100, "INFO: End, please wait", BrainPad.Color.White);
                while (!finTemp)
                {
                    ;
                }
                BrainPad.Display.Clear();
                DisplayMenu();
                BrainPad.Display.DrawText(10, 40, "3. Temperature Sensor", BrainPad.Color.Yellow);
                activeUp = true; activeDown = true;
            }
            break;

        case Menu.Light:
            if ((button == BrainPad.Button.DPad.Down) && (state == BrainPad.Button.State.Pressed) && activeDown)
            {
                choiceMenu = Menu.Accelerometer;
                BrainPad.Display.DrawText(10, 50, "4. Light Sensor", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 60, "5. Accelerometer", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Up) && (state == BrainPad.Button.State.Pressed) && activeUp)
            {
                choiceMenu = Menu.Temperature;
                BrainPad.Display.DrawText(10, 50, "4. Light Sensor", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 40, "3. Temperature Sensor", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Right) && (state == BrainPad.Button.State.Pressed))
            {
                activeUp = false; activeDown = false;
                BrainPad.Display.Clear();
                InfoLight();
                BrainPad.LightBulb.SetColor(BrainPad.Color.White);
                choiceProg = progDemo.Light;
            }
            else if ((button == BrainPad.Button.DPad.Left) && (state == BrainPad.Button.State.Pressed) && (choiceProg != progDemo.Attente))
            {
                choiceProg = progDemo.Attente;
                BrainPad.Display.Clear();
                DisplayMenu();
                BrainPad.Display.DrawText(10, 50, "4. Light Sensor", BrainPad.Color.Yellow);
                activeUp = true; activeDown = true;
            }
            break;

        case Menu.Accelerometer:
            if ((button == BrainPad.Button.DPad.Down) && (state == BrainPad.Button.State.Pressed) && activeDown)
            {
                choiceMenu = Menu.Buzzer;
                BrainPad.Display.DrawText(10, 60, "5. Accelerometer", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 70, "6. Buzzer", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Up) && (state == BrainPad.Button.State.Pressed) && activeUp)
            {
                choiceMenu = Menu.Light;
                BrainPad.Display.DrawText(10, 60, "5. Accelerometer", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 50, "4. Light Sensor", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Right) && (state == BrainPad.Button.State.Pressed))
            {
                activeUp = false; activeDown = false;
                BrainPad.Display.Clear();
                BrainPad.Display.DrawText(35, 0, "Accelerometer demo", BrainPad.Color.White);
                choiceProg = progDemo.Accelerometer;
            }
            else if ((button == BrainPad.Button.DPad.Left) && (state == BrainPad.Button.State.Pressed) && (choiceProg != progDemo.Attente))
            {
                choiceProg = progDemo.Attente;
                Thread.Sleep(150);
                BrainPad.Display.Clear();
                DisplayMenu();
                BrainPad.Display.DrawText(10, 60, "5. Accelerometer", BrainPad.Color.Yellow);
                activeUp = true; activeDown = true;
            }
            break;

        case Menu.Buzzer:
            if ((button == BrainPad.Button.DPad.Down) && (state == BrainPad.Button.State.Pressed) && activeDown)
            {
                choiceMenu = Menu.Game;
                BrainPad.Display.DrawText(10, 70, "6. Buzzer", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 80, "7. Game", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Up) && (state == BrainPad.Button.State.Pressed) && activeUp)
            {
                choiceMenu = Menu.Accelerometer;
                BrainPad.Display.DrawText(10, 70, "6. Buzzer", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 60, "5. Accelerometer", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Right) && (state == BrainPad.Button.State.Pressed))
            {
                activeUp = false; activeDown = false;
                BrainPad.Display.Clear();
                InfoBuzzer();
                choiceProg = progDemo.Buzzer;
            }
            else if ((button == BrainPad.Button.DPad.Left) && (state == BrainPad.Button.State.Pressed) && (choiceProg != progDemo.Attente))
            {
                choiceProg = progDemo.Attente;
                BrainPad.Display.Clear();
                DisplayMenu();
                BrainPad.Display.DrawText(10, 70, "6. Buzzer", BrainPad.Color.Yellow);
                activeUp = true; activeDown = true;
            }
            break;

        case Menu.Game:
            if ((button == BrainPad.Button.DPad.Down) && (state == BrainPad.Button.State.Pressed) && activeDown)
            {
                choiceMenu = Menu.Bulb;
                BrainPad.Display.DrawText(10, 80, "7. Game", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 20, "1. Bulb", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Up) && (state == BrainPad.Button.State.Pressed) && activeUp)
            {
                choiceMenu = Menu.Buzzer;
                BrainPad.Display.DrawText(10, 80, "7. Game", BrainPad.Color.White);
                BrainPad.Display.DrawText(10, 70, "6. Buzzer", BrainPad.Color.Yellow);
            }
            else if ((button == BrainPad.Button.DPad.Right) && (state == BrainPad.Button.State.Pressed))
            {
                activeUp = false; activeDown = false;
                BrainPad.Display.Clear();
                choiceProg = progDemo.Game;
                x          = 50; y = 50; // position
                dx         = 4; dy = 6;  // vitesse et direction
                bouncerOk  = true;
            }
            else if ((button == BrainPad.Button.DPad.Left) && (state == BrainPad.Button.State.Pressed) && (choiceProg != progDemo.Attente))
            {
                bouncerOk  = false;
                choiceProg = progDemo.Attente;
                BrainPad.Display.Clear();
                DisplayMenu();
                BrainPad.Display.DrawText(10, 80, "7. Game", BrainPad.Color.Yellow);
                activeUp = true; activeDown = true;
            }
            break;

        default:

            break;
        }
    }