Exemplo n.º 1
0
        /// <summary>
        /// Class constructor, creates a new Nom Nom! Game
        /// </summary>
        /// <param name="config">The hardware configuration</param>
        public Nomnom(ConsoleHardwareConfig config)
            : base(config)
        {
            DisplayDelay = 1;
#if toolboxspeaker
            // I used my own speaker class due to a small bug in the RTTL class from Nwazet
            config.Speaker.Dispose();
            this._speaker = new Speaker(Pins.GPIO_PIN_18);
#endif
        }
Exemplo n.º 2
0
        public static void Main()
        {
            // Initializes the speaker
            Speaker PCSpeaker = new Speaker(new Netduino.PWM(Pins.GPIO_PIN_D9));

            // Produces a simple beep
            PCSpeaker.Beep();

            // Wait for 2 seconds
            Thread.Sleep(2000);

            // Produces a 440 hertz tone for 5 ticks
            PCSpeaker.Sound(440, 5);

            // Wait for 2 seconds
            Thread.Sleep(2000);

            // Plays a little song
            PCSpeaker.Play("cdec cdec");     // Are you sleeping? Are you sleeping?
            PCSpeaker.Play("efg efg");       // Brother John, Brother John,
            PCSpeaker.Play("gagfec gagfec"); // Morning bells are ringing! Morning bells are ringing!
            PCSpeaker.Play("c<g>c c<g>c");   // Ding, dang, dong. Ding, dang, dong.

            // ------------------------------------------------------------------------
            //                         Speaker.Play() synax
            // ------------------------------------------------------------------------
            // Octave and tone commands:
            //   Ooctave    Sets the current octave (0 - 6).
            //   < or >     Moves up or down one octave.
            //   A - G      Plays the specified note in the current octave.
            //   Nnote      Plays a specified note (0 - 84) in the seven octave
            //              range (0 is a rest).
            // 
            // Duration and tempo commands:
            //   Llength    Sets the length of each note (1 - 64). L1 is whole note,
            //              L2 is half note, etc.
            //   ML         Sets music legato.
            //   MN         Sets music normal.
            //   MS         Sets music staccato.
            //   Ppause     Specifies a pause (1 - 64). P1 is a whole-note pause,
            //              P2 is a half-note pause, etc.
            //   Ttempo     Sets the tempo in quarter notes per minute (32 - 255).
            //   
            // Mode commands:
            //   MF         Plays music in foreground.
            //   MB         Plays music in background.
            // 
            // Suffix commands:
            //   # or +     Turns preceding note into a sharp.
            //   -          Turns preceding note into a flat.
            //   .          Plays the preceding note 3/2 as long as specified.
            // ------------------------------------------------------------------------
            // See also: http://netmftoolbox.codeplex.com/wikipage?title=Toolbox.NETMF.Hardware.Speaker
            // ------------------------------------------------------------------------
        }