mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-04 23:45:26 +00:00
Beep-on-packets option in Settings and updated ERT & Sonde apps (#2058)
* Beep-on-packets option in Settings * Add beep to ERT app
This commit is contained in:
parent
ba36680a7b
commit
fe2fbb847f
@ -23,7 +23,7 @@
|
||||
#include "ert_app.hpp"
|
||||
|
||||
#include "baseband_api.hpp"
|
||||
|
||||
#include "audio.hpp"
|
||||
#include "portapack.hpp"
|
||||
using namespace portapack;
|
||||
|
||||
@ -33,6 +33,8 @@ using namespace portapack;
|
||||
#include "string_format.hpp"
|
||||
#include "file_path.hpp"
|
||||
|
||||
namespace pmem = portapack::persistent_memory;
|
||||
|
||||
namespace ert {
|
||||
|
||||
namespace format {
|
||||
@ -121,6 +123,7 @@ ERTAppView::ERTAppView(NavigationView& nav)
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&rssi,
|
||||
&field_volume,
|
||||
&recent_entries_view,
|
||||
});
|
||||
|
||||
@ -132,9 +135,15 @@ ERTAppView::ERTAppView(NavigationView& nav)
|
||||
if (logger) {
|
||||
logger->append(logs_dir / u"ERT.TXT");
|
||||
}
|
||||
|
||||
if (pmem::beep_on_packets()) {
|
||||
audio::set_rate(audio::Rate::Hz_24000);
|
||||
audio::output::start();
|
||||
}
|
||||
}
|
||||
|
||||
ERTAppView::~ERTAppView() {
|
||||
audio::output::stop();
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
@ -158,6 +167,10 @@ void ERTAppView::on_packet(const ert::Packet& packet) {
|
||||
entry.update(packet);
|
||||
recent_entries_view.set_dirty();
|
||||
}
|
||||
|
||||
if (pmem::beep_on_packets()) {
|
||||
baseband::request_audio_beep(1000, 24000, 60);
|
||||
}
|
||||
}
|
||||
|
||||
void ERTAppView::on_show_list() {
|
||||
|
@ -165,6 +165,9 @@ class ERTAppView : public View {
|
||||
{21 * 8, 0, 6 * 8, 4},
|
||||
};
|
||||
|
||||
AudioVolumeField field_volume{
|
||||
{28 * 8, 0 * 16}};
|
||||
|
||||
MessageHandlerRegistration message_handler_packet{
|
||||
Message::ID::ERTPacket,
|
||||
[this](Message* const p) {
|
||||
|
@ -635,13 +635,17 @@ void SetPersistentMemoryView::focus() {
|
||||
SetAudioView::SetAudioView(NavigationView& nav) {
|
||||
add_children({&labels,
|
||||
&field_tone_mix,
|
||||
&checkbox_beep_on_packets,
|
||||
&button_save,
|
||||
&button_cancel});
|
||||
|
||||
field_tone_mix.set_value(pmem::tone_mix());
|
||||
|
||||
checkbox_beep_on_packets.set_value(pmem::beep_on_packets());
|
||||
|
||||
button_save.on_select = [&nav, this](Button&) {
|
||||
pmem::set_tone_mix(field_tone_mix.value());
|
||||
pmem::set_beep_on_packets(checkbox_beep_on_packets.value());
|
||||
audio::output::update_audio_mute();
|
||||
nav.pop();
|
||||
};
|
||||
|
@ -506,8 +506,12 @@ class SetAudioView : public View {
|
||||
Labels labels{
|
||||
{{1 * 8, 1 * 16}, "Controls the volume of the", Color::light_grey()},
|
||||
{{1 * 8, 2 * 16}, "tone when transmitting in", Color::light_grey()},
|
||||
{{1 * 8, 3 * 16}, "Soundboard or Mic apps.", Color::light_grey()},
|
||||
{{1 * 8, 3 * 16}, "Soundboard or Mic apps:", Color::light_grey()},
|
||||
{{2 * 8, 5 * 16}, "Tone key mix: %", Color::light_grey()},
|
||||
{{1 * 8, 8 * 16}, "Controls whether apps should", Color::light_grey()},
|
||||
{{1 * 8, 9 * 16}, "beep on speaker & headphone", Color::light_grey()},
|
||||
{{1 * 8, 10 * 16}, "when a packet is received", Color::light_grey()},
|
||||
{{1 * 8, 11 * 16}, "(not all apps support this):", Color::light_grey()},
|
||||
};
|
||||
|
||||
NumberField field_tone_mix{
|
||||
@ -517,6 +521,11 @@ class SetAudioView : public View {
|
||||
1,
|
||||
'0'};
|
||||
|
||||
Checkbox checkbox_beep_on_packets{
|
||||
{3 * 8, 13 * 16},
|
||||
16,
|
||||
"Beep on RX packets"};
|
||||
|
||||
Button button_save{
|
||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
||||
"Save"};
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace portapack;
|
||||
namespace pmem = portapack::persistent_memory;
|
||||
|
||||
#include "string_format.hpp"
|
||||
#include "complex.hpp"
|
||||
@ -54,7 +55,6 @@ SondeView::SondeView(NavigationView& nav)
|
||||
&field_vga,
|
||||
&rssi,
|
||||
&field_volume,
|
||||
&check_beep,
|
||||
&check_log,
|
||||
&check_crc,
|
||||
&text_signature,
|
||||
@ -72,13 +72,6 @@ SondeView::SondeView(NavigationView& nav)
|
||||
|
||||
geopos.set_read_only(true);
|
||||
|
||||
check_beep.set_value(beep);
|
||||
check_beep.on_select = [this](Checkbox&, bool v) {
|
||||
beep = v;
|
||||
if (beep)
|
||||
baseband::request_audio_beep(1000, 24000, 60); // 1khz tone for 60ms to acknowledge enablement
|
||||
};
|
||||
|
||||
check_log.set_value(logging);
|
||||
check_log.on_select = [this](Checkbox&, bool v) {
|
||||
logging = v;
|
||||
@ -115,7 +108,10 @@ SondeView::SondeView(NavigationView& nav)
|
||||
if (logger)
|
||||
logger->append(logs_dir / u"SONDE.TXT");
|
||||
|
||||
audio::output::start();
|
||||
if (pmem::beep_on_packets()) {
|
||||
audio::set_rate(audio::Rate::Hz_24000);
|
||||
audio::output::start();
|
||||
}
|
||||
|
||||
// inject a PitchRSSIConfigureMessage in order to arm
|
||||
// the pitch rssi events that will be used by the
|
||||
@ -185,7 +181,7 @@ void SondeView::on_packet(const sonde::Packet& packet) {
|
||||
logger->on_packet(packet);
|
||||
}
|
||||
|
||||
if (beep) {
|
||||
if (pmem::beep_on_packets()) {
|
||||
baseband::request_rssi_beep();
|
||||
}
|
||||
}
|
||||
|
@ -75,14 +75,12 @@ class SondeView : public View {
|
||||
1750000 /* bandwidth */,
|
||||
2457600 /* sampling rate */
|
||||
};
|
||||
bool beep{false};
|
||||
bool logging{false};
|
||||
bool use_crc{false};
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_sonde",
|
||||
app_settings::Mode::RX,
|
||||
{
|
||||
{"beep"sv, &beep},
|
||||
{"logging"sv, &logging},
|
||||
{"use_crc"sv, &use_crc},
|
||||
}};
|
||||
@ -124,11 +122,6 @@ class SondeView : public View {
|
||||
AudioVolumeField field_volume{
|
||||
{28 * 8, 0 * 16}};
|
||||
|
||||
Checkbox check_beep{
|
||||
{22 * 8, 6 * 16},
|
||||
3,
|
||||
"Beep"};
|
||||
|
||||
Checkbox check_log{
|
||||
{22 * 8, 8 * 16},
|
||||
3,
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "baseband_processor.hpp"
|
||||
#include "message.hpp"
|
||||
|
||||
#define AUDIO_SAMPLE_RATE 24000
|
||||
|
||||
class AudioBeepProcessor : public BasebandProcessor {
|
||||
public:
|
||||
AudioBeepProcessor();
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "proc_ert.hpp"
|
||||
#include "audio_dma.hpp"
|
||||
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
@ -109,7 +110,17 @@ void ERTProcessor::idm_handler(
|
||||
shared_memory.application_queue.push(message);
|
||||
}
|
||||
|
||||
void ERTProcessor::on_message(const Message* const msg) {
|
||||
if (msg->id == Message::ID::AudioBeep)
|
||||
on_beep_message(*reinterpret_cast<const AudioBeepMessage*>(msg));
|
||||
}
|
||||
|
||||
void ERTProcessor::on_beep_message(const AudioBeepMessage& message) {
|
||||
audio::dma::beep_start(message.freq, message.sample_rate, message.duration_ms);
|
||||
}
|
||||
|
||||
int main() {
|
||||
audio::dma::init_audio_out();
|
||||
EventDispatcher event_dispatcher{std::make_unique<ERTProcessor>()};
|
||||
event_dispatcher.run();
|
||||
return 0;
|
||||
|
@ -102,6 +102,8 @@ class ERTProcessor : public BasebandProcessor {
|
||||
void scm_handler(const baseband::Packet& packet);
|
||||
void scmplus_handler(const baseband::Packet& packet);
|
||||
void idm_handler(const baseband::Packet& packet);
|
||||
void on_message(const Message* const msg);
|
||||
void on_beep_message(const AudioBeepMessage& message);
|
||||
|
||||
float sum_half_period[2];
|
||||
float sum_period[3];
|
||||
|
@ -152,7 +152,7 @@ struct misc_config_t {
|
||||
bool config_disable_external_tcxo : 1;
|
||||
bool config_sdcard_high_speed_io : 1;
|
||||
bool config_disable_config_mode : 1;
|
||||
bool UNUSED_5 : 1;
|
||||
bool beep_on_packets : 1;
|
||||
bool UNUSED_6 : 1;
|
||||
bool UNUSED_7 : 1;
|
||||
|
||||
@ -641,6 +641,10 @@ bool config_disable_config_mode() {
|
||||
return data->misc_config.config_disable_config_mode;
|
||||
}
|
||||
|
||||
bool beep_on_packets() {
|
||||
return data->misc_config.beep_on_packets;
|
||||
}
|
||||
|
||||
bool config_sdcard_high_speed_io() {
|
||||
return data->misc_config.config_sdcard_high_speed_io;
|
||||
}
|
||||
@ -718,6 +722,10 @@ void set_config_disable_config_mode(bool v) {
|
||||
data->misc_config.config_disable_config_mode = v;
|
||||
}
|
||||
|
||||
void set_beep_on_packets(bool v) {
|
||||
data->misc_config.beep_on_packets = v;
|
||||
}
|
||||
|
||||
void set_config_sdcard_high_speed_io(bool v, bool save) {
|
||||
if (v) {
|
||||
/* 200MHz / (2 * 2) = 50MHz */
|
||||
@ -1247,6 +1255,7 @@ bool debug_dump() {
|
||||
pmem_dump_file.write_line("misc_config config_disable_external_tcxo: " + to_string_dec_uint(config_disable_external_tcxo()));
|
||||
pmem_dump_file.write_line("misc_config config_sdcard_high_speed_io: " + to_string_dec_uint(config_sdcard_high_speed_io()));
|
||||
pmem_dump_file.write_line("misc_config config_disable_config_mode: " + to_string_dec_uint(config_disable_config_mode()));
|
||||
pmem_dump_file.write_line("misc_config beep_on_packets: " + to_string_dec_int(beep_on_packets()));
|
||||
|
||||
// receiver_model
|
||||
pmem_dump_file.write_line("\n[Receiver Model]");
|
||||
|
@ -204,6 +204,7 @@ void set_config_cpld(uint8_t i);
|
||||
bool config_disable_external_tcxo();
|
||||
bool config_sdcard_high_speed_io();
|
||||
bool config_disable_config_mode();
|
||||
bool beep_on_packets();
|
||||
|
||||
bool config_splash();
|
||||
bool config_converter();
|
||||
@ -226,6 +227,7 @@ void set_show_bigger_qr_code(bool v);
|
||||
void set_config_disable_external_tcxo(bool v);
|
||||
void set_config_sdcard_high_speed_io(bool v, bool save);
|
||||
void set_config_disable_config_mode(bool v);
|
||||
void set_beep_on_packets(bool v);
|
||||
|
||||
void set_config_splash(bool v);
|
||||
bool config_converter();
|
||||
|
Loading…
Reference in New Issue
Block a user