Exemplo n.º 1
0
        public static void Main()
        {
            var LeftJoystick  = new AnalogJoystick(Pins.GPIO_PIN_A0, Pins.GPIO_PIN_A1);
            var RightJoystick = new AnalogJoystick(Pins.GPIO_PIN_A2, Pins.GPIO_PIN_A3);

            var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_D8);

            matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation);
            matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode);
            matrix.SetDigitScanLimit(7);
            matrix.SetIntensity(8);

            var comp = new Composition(new byte[8], 8, 8);

            var leftBall  = new PlayerMissile("leftBall", 0, 0);
            var rightBall = new PlayerMissile("rightBall", 0, 0);

            comp.AddMissile(leftBall);
            comp.AddMissile(rightBall);

            while (true)
            {
                leftBall.X  = LeftJoystick.X / 128;
                leftBall.Y  = LeftJoystick.Y / 128;
                rightBall.X = RightJoystick.X / 128;
                rightBall.Y = RightJoystick.Y / 128;

                Debug.Print("X=" + LeftJoystick.X.ToString() + " (" + LeftJoystick.XDirection.ToString() + ")" + ", Y=" + LeftJoystick.Y.ToString() + " (" + LeftJoystick.YDirection.ToString() + ")");

                matrix.Display(comp.GetFrame(0, 0));

                Thread.Sleep(80);
            }
        }
Exemplo n.º 2
0
        public static void Main()
        {
            using (var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_D8, speedKHz: 10000)) {
                matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation);
                matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode);
                matrix.SetDigitScanLimit(7);
                matrix.SetIntensity(8);

                var comp = new Composition(new byte[]  {
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x03, 0xC0,
                    0x07, 0xE0,
                    0x0F, 0xF0,
                    0x0F, 0xF0,
                    0x0F, 0xF0,
                    0x0F, 0xF0,
                    0x07, 0xE0,
                    0x03, 0xC0,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                }, 16, 16);

                var player  = new PlayerMissile("player", 0, 0);
                var missile = new PlayerMissile("missile", 0, 0);
                comp.AddMissile(player);
                comp.AddMissile(missile);

                while (true)
                {
                    for (var angle = 0; angle < 360; angle++)
                    {
                        player.X  = 8 + Math.Sin(angle * 2) / 160;
                        player.Y  = 8 + Math.Cos(angle * 2) / 160;
                        missile.X = 8 + Math.Sin(angle) / 160;
                        missile.Y = 8 + Math.Cos(angle) / 160;
                        var frame = comp.GetFrame(Math.Sin(angle * 20) / 250 + 4, Math.Cos(angle * 20) / 250 + 4);
                        matrix.Display(frame);
                        Thread.Sleep(25);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public PlayerMissile(string name, int x, int y, Composition owner = null)
 {
     Name  = name;
     _x    = x;
     _y    = y;
     Owner = owner;
     if (Owner != null)
     {
         Owner.AddMissile(this);
     }
 }
Exemplo n.º 4
0
        public static void Main()
        {
#if NETDUINO || NETDUINO_PLUS
            var LeftJoystick  = new AnalogJoystick(Pins.GPIO_PIN_A0, Pins.GPIO_PIN_A1);
            var RightJoystick = new AnalogJoystick(Pins.GPIO_PIN_A2, Pins.GPIO_PIN_A3);
            var matrix        = new Max72197221(chipSelect: Pins.GPIO_PIN_D8);
#endif
#if NETDUINO_MINI
            var LeftJoystick  = new AnalogJoystick(Pins.GPIO_PIN_5, Pins.GPIO_PIN_6, minYRange: 1023, maxYRange: 0, centerDeadZoneRadius: 30);
            var RightJoystick = new AnalogJoystick(Pins.GPIO_PIN_7, Pins.GPIO_PIN_8, minYRange: 1023, maxYRange: 0, centerDeadZoneRadius: 30);
            var matrix        = new Max72197221(chipSelect: Pins.GPIO_PIN_17);
#endif

            matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation);
            matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode);
            matrix.SetDigitScanLimit(7);
            matrix.SetIntensity(4);

            var comp = new Composition(new byte[8], 8, 8);

            var leftBall  = new PlayerMissile("leftBall", 0, 0);
            var rightBall = new PlayerMissile("rightBall", 0, 0);

            comp.AddMissile(leftBall);
            comp.AddMissile(rightBall);

            while (true)
            {
                leftBall.X  = LeftJoystick.X / 128;
                leftBall.Y  = LeftJoystick.Y / 128;
                rightBall.X = RightJoystick.X / 128;
                rightBall.Y = RightJoystick.Y / 128;

                Debug.Print("LEFT: (X=" + LeftJoystick.X + " (" + LeftJoystick.XDirection + ")" + ", Y=" + LeftJoystick.Y + " (" + LeftJoystick.YDirection + "), RIGHT: (X=" + RightJoystick.X + " (" + RightJoystick.XDirection + ")" + ", Y=" + RightJoystick.Y + " (" + RightJoystick.YDirection + ")");

                matrix.Display(comp.GetFrame(0, 0));

                Thread.Sleep(80);
            }
        }