Ejemplo n.º 1
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
            // ------------------------------------------------------------------------
        }
Ejemplo n.º 2
0
 internal override void Loop()
 {
     move.Forward(50);
     while (running)
     {
         if (this.dist.Read() < 5)
         {
             move.Brake();
             speak.Beep(50, 100);
             running = false;
         }
         Thread.Sleep(0);
     }
 }
Ejemplo n.º 3
0
        public virtual void MakeSound(DogSound sound)
        {
            //TODO: Play sound from file
            this.sound = sound;
            //use enum for picking the right sound file
            string soundFileName = "/home/root/apps/SoundTest.wav";
            //Maybe this directory:  /home/root/lms2012/prjs/Hvalp/Dog sniff.rsf

            var speaker = new Speaker(50);

            try
            {
                // speaker.PlaySoundFile(soundFileName);
                speaker.Beep();
            }
            catch (Exception e)
            {
                LcdConsole.WriteLine("Failed to play " + soundFileName);
                LcdConsole.WriteLine("Exception" + e.Message);
                LcdConsole.WriteLine("Stack trace " + e.StackTrace);
            }
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            string           soundFileName    = "/home/root/apps/SoundTest.wav";
            ManualResetEvent terminateProgram = new ManualResetEvent(false);
            var          speaker = new Speaker(50);
            ButtonEvents buts    = new ButtonEvents();

            LcdConsole.WriteLine("Up beep");
            LcdConsole.WriteLine("Down buzz");
            LcdConsole.WriteLine("Enter play soundfile");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                terminateProgram.Set();
            };
            buts.UpPressed += () => {
                LcdConsole.WriteLine("Beep");
                speaker.Beep();
            };
            buts.DownPressed += () => {
                LcdConsole.WriteLine("Buzz");
                speaker.Buzz();
            };
            buts.EnterPressed += () => {
                LcdConsole.WriteLine("Play sound file");
                try{
                    speaker.PlaySoundFile(soundFileName);
                }
                catch (Exception e)
                {
                    LcdConsole.WriteLine("Failed to play " + soundFileName);
                    LcdConsole.WriteLine("Exception" + e.Message);
                    LcdConsole.WriteLine("Stack trace " + e.StackTrace);
                }
            };
            terminateProgram.WaitOne();
        }
Ejemplo n.º 5
0
        private static void Main()
        {
            BrickConsole.WriteLine("Start!");
            var speaker = new Speaker(10);

            speaker.Beep();

            var tank            = new Tank(MotorPort.OutD, MotorPort.OutA);
            var irSensorWrapper = new IRSensorLockWrapper(new EV3IRSensor(SensorPort.In2));
            var colorSensor     = new EV3ColorSensor(SensorPort.In1, ColorMode.Color);
            var touchSensor     = new EV3TouchSensor(SensorPort.In3);

            var buttons = new ButtonEvents();

            buttons.EscapePressed += () =>
            {
                tank.Stop();
                BrickConsole.WriteLine("End!");
                speaker.Buzz();
                Environment.Exit(0);
            };

            var remote = new RemoteControl(irSensorWrapper, IRChannel.One);

            remote.ButtonsReleased += btn =>
            {
                tank.Stop();
                BrickConsole.WriteLine("TankState: {0}", tank);
            };

            remote.ButtonsPressed += btn =>
            {
                switch (btn)
                {
                case RemoteButton.LeftUp:
                    tank.StartForward(speed);
                    break;

                case RemoteButton.LeftDown:
                    tank.StartBackward(speed);
                    break;

                case RemoteButton.RightUp:
                    tank.StartSpinLeft(speed);
                    break;

                case RemoteButton.RightDown:
                    tank.StartSpinRight(speed);
                    break;

                case RemoteButton.LeftUp | RemoteButton.LeftDown:
                    BrickConsole.WriteLine("Color: {0}", colorSensor.ReadColor());
                    break;

                case RemoteButton.RightUp | RemoteButton.RightDown:
                    BrickConsole.WriteLine("TouchSensor.IsPressed: {0}", touchSensor.IsPressed());
                    break;

                case RemoteButton.LeftUp | RemoteButton.RightUp:
                    BrickConsole.WriteLine("Distance: {0} cm", irSensorWrapper.Do(x => x.ReadDistance()));
                    break;

                case RemoteButton.Beacon:
                    BrickConsole.WriteLine("Color: {0}", colorSensor.ReadColor());
                    BrickConsole.WriteLine("Distance: {0} cm", irSensorWrapper.Do(x => x.ReadDistance()));
                    BrickConsole.WriteLine("TouchSensor.IsPressed: {0}", touchSensor.IsPressed());
                    break;
                }
            };

            Thread.Sleep(Timeout.Infinite);
        }
Ejemplo n.º 6
0
 private void EntryMore_Click(object sender, EventArgs e)
 {
     LoadUpIcons(LastKey, Loc + 5);
     Speaker.Beep(600);
 }
Ejemplo n.º 7
0
 private void Entry5_Click(object sender, EventArgs e)
 {
     Output.AppendText(Entry5.Text + " ");
     LoadUpIcons(Entry5.Text);
     Speaker.Beep(200);
 }
Ejemplo n.º 8
0
 private void Clear_Click(object sender, EventArgs e)
 {
     Output.Clear();
     Speaker.Beep(200);
     LoadUpIcons("");
 }
 pubic void BeepTheSpeaker()
 {
     _speaker.Beep();
 }