示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Simon for Pi & Bash_");


            Connectors.GpioConnectionSettings.BoardConnectorRevision = 1;

            // initialise Pi and Bash
            PiAndBash.Driver driver = new PiAndBash.Driver();

            // initialise Sound Engine
            NotePlayer notePlayer = new NotePlayer();

            // load game engine
            GameEngine gameEngine = new GameEngine(driver, notePlayer);

            gameEngine.Start();
        }
示例#2
0
        public static void WaitForAllButtonsAsync()
        {
            // http://stackoverflow.com/questions/3390286/making-a-console-application-like-a-windows-application

            PiAndBash.Display disp = new PiAndBash.Display();
            disp.TopLine    = "Simon";
            disp.BottomLine = "< EXIT";


            notePlayer = new NotePlayer();
            notePlayer.CreateSamples(new double[] { 440, 523 });
            PiAndBash.ButtonCatcher bc = new PiAndBash.ButtonCatcher();
            bc.ButtonEvent += bc_ButtonEvent2;



            bc.Start();
        }
示例#3
0
        internal static void WindowsInterruptTest()
        {
            Console.WriteLine("press any key to play sound");
            bool isPlaying = false;
            var  ad        = Mono.Audio.AudioDevice.CreateDevice("sss");

            var np = new NotePlayer();



            short[] buffer = new short[480];
            while (true)
            {
                if (!isPlaying)
                {
                    Console.ReadKey(false);
                    isPlaying = true;
                }

                if (isPlaying && !Console.KeyAvailable)
                {
                    // ad.PlaySample(buffer, 480);
                    //Thread.Sleep(100);
                    //Task.Factory.StartNew(() => np.PlayNote(440, 1));
                    //Thread t = new Thread(() => np.PlayNote(440,1));
                    //t.Start();
                    //while (!t.IsAlive) ;
                    np.PlayNote(440, 1);
                    Console.Write(".");
                }
                else
                {
                    Console.Write("£");
                    np.Silence();
                    isPlaying = false;
                    Console.ReadKey(true);
                }
            }
        }
示例#4
0
        public GameEngine(PiAndBash.Driver PiAndBashDriver, NotePlayer NotePlayer)
        {
            pnbDriver     = PiAndBashDriver;
            pnbDisplay    = new PiAndBash.Display(pnbDriver);
            leds          = new PiAndBash.LedController(pnbDriver);
            buttonCatcher = new PiAndBash.ButtonCatcher(pnbDriver);
            notePlayer    = NotePlayer;

            // set up the Notes and associations
            notes = new Dictionary <int, Note>();
            notes.Add(1, new Note()
            {
                Color = PiAndBash.LedController.LightColor.Green, Button = PiAndBash.ButtonCatcher.ButtonType.Down, Frequency = 349
            });
            notes.Add(2, new Note()
            {
                Color = PiAndBash.LedController.LightColor.Yellow, Button = PiAndBash.ButtonCatcher.ButtonType.Enter, Frequency = 440
            });
            notes.Add(3, new Note()
            {
                Color = PiAndBash.LedController.LightColor.Red, Button = PiAndBash.ButtonCatcher.ButtonType.Up, Frequency = 523
            });
        }