mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-09 14:53:38 +00:00
Beep-on-packet support in AIS app (#2064)
* Beep-on-packet support in AIS app
This commit is contained in:
parent
76017c91a9
commit
6e5eadd25c
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ais_app.hpp"
|
#include "ais_app.hpp"
|
||||||
|
#include "audio.hpp"
|
||||||
|
|
||||||
#include "string_format.hpp"
|
#include "string_format.hpp"
|
||||||
#include "database.hpp"
|
#include "database.hpp"
|
||||||
@ -32,6 +33,8 @@ using namespace portapack;
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace pmem = portapack::persistent_memory;
|
||||||
|
|
||||||
namespace ais {
|
namespace ais {
|
||||||
namespace format {
|
namespace format {
|
||||||
|
|
||||||
@ -190,6 +193,10 @@ void AISLogger::on_packet(const ais::Packet& packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_file.write_entry(packet.received_at(), entry);
|
log_file.write_entry(packet.received_at(), entry);
|
||||||
|
|
||||||
|
if (pmem::beep_on_packets()) {
|
||||||
|
baseband::request_audio_beep(1000, 24000, 60);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AISRecentEntry::update(const ais::Packet& packet) {
|
void AISRecentEntry::update(const ais::Packet& packet) {
|
||||||
@ -377,6 +384,7 @@ AISAppView::AISAppView(NavigationView& nav)
|
|||||||
&field_lna,
|
&field_lna,
|
||||||
&field_vga,
|
&field_vga,
|
||||||
&rssi,
|
&rssi,
|
||||||
|
&field_volume,
|
||||||
&channel,
|
&channel,
|
||||||
&recent_entries_view,
|
&recent_entries_view,
|
||||||
&recent_entry_detail_view,
|
&recent_entry_detail_view,
|
||||||
@ -402,9 +410,15 @@ AISAppView::AISAppView(NavigationView& nav)
|
|||||||
if (logger) {
|
if (logger) {
|
||||||
logger->append(logs_dir / u"AIS.TXT");
|
logger->append(logs_dir / u"AIS.TXT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pmem::beep_on_packets()) {
|
||||||
|
audio::set_rate(audio::Rate::Hz_24000);
|
||||||
|
audio::output::start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AISAppView::~AISAppView() {
|
AISAppView::~AISAppView() {
|
||||||
|
audio::output::stop();
|
||||||
receiver_model.disable();
|
receiver_model.disable();
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,9 @@ class AISAppView : public View {
|
|||||||
{21 * 8, 0, 6 * 8, 4},
|
{21 * 8, 0, 6 * 8, 4},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AudioVolumeField field_volume{
|
||||||
|
{28 * 8, 0 * 16}};
|
||||||
|
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{21 * 8, 5, 6 * 8, 4},
|
{21 * 8, 5, 6 * 8, 4},
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proc_ais.hpp"
|
#include "proc_ais.hpp"
|
||||||
|
#include "audio_dma.hpp"
|
||||||
|
|
||||||
#include "portapack_shared_memory.hpp"
|
#include "portapack_shared_memory.hpp"
|
||||||
|
|
||||||
@ -64,7 +65,17 @@ void AISProcessor::payload_handler(
|
|||||||
shared_memory.application_queue.push(message);
|
shared_memory.application_queue.push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AISProcessor::on_message(const Message* const message) {
|
||||||
|
if (message->id == Message::ID::AudioBeep)
|
||||||
|
on_beep_message(*reinterpret_cast<const AudioBeepMessage*>(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AISProcessor::on_beep_message(const AudioBeepMessage& message) {
|
||||||
|
audio::dma::beep_start(message.freq, message.sample_rate, message.duration_ms);
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
audio::dma::init_audio_out();
|
||||||
EventDispatcher event_dispatcher{std::make_unique<AISProcessor>()};
|
EventDispatcher event_dispatcher{std::make_unique<AISProcessor>()};
|
||||||
event_dispatcher.run();
|
event_dispatcher.run();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -74,13 +74,15 @@ class AISProcessor : public BasebandProcessor {
|
|||||||
this->payload_handler(packet);
|
this->payload_handler(packet);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
void consume_symbol(const float symbol);
|
||||||
|
void payload_handler(const baseband::Packet& packet);
|
||||||
|
void on_message(const Message* const message);
|
||||||
|
void on_beep_message(const AudioBeepMessage& message);
|
||||||
|
|
||||||
/* NB: Threads should be the last members in the class definition. */
|
/* NB: Threads should be the last members in the class definition. */
|
||||||
BasebandThread baseband_thread{
|
BasebandThread baseband_thread{
|
||||||
baseband_fs, this, baseband::Direction::Receive, /*auto_start*/ false};
|
baseband_fs, this, baseband::Direction::Receive, /*auto_start*/ false};
|
||||||
RSSIThread rssi_thread{};
|
RSSIThread rssi_thread{};
|
||||||
|
|
||||||
void consume_symbol(const float symbol);
|
|
||||||
void payload_handler(const baseband::Packet& packet);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__PROC_AIS_H__*/
|
#endif /*__PROC_AIS_H__*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user