Exemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ButtonCatcher(PiAndBash.Driver PiAndBashDriver)
        {
            _states = new List <ButtonState>();
            _states.Add(new ButtonState()
            {
                Button = ButtonType.Up, Pin = Mcp23017Pin.B1
            });
            _states.Add(new ButtonState()
            {
                Button = ButtonType.Down, Pin = Mcp23017Pin.B5
            });
            _states.Add(new ButtonState()
            {
                Button = ButtonType.Enter, Pin = Mcp23017Pin.B3
            });
            _states.Add(new ButtonState()
            {
                Button = ButtonType.TopSel, Pin = Mcp23017Pin.B6
            });
            _states.Add(new ButtonState()
            {
                Button = ButtonType.BotSel, Pin = Mcp23017Pin.B7
            });



            deviceConnection = PiAndBashDriver.i2cConnection;

            // Always for PnB
            foreach (ButtonState btn in _states)
            {
                deviceConnection.SetDirection(btn.Pin, Mcp23017PinDirection.Input);
                deviceConnection.SetResistor(btn.Pin, Mcp23017PinResistor.PullUp);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// ctor
        /// </summary>
        public Display(PiAndBash.Driver PiAndBashDriver)
        {
            deviceConnection = PiAndBashDriver.i2cConnection;

            // turn on LCD backlight
            deviceConnection.SetDirection(Mcp23017Pin.A0, Mcp23017PinDirection.Output);
            SetBacklight(true);


            // light is on, let's write
            var settings = new Hd44780LcdConnectionSettings
            {
                ScreenWidth  = 16,
                ScreenHeight = 2
            };

            settings.Encoding = Encoding.ASCII;

            configuration = Hd44780Configuration.LoadGpioConfiguration();
            connection    = new Hd44780LcdConnection(settings, configuration.Pins);


            connection.Clear();

            Console.WriteLine("Display initialised");
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 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
            });
        }
Exemplo n.º 5
0
 public LedController(PiAndBash.Driver PiAndBashDriver)
 {
     driver = PiAndBashDriver;
 }