-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sound alerts on low battery and weak wifi link
- Loading branch information
1 parent
817f96f
commit 40c54fc
Showing
8 changed files
with
86 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "soundalerts.h" | ||
|
||
#define BATTERY_ALERT_THRESHOLD 13 | ||
#define LINK_ALERT_THRESHOLD 25 | ||
|
||
SoundAlerts::SoundAlerts() | ||
{ | ||
battery_low.reset(new QSoundEffect()); | ||
battery_low->setSource(QUrl("qrc:/resources/batt_low.wav")); | ||
|
||
link_weak.reset(new QSoundEffect()); | ||
link_weak->setSource(QUrl("qrc:/resources/link_weak.wav")); | ||
} | ||
|
||
void SoundAlerts::navdataAvailable(std::shared_ptr<const drone::navdata> nd) | ||
{ | ||
int battery_percent = (int) (nd->batterystatus * 100.0f); | ||
int link_percent = (int) (nd->linkquality * 100.0f); | ||
|
||
if(battery_percent <= BATTERY_ALERT_THRESHOLD) | ||
{ | ||
if(!battery_low->isPlaying()) battery_low->play(); | ||
} | ||
else | ||
{ | ||
if(battery_low->isPlaying()) battery_low->stop(); | ||
} | ||
|
||
if(link_percent <= LINK_ALERT_THRESHOLD) | ||
{ | ||
if(!link_weak->isPlaying()) link_weak->play(); | ||
} | ||
else | ||
{ | ||
if(link_weak->isPlaying()) link_weak->stop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef AUTOFLIGHT_SOUNDALERTS_H | ||
#define AUTOFLIGHT_SOUNDALERTS_H | ||
|
||
#include <QtWidgets> | ||
#include <QtMultimedia/QSoundEffect> | ||
|
||
#include <memory> | ||
|
||
#include "qinterface/qnavdatalistener.h" | ||
|
||
#include <drone.h> | ||
|
||
class SoundAlerts : public QObject, QNavdataListener | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
SoundAlerts(); | ||
|
||
public Q_SLOTS: | ||
void navdataAvailable(std::shared_ptr<const drone::navdata> navdata); | ||
|
||
private: | ||
std::unique_ptr<QSoundEffect> battery_low = nullptr; | ||
std::unique_ptr<QSoundEffect> link_weak = nullptr; | ||
}; | ||
|
||
#endif |