Beispiel #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);
        }
        /// <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);
        }
Beispiel #3
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 {
#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) {
                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);
            }
        }