private static void StringToDigitTest() { _max.SetDecodeMode(Max72197221.DecodeModeRegister.DecodeDigitAll); _max.Display(" "); Thread.Sleep(1000); _max.Display("12345678"); Thread.Sleep(3000); _max.Display("-6.5.4.3.2.1.0."); Thread.Sleep(3000); _max.Display("z-z-z-z-"); Thread.Sleep(3000); _max.Display("-.-.-. . . . ."); Thread.Sleep(3000); _max.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode); }
/// <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() { 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); } }
public static void Main() { try { int index = 0; args[index++] = CartridgeVersionInfo.CurrentVersion; args[index++] = JoystickLeft; args[index++] = JoystickRight; args[index++] = Matrix; args[index++] = Speaker; args[index++] = ResourceLoader; Matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation); Matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode); Matrix.SetDigitScanLimit(7); Matrix.SetIntensity(8); Matrix.Display(new byte[] { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 }); #if NETDUINO_MINI ResourceLoader.Load(Pins.GPIO_PIN_13, resourceManifest: "cartridge.txt", args: new object[] { args }); #else ResourceLoader.Load(Pins.GPIO_PIN_D10, resourceManifest: "cartridge.txt", args: new object[] { args }); #endif DisplayAndWait(new byte[] { 0x7e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x22, 0x1e }); } catch (IOException) { DisplayAndWait(new byte[] { 0x81, 0x42, 0x3c, 0x5a, 0x7e, 0x24, 0x5a, 0x81 }); } }
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); } } } }
public static void Main() { try { int 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; // This small delay ensures that the netduino has the time to settle down upon powering up. // Upon power-up the pins of the netduino turn to high for a moment, which interferes with setting up the matrix. Thread.Sleep(1500); Matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation); Matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode); Matrix.SetDigitScanLimit(7); Matrix.SetIntensity(7); Matrix.Display(new byte[] { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 }); #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 ResourceLoader.Path = SelectCartridge(); ResourceLoader.Load(resourceManifest: "cartridge.txt", args: new object[] { args }); #if NETDUINO_MINI || NETDUINO StorageDevice.Unmount(SDMountPoint); #endif Matrix.Display(new byte[] { 0x7e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x22, 0x1e }); Wait(); } catch (IOException) { Matrix.Display(new byte[] { 0x81, 0x42, 0x3c, 0x5a, 0x7e, 0x24, 0x5a, 0x81 }); Wait(); } }
public static void Main() { try { while (true) { int 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(1); Matrix.Display(new byte[] { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 }); #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 ResourceLoader.Path = SelectCartridge(); ResourceLoader.Load(resourceManifest: "cartridge.txt", args: new object[] { args }); ResourceLoader.Dispose(); #if NETDUINO_MINI || NETDUINO StorageDevice.Unmount(SDMountPoint); #endif Debug.GC(true); ResourceLoader = new SDResourceLoader(); } } catch (IOException) { Matrix.Display(new byte[] { 0x81, 0x42, 0x3c, 0x5a, 0x7e, 0x24, 0x5a, 0x81 }); Wait(); } }
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); } }
/// <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 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)); 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); } }
/*public static void SetPixel(int x, int y, bool color) { * if (x < 0 || x > WIDTH - 1 || y < 0 || y > HEIGHT - 1) * return; * y = 7 - y; * if(color) * vram[(x / 8) + (y * line.Length)] |= (byte)(1 << x % 8); * else * vram[(x / 8) + (y * line.Length)] &= (byte)(~(1 << x % 8)); * * }*/ private static void Main() { var chipSelect = GpioController.GetDefault().OpenPin(SC20100.GpioPin.PD3); var settings = new SpiConnectionSettings() { ChipSelectType = SpiChipSelectType.None, //ChipSelectLine = SC20100.GpioPin.PD3, Mode = SpiMode.Mode0, ClockFrequency = 4_000_000, //4Mhz DataBitLength = 8, }; var controller = SpiController.FromName(SC20100.SpiBus.Spi3); var device = controller.GetDevice(settings); //byte[] data = new byte[2]; //data[0] = 9; //data[1] = 0x0f; //device.Write(data) ledchip = new Max72197221(chipSelect, device); ledchip.SetDisplayTest(Max72197221.DisplayTestRegister.DisplayTestMode); Thread.Sleep(100); ledchip.SetDisplayTest(Max72197221.DisplayTestRegister.NormalOperation); Thread.Sleep(100); for (int x = 0; x < 20; x++) { ledchip.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode); } for (int x = 0; x < 20; x++) { ledchip.SetDigitScanLimit(7); } for (int x = 0; x < 20; x++) { ledchip.SetIntensity(0x07); } for (int x = 0; x < 20; x++) { ledchip.Shutdown(Max72197221.ShutdownRegister.NormalOperation); } int v = 100; BasicDrawing pen = new BasicDrawing(WIDTH, HEIGHT); pen.ClearScreen(); while (true) { pen.ClearScreen(); pen.DrawText(v--, 0, "Stay at home!!!"); Flush(pen.vram); if (v < -100) { v = 100; } Thread.Sleep(50); } }