IBuzzer

class

Generic Buzzer interface.

This interface defines a generic API for buzzers used in the framework. You should not construct any subclass of this interface yourself. The system automatically creates a buzzer object for you, that you can obtain through the IApplicationContext:

Example

mono::sensor::IBuzzer *buzz = mono::IApplicationContext::Instance->Buzzer;

To make a short buzz sound do:

mono::IApplicationContext::Instance->Buzzer->buzzAsync(100);

Public Functions

virtual void mono::sensor::IBuzzer::buzzAsync(uint32_t timeMs)
= 0

Buzz for a given period of time, then stop.

Sets the buzzer to emit a buzz for a defined number of milliseconds. Then stop. This method is asynchronous, so it returns immediately. It relies on interrupts to mute the buzzer later in time.

You should not call it multiple times in a row, since it behaves asynchronously. Instread use Timer to schedule multiple beeps.

Parameters
  • timeMs -

    The time window where the buzzer buzzes, in milliseconds

virtual void mono::sensor::IBuzzer::buzzKill()
= 0

Stop any running buzz.

Use this method to cancel a buzz immediately. This method will not have any impact on callback functions. They will still be called, when the buzz was suppose to end.

template <typename Object>
void mono::sensor::IBuzzer::buzzAsync(uint32_t timeMs, Object * self, void(Object::*)(void) member)

Buzz for some time, and when done call a C++ member function.

Sets the buzzer to emit a buzz for a defined number of milliseconds. Then stop. This method is asynchronous, so it return immediately. It relies on the run loop to mute the buzzer later in time. You also provide a callback function, that gets called when the buzz is finished.

You should not call it multiple times in a row, since it behaves asynchronously. Instead you should use the callback function to make a new beep.

Example This will buzz for 100 ms, then call buzzDone.

buzzAsync<AppController>(100, this, &AppController::buzzDone);

Parameters
  • timeMs -

    The time window where the buzzer buzzes, in milliseconds

  • self -

    The this pointer for the member function

  • member -

    A pointer to the member function to call

void mono::sensor::IBuzzer::buzzAsync(uint32_t timeMs, void (*function)(void))

Buzz for some time, and when done call a C function.

Sets the buzzer to emit a buzz for a defined number of milliseconds. Then stop. This method is asynchronous, so it return immediately. It relies on the run loop to mute the buzzer later in time. You also provide a callback function, that gets called when the buzz is finished.

You should not call it multiple times in a row, since it behaves asynchronously. Instead you should use the callback function to make a new beep.

Example This will buzz for 100 ms, then call global C function buzzDone.

buzzAsync(100, &buzzDone);

Parameters
  • timeMs -

    The time window where the buzzer buzzes, in milliseconds

  • function -

    A pointer to the global C function to call

Protected Attributes

mbed::FunctionPointer mono::sensor::IBuzzer::timeoutHandler

A Handler to call when buzzing finished.

This member is setup when you provide a callback to the buzzAsync methods. Your subclass must call this when buzzing ends.