1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #pragma once
- #include "NotifyDevice.h"
- #include "MMLPlayer.h"
- #define AP_NOTIFY_TONEALARM_MAX_TONE_LENGTH_MS 2000
- #define AP_NOTIFY_TONEALARM_TONE_BUF_SIZE 100
- class AP_ToneAlarm: public NotifyDevice {
- public:
-
- bool init(void) override;
-
- void update() override;
-
- void handle_play_tune(const mavlink_message_t &msg) override;
-
- void play_tune(const char *tune) override;
- private:
-
- void play_tone(const uint8_t tone_index);
-
- void stop_cont_tone();
-
- void check_cont_tone();
-
- void _timer_task();
-
- struct tonealarm_type {
- uint16_t armed : 1;
- uint16_t failsafe_battery : 1;
- uint16_t parachute_release : 1;
- uint16_t pre_arm_check : 1;
- uint16_t failsafe_radio : 1;
- uint16_t vehicle_lost : 1;
- uint16_t compass_cal_running : 1;
- uint16_t waiting_for_throw : 1;
- uint16_t leak_detected : 1;
- uint16_t powering_off : 1;
- } flags;
- bool _have_played_ready_tone : 1;
- int8_t _cont_tone_playing;
- int8_t _tone_playing;
- uint32_t _tone_beginning_ms;
- struct Tone {
- const char *str;
- const uint8_t continuous : 1;
- };
- const static Tone _tones[];
- HAL_Semaphore _sem;
- MMLPlayer _mml_player;
- char _tone_buf[AP_NOTIFY_TONEALARM_TONE_BUF_SIZE];
- };
|