Пример #1
0
        public void Beep(SpeakerSound sound)
        {
            if (_isSilent)
            {
                return;
            }

            var currentTone = sound.Tone;

            for (var i = 0; i < sound.Repeat; i++)
            {
                _pin.SoftToneFrequency = currentTone;
                Thread.Sleep(sound.Length);

                currentTone += sound.Increase;

                if (sound.Delay <= 0)
                {
                    continue;
                }

                _pin.SoftToneFrequency = 0;
                Thread.Sleep(sound.Delay);
            }

            _pin.SoftToneFrequency = 0;
            if (sound.SeqDelay > 0)
            {
                Thread.Sleep(sound.SeqDelay);
            }
        }
Пример #2
0
 public async Task BeepAsync(SpeakerSound sound)
 {
     await Task.Run(() => Beep(sound));
 }