예제 #1
0
        /// <summary>
        /// Configures the application from the 'resources.txt' file place on the microSD card.
        /// See the 'SD Card Resources' folder for a sample to start with.
        /// </summary>
        private static void InitializeResources()
        {
            var resourceLoader = new SDResourceLoader();

            try {
                resourceLoader.Load();
            } catch (IOException e) {
                PowerState.RebootDevice(false);
            }

            _key        = (string)resourceLoader.Strings["key"];
            _user       = (string)resourceLoader.Strings["user"];
            _host       = (string)resourceLoader.Strings["host"];
            _port       = int.Parse((string)resourceLoader.Strings["port"]);
            _timeZone   = int.Parse((string)resourceLoader.Strings["timeZone"]);
            _ntpServers = (string)resourceLoader.Strings["ntpServers"];
            _dst        = int.Parse((string)resourceLoader.Strings["dst"]);

            resourceLoader.Dispose();

            vm            = new VirtualFrame(40960, 16, VirtualMemoryFilename);
            vm.IsReadOnly = false;

            tft             = new AdaFruitST7735(Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8, speedKHz: 40000, vm: vm);
            tft.Orientation = AdaFruitST7735.ScreenOrientation.Landscape;

            Debug.GC(true);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        /// <summary>
        /// Configures the application from the 'resources.txt' file place on the microSD card.
        /// See the 'SD Card Resources' folder for a sample to start with.
        /// </summary>
        private static void InitializeResources()
        {
            var resourceLoader = new SDResourceLoader();

            resourceLoader.Load();

            _ntpServers = (string)resourceLoader.Strings["ntpServers"];
            _latitude   = (string)resourceLoader.Strings["latitude"];
            _longitude  = (string)resourceLoader.Strings["longitude"];

            _twitter = new TwitterClient(
                (string)resourceLoader.Strings["consumerKey"],
                (string)resourceLoader.Strings["consumerSecret"],
                (string)resourceLoader.Strings["accessToken"],
                (string)resourceLoader.Strings["accessTokenSecret"]);

            resourceLoader.Dispose();

            Debug.GC(true);
        }