/// <summary> /// Play a set of RTTL songs synchronously, loaded from SD card resources /// </summary> public static void PlayFromResource(){ #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 var sd = new SDResourceLoader(); sd.Load(); foreach(string songName in sd.RTTLSongs.Keys) { RttlSong song = (RttlSong) sd.RTTLSongs[songName]; Debug.Print("Playing: " + song.Name); song.Play(_channel); Thread.Sleep(1500); } #if NETDUINO_MINI || NETDUINO StorageDevice.Unmount(SDMountPoint); #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); } }
/// <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); }
/// <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); }