mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-09 23:43:39 +00:00
Beep-on-packet support in ADSB RX app (#2065)
This commit is contained in:
parent
6e5eadd25c
commit
b473930f94
@ -32,9 +32,12 @@
|
|||||||
#include "rtc_time.hpp"
|
#include "rtc_time.hpp"
|
||||||
#include "string_format.hpp"
|
#include "string_format.hpp"
|
||||||
#include "file_path.hpp"
|
#include "file_path.hpp"
|
||||||
|
#include "audio.hpp"
|
||||||
|
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
|
|
||||||
|
namespace pmem = portapack::persistent_memory;
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
static std::string get_map_tag(const AircraftRecentEntry& entry) {
|
static std::string get_map_tag(const AircraftRecentEntry& entry) {
|
||||||
@ -373,7 +376,8 @@ ADSBRxView::ADSBRxView(NavigationView& nav) {
|
|||||||
&rssi,
|
&rssi,
|
||||||
&recent_entries_view,
|
&recent_entries_view,
|
||||||
&status_frame,
|
&status_frame,
|
||||||
&status_good_frame});
|
&status_good_frame,
|
||||||
|
&field_volume});
|
||||||
|
|
||||||
recent_entries_view.set_parent_rect({0, 16, 240, 272});
|
recent_entries_view.set_parent_rect({0, 16, 240, 272});
|
||||||
recent_entries_view.on_select = [this, &nav](const AircraftRecentEntry& entry) {
|
recent_entries_view.on_select = [this, &nav](const AircraftRecentEntry& entry) {
|
||||||
@ -395,10 +399,16 @@ ADSBRxView::ADSBRxView(NavigationView& nav) {
|
|||||||
|
|
||||||
receiver_model.enable();
|
receiver_model.enable();
|
||||||
baseband::set_adsb();
|
baseband::set_adsb();
|
||||||
|
|
||||||
|
if (pmem::beep_on_packets()) {
|
||||||
|
audio::set_rate(audio::Rate::Hz_24000);
|
||||||
|
audio::output::start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ADSBRxView::~ADSBRxView() {
|
ADSBRxView::~ADSBRxView() {
|
||||||
rtc_time::signal_tick_second -= signal_token_tick_second;
|
rtc_time::signal_tick_second -= signal_token_tick_second;
|
||||||
|
audio::output::stop();
|
||||||
receiver_model.disable();
|
receiver_model.disable();
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
@ -473,6 +483,10 @@ void ADSBRxView::on_frame(const ADSBFrameMessage* message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger->log(log_entry);
|
logger->log(log_entry);
|
||||||
|
|
||||||
|
if (pmem::beep_on_packets()) {
|
||||||
|
baseband::request_audio_beep(1000, 24000, 60);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ADSBRxView::on_tick_second() {
|
void ADSBRxView::on_tick_second() {
|
||||||
|
@ -421,19 +421,22 @@ class ADSBRxView : public View {
|
|||||||
{18 * 8, 0 * 16}};
|
{18 * 8, 0 * 16}};
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{20 * 8, 4, 10 * 7, 8},
|
{20 * 8, 4, 7 * 8, 8},
|
||||||
};
|
};
|
||||||
|
|
||||||
ActivityDot status_frame{
|
ActivityDot status_frame{
|
||||||
{screen_width - 3, 5, 2, 2},
|
{27 * 8 + 2, 5, 2, 2},
|
||||||
Color::white(),
|
Color::white(),
|
||||||
};
|
};
|
||||||
|
|
||||||
ActivityDot status_good_frame{
|
ActivityDot status_good_frame{
|
||||||
{screen_width - 3, 9, 2, 2},
|
{27 * 8 + 2, 9, 2, 2},
|
||||||
Color::green(),
|
Color::green(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AudioVolumeField field_volume{
|
||||||
|
{28 * 8, 0 * 16}};
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_frame{
|
MessageHandlerRegistration message_handler_frame{
|
||||||
Message::ID::ADSBFrame,
|
Message::ID::ADSBFrame,
|
||||||
[this](Message* const p) {
|
[this](Message* const p) {
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "portapack_shared_memory.hpp"
|
#include "portapack_shared_memory.hpp"
|
||||||
#include "sine_table_int8.hpp"
|
#include "sine_table_int8.hpp"
|
||||||
#include "event_m4.hpp"
|
#include "event_m4.hpp"
|
||||||
|
#include "audio_dma.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@ -144,16 +145,30 @@ void ADSBRXProcessor::execute(const buffer_c8_t& buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ADSBRXProcessor::on_message(const Message* const message) {
|
void ADSBRXProcessor::on_message(const Message* const message) {
|
||||||
if (message->id == Message::ID::ADSBConfigure) {
|
switch (message->id) {
|
||||||
|
case Message::ID::ADSBConfigure:
|
||||||
bit_count = 0;
|
bit_count = 0;
|
||||||
sample_count = 0;
|
sample_count = 0;
|
||||||
decoding = false;
|
decoding = false;
|
||||||
configured = true;
|
configured = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Message::ID::AudioBeep:
|
||||||
|
on_beep_message(*reinterpret_cast<const AudioBeepMessage*>(message));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ADSBRXProcessor::on_beep_message(const AudioBeepMessage& message) {
|
||||||
|
audio::dma::beep_start(message.freq, message.sample_rate, message.duration_ms);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
int main() {
|
int main() {
|
||||||
|
audio::dma::init_audio_out();
|
||||||
EventDispatcher event_dispatcher{std::make_unique<ADSBRXProcessor>()};
|
EventDispatcher event_dispatcher{std::make_unique<ADSBRXProcessor>()};
|
||||||
event_dispatcher.run();
|
event_dispatcher.run();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -53,6 +53,8 @@ class ADSBRXProcessor : public BasebandProcessor {
|
|||||||
|
|
||||||
uint32_t shifter[ADSB_PREAMBLE_LENGTH + 1];
|
uint32_t shifter[ADSB_PREAMBLE_LENGTH + 1];
|
||||||
|
|
||||||
|
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{baseband_fs, this, baseband::Direction::Receive};
|
BasebandThread baseband_thread{baseband_fs, this, baseband::Direction::Receive};
|
||||||
RSSIThread rssi_thread{};
|
RSSIThread rssi_thread{};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user