Class PiezoSpeaker
Represents a 2 pin piezo-electric speaker capable of generating tones
Assembly: Meadow.Foundation.dll
View Source
Declaration
public class PiezoSpeaker : IToneGenerator, IDisposable
Implements:
Meadow.Peripherals.Speakers.IToneGenerator
, System.IDisposable
Properties
Volume
The volume from 0-1 Defined by the PWM port duty cycle from 0 to 0.5
View Source
Declaration
public float Volume { get; protected set; }
Port
Gets the port that is driving the Piezo Speaker
View Source
Declaration
protected IPwmPort Port { get; set; }
IsDisposed
Is the object disposed
View Source
Declaration
public bool IsDisposed { get; }
Methods
PlayTone(Frequency)
Play a frequency until stopped by StopTone
View Source
Declaration
public Task PlayTone(Frequency frequency)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
Meadow.Units.Frequency | frequency | The frequency in hertz of the tone to be played |
PlayTone(Frequency, TimeSpan)
Play a frequency for a specified duration
View Source
Declaration
public Task PlayTone(Frequency frequency, TimeSpan duration)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
Meadow.Units.Frequency | frequency | The frequency in hertz of the tone to be played |
System.TimeSpan | duration | How long the note is played in milliseconds, if duration is 0, tone plays indefinitely |
StopTone()
Stops a tone playing
View Source
Declaration
public void StopTone()
SetVolume(float)
Set the playback volume
View Source
Declaration
public void SetVolume(float volume)
Parameters
Type | Name | Description |
---|---|---|
System.Single | volume | The volume from 0 (off) to 1 (max volume) |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
View Source
Declaration
public void Dispose()
Dispose(bool)
Dispose of the object
View Source
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Is disposing |
Implements
Meadow.Peripherals.Speakers.IToneGenerator
System.IDisposable