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); } }
/// <summary> /// During development, Main() acts as the ConsoleBootLoader, making it easy to debug the game. /// When game development is complete, comment out the content Main() to remove the overhead /// </summary> public static void Main() { #if dev var joystickLeft = new AnalogJoystick(xAxisPin: Pins.GPIO_PIN_A0, yAxisPin: Pins.GPIO_PIN_A1); var joystickRight = new AnalogJoystick(xAxisPin: Pins.GPIO_PIN_A2, yAxisPin: Pins.GPIO_PIN_A3); var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_D8); var speaker = new PWM(Pins.GPIO_PIN_D5); var resourceLoader = new SDResourceLoader(); var buttonLeft = new PushButton(Pins.GPIO_PIN_D0, Port.InterruptMode.InterruptEdgeLevelLow, null, Port.ResistorMode.PullUp); var buttonRight = new PushButton(Pins.GPIO_PIN_D1, Port.InterruptMode.InterruptEdgeLevelLow, null, Port.ResistorMode.PullUp); var args = new object[(int)CartridgeVersionInfo.LoaderArgumentsVersion100.Size]; var index = 0; args[index++] = CartridgeVersionInfo.CurrentVersion; args[index++] = joystickLeft; args[index++] = joystickRight; args[index++] = matrix; args[index++] = speaker; args[index++] = resourceLoader; args[index++] = buttonLeft; args[index] = buttonRight; matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation); matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode); matrix.SetDigitScanLimit(7); matrix.SetIntensity(8); Run(args); #endif }
public Remote() { _button0 = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di12, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh); _button1 = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di13, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh); _button2 = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di2, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh); _button3 = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di3, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh); _button0.OnInterrupt += OnButtonPush; _button1.OnInterrupt += OnButtonPush; _button2.OnInterrupt += OnButtonPush; _button3.OnInterrupt += OnButtonPush; Cpu.GlitchFilterTime = new TimeSpan(TimeSpan.TicksPerSecond / 2); _leftJoystick = new AnalogJoystick((Cpu.Pin)FEZ_Pin.AnalogIn.An1, (Cpu.Pin)FEZ_Pin.AnalogIn.An0, -100, 100); _leftJoystick.YCalibration.EndPoints.Low = -4; _leftJoystick.YCalibration.EndPoints.High = 7; _leftJoystick.XCalibration.EndPoints.Low = 0; _leftJoystick.XCalibration.EndPoints.High = 3; _leftJoystick.AngularCalibration = new Angle(Angle.ConvertDegreesToRadians(-90)); _rightJoystick = new AnalogJoystick((Cpu.Pin)FEZ_Pin.AnalogIn.An3, (Cpu.Pin)FEZ_Pin.AnalogIn.An2, -100, 100); _rightJoystick.YCalibration.EndPoints.Low = -6; _rightJoystick.YCalibration.EndPoints.High = 6; _rightJoystick.XCalibration.EndPoints.Low = 0; _rightJoystick.XCalibration.EndPoints.High = 9; _rightJoystick.AngularCalibration = new Angle(Angle.ConvertDegreesToRadians(-90)); // ReSharper disable RedundantArgumentDefaultValue _radio = new RCRadio("OM1", "COM1", 115200, Parity.None, 8, StopBits.One) {Id = "OM1", PartnerId = "OC1", SendFrequency = 200}; // ReSharper restore RedundantArgumentDefaultValue _radio.DataReceived += OnRadioDataReceived; }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); Up = new PwmLed(Device.CreatePwmPort(Device.Pins.D07, 100, 0.0f), TypicalForwardVoltage.Red); Down = new PwmLed(Device.CreatePwmPort(Device.Pins.D04, 100, 0.0f), TypicalForwardVoltage.Red); Left = new PwmLed(Device.CreatePwmPort(Device.Pins.D02, 100, 0.0f), TypicalForwardVoltage.Red); Right = new PwmLed(Device.CreatePwmPort(Device.Pins.D03, 100, 0.0f), TypicalForwardVoltage.Red); joystick = new AnalogJoystick( Device.CreateAnalogInputPort(Device.Pins.A01), Device.CreateAnalogInputPort(Device.Pins.A00), null, true); joystick.SetCenterPosition(); joystick.Updated += JoystickUpdated; joystick.StartUpdating(TimeSpan.FromMilliseconds(100)); onboardLed.SetColor(Color.Green); }
/// <summary> /// During development, Main() acts as the ConsoleBootLoader, making it easy to debug the game. /// When game development is complete, comment out the content Main() to remove the overhead /// </summary> public static void Main() { #if dev var joystickLeft = new AnalogJoystick(xAxisPin: Pins.GPIO_PIN_A0, yAxisPin: Pins.GPIO_PIN_A1); var joystickRight = new AnalogJoystick(xAxisPin: Pins.GPIO_PIN_A2, yAxisPin: Pins.GPIO_PIN_A3); var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_D8); var speaker = new PWM(Pins.GPIO_PIN_D5); var resourceLoader = new SDResourceLoader(); var buttonLeft = new PushButton(Pins.GPIO_PIN_D0, Port.InterruptMode.InterruptEdgeLevelLow, null, Port.ResistorMode.PullUp); var buttonRight = new PushButton(Pins.GPIO_PIN_D1, Port.InterruptMode.InterruptEdgeLevelLow, null, Port.ResistorMode.PullUp); var args = new object[(int)CartridgeVersionInfo.LoaderArgumentsVersion100.Size]; var index = 0; args[index++] = CartridgeVersionInfo.CurrentVersion; args[index++] = joystickLeft; args[index++] = joystickRight; args[index++] = matrix; args[index++] = speaker; args[index++] = resourceLoader; args[index++] = buttonLeft; args[index] = buttonRight; matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation); matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode); matrix.SetDigitScanLimit(7); matrix.SetIntensity(8); Run(args); #endif }
public static void Main() { SDResourceLoader rsc = null; Joystick = new AnalogJoystick(Pins.GPIO_PIN_A0, Pins.GPIO_PIN_A1); // I'm being lazy here and using the default on-board switch instead of the actual joystick button :) JoystickButton = new PushButton(pin: Pins.ONBOARD_SW1, target: new NativeEventHandler(ButtonEventHandler)); try { // Load the resources from the SD card // Place the content of the "SD Card Resources" folder at the root of an SD card rsc = new SDResourceLoader(); rsc.Load(Pins.GPIO_PIN_D10); } catch (IOException) { ShowNoSDPresent(); } // Using the space invaders bitmap in this example var Invaders = (Bitmap)rsc.Bitmaps["spaceinvaders.bmp.bin"]; rsc.Dispose(); var matrix = new LedMS88SR74HC595().Initialize(); while (true) { // Read the current direction of the joystick X += (int)Joystick.XDirection; Y += (int)Joystick.YDirection; // Validate the position of the coordinates to prevent out-of-bound exceptions. if (X < 0) { X = 0; } else if (X >= Invaders.Width - Bitmap.FrameSize) { X = Invaders.Width - Bitmap.FrameSize; } if (Y < 0) { Y = 0; } else if (Y >= Invaders.Height) { Y = Invaders.Height - 1; } Debug.Print("X=" + Joystick.X.ToString() + " (" + Joystick.XDirection.ToString() + ")" + ", Y=" + Joystick.Y.ToString() + " (" + Joystick.YDirection.ToString() + ")"); // move the bitmap according to the direction of the joystick matrix.Set(Invaders.GetFrame(X, Y)); Thread.Sleep(80); } }
public MeadowApp() { Console.WriteLine("MeadowApp()..."); joystick = new AnalogJoystick( Device.CreateAnalogInputPort(Device.Pins.A01), Device.CreateAnalogInputPort(Device.Pins.A00)); var t = TestAnalogJoystick(); }
void Init() { Console.WriteLine("Init"); display = new Max7219(Device, Device.CreateSpiBus(), Device.Pins.D01, 4, Max7219.Max7219Type.Display); graphics = new GraphicsLibrary(display); graphics.CurrentFont = new Font4x8(); joystick = new AnalogJoystick(Device, Device.Pins.A01, Device.Pins.A02, null, true); }
public MeadowApp() { joystick = new AnalogJoystick( Device.CreateAnalogInputPort(Device.Pins.A01), Device.CreateAnalogInputPort(Device.Pins.A00), null, false); joystick.SetCenterPosition(); //fire and forget joystick.Updated += JoystickUpdated; joystick.StartUpdating(); }
void Initialize() { var display = new Max7219( device: Device, spiBus: Device.CreateSpiBus(Max7219.DefaultSpiBusSpeed), csPin: Device.Pins.D01, deviceCount: 4, maxMode: Max7219.Max7219Type.Display); graphics = new MicroGraphics(display); graphics.CurrentFont = new Font4x8(); joystick = new AnalogJoystick(Device, Device.Pins.A01, Device.Pins.A02, null, true); joystick.StartUpdating(TimeSpan.FromMilliseconds(20)); }
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); } }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); Up = new PwmLed(Device.CreatePwmPort(Device.Pins.D07, 100, 0.0f), TypicalForwardVoltage.Red); Down = new PwmLed(Device.CreatePwmPort(Device.Pins.D04, 100, 0.0f), TypicalForwardVoltage.Red); Left = new PwmLed(Device.CreatePwmPort(Device.Pins.D02, 100, 0.0f), TypicalForwardVoltage.Red); Right = new PwmLed(Device.CreatePwmPort(Device.Pins.D03, 100, 0.0f), TypicalForwardVoltage.Red); joystick = new AnalogJoystick( Device.CreateAnalogInputPort(Device.Pins.A01), Device.CreateAnalogInputPort(Device.Pins.A00), null, true); joystick.SetCenterPosition(); joystick.Updated += JoystickUpdated; joystick.StartUpdating(); led.SetColor(RgbLed.Colors.Green); //TestAnalogJoystick(); }
public static void Main() { SDResourceLoader rsc = null; Joystick = new AnalogJoystick(Pins.GPIO_PIN_A0, Pins.GPIO_PIN_A1); // I'm being lazy here and using the default on-board switch instead of the actual joystick button :) JoystickButton = new PushButton(pin: Pins.ONBOARD_SW1, target: new NativeEventHandler(ButtonEventHandler)); 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); try { // Load the resources from the SD card // Place the content of the "SD Card Resources" folder at the root of an SD card #if NETDUINO_MINI StorageDevice.MountSD(SDMountPoint, SPI.SPI_module.SPI1, Pins.GPIO_PIN_13); #else StorageDevice.MountSD(SDMountPoint, SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10); #endif // Load the resources from the SD card // Place the content of the "SD Card Resources" folder at the root of an SD card rsc = new SDResourceLoader(); rsc.Load(); #if NETDUINO_MINI || NETDUINO StorageDevice.Unmount(SDMountPoint); #endif } catch (IOException e) { ShowNoSDPresent(matrix); } // Using the space invaders bitmap in this example var Invaders = (Bitmap)rsc.Bitmaps["spaceinvaders.bmp.bin"]; while (true) { // Read the current direction of the joystick X += (int)Joystick.XDirection; Y += (int)Joystick.YDirection; // Validate the position of the coordinates to prevent out-of-bound exceptions. if (X < 0) { X = 0; } else if (X >= Invaders.Width - Bitmap.FrameSize) { X = Invaders.Width - Bitmap.FrameSize; } if (Y < 0) { Y = 0; } else if (Y >= Invaders.Height) { Y = Invaders.Height - 1; } Debug.Print("X=" + Joystick.X.ToString() + " (" + Joystick.XDirection.ToString() + ")" + ", Y=" + Joystick.Y.ToString() + " (" + Joystick.YDirection.ToString() + ")"); // move the bitmap according to the direction of the joystick matrix.Display(Invaders.GetFrame(X, Y)); Thread.Sleep(80); } }