mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-04 23:18:29 -04:00
AP_Notify: Add singleton, expose string message player
This commit is contained in:
parent
e7d59514d9
commit
200870e7a0
@ -346,6 +346,15 @@ void AP_Notify::handle_play_tune(mavlink_message_t *msg)
|
||||
}
|
||||
}
|
||||
|
||||
void AP_Notify::play_tune(const char *tune)
|
||||
{
|
||||
for (uint8_t i = 0; i < _num_devices; i++) {
|
||||
if (_devices[i] != nullptr) {
|
||||
_devices[i]->play_tune(tune);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set flight mode string
|
||||
void AP_Notify::set_flight_mode_str(const char *str)
|
||||
{
|
||||
@ -359,3 +368,12 @@ void AP_Notify::send_text(const char *str)
|
||||
_send_text[sizeof(_send_text)-1] = 0;
|
||||
_send_text_updated_millis = AP_HAL::millis();
|
||||
}
|
||||
|
||||
namespace AP {
|
||||
|
||||
AP_Notify ¬ify()
|
||||
{
|
||||
return *AP_Notify::get_singleton();
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -139,6 +139,9 @@ public:
|
||||
// handle a PLAY_TUNE message
|
||||
static void handle_play_tune(mavlink_message_t* msg);
|
||||
|
||||
// play a tune string
|
||||
static void play_tune(const char *tune);
|
||||
|
||||
bool buzzer_enabled() const { return _buzzer_enable; }
|
||||
|
||||
// set flight mode string
|
||||
@ -180,3 +183,7 @@ private:
|
||||
static NotifyDevice* _devices[];
|
||||
static uint8_t _num_devices;
|
||||
};
|
||||
|
||||
namespace AP {
|
||||
AP_Notify ¬ify();
|
||||
};
|
||||
|
@ -19,6 +19,9 @@ public:
|
||||
|
||||
// handle a PLAY_TUNE message, by default device ignore message
|
||||
virtual void handle_play_tune(mavlink_message_t *msg) {}
|
||||
|
||||
// play a MML tune
|
||||
virtual void play_tune(const char *tune) {}
|
||||
|
||||
// this pointer is used to read the parameters relative to devices
|
||||
const AP_Notify *pNotify;
|
||||
|
@ -125,7 +125,7 @@ void AP_ToneAlarm::play_tone(const uint8_t tone_index)
|
||||
_tone_playing = tone_index;
|
||||
_tone_beginning_ms = tnow_ms;
|
||||
|
||||
play_string(tone_requested.str);
|
||||
play_tune(tone_requested.str);
|
||||
}
|
||||
|
||||
void AP_ToneAlarm::_timer_task()
|
||||
@ -134,7 +134,7 @@ void AP_ToneAlarm::_timer_task()
|
||||
_mml_player.update();
|
||||
}
|
||||
|
||||
void AP_ToneAlarm::play_string(const char *str)
|
||||
void AP_ToneAlarm::play_tune(const char *str)
|
||||
{
|
||||
WITH_SEMAPHORE(_sem);
|
||||
|
||||
@ -147,7 +147,7 @@ void AP_ToneAlarm::play_string(const char *str)
|
||||
void AP_ToneAlarm::stop_cont_tone()
|
||||
{
|
||||
if (_cont_tone_playing == _tone_playing) {
|
||||
play_string("");
|
||||
play_tune("");
|
||||
_tone_playing = -1;
|
||||
}
|
||||
_cont_tone_playing = -1;
|
||||
|
@ -35,13 +35,13 @@ public:
|
||||
// handle a PLAY_TUNE message
|
||||
void handle_play_tune(mavlink_message_t *msg) override;
|
||||
|
||||
// play_tune - play tone specified by the provided string of notes
|
||||
void play_tune(const char *tune) override;
|
||||
|
||||
private:
|
||||
/// play_tune - play one of the pre-defined tunes
|
||||
void play_tone(const uint8_t tone_index);
|
||||
|
||||
// play_string - play tone specified by the provided string of notes
|
||||
void play_string(const char *str);
|
||||
|
||||
// stop_cont_tone - stop playing the currently playing continuous tone
|
||||
void stop_cont_tone();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user