mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Beep-on-packet support in TPMS app (#2062)
* Beep-on-packet support in TPMS app * audio::output::stop when exiting
This commit is contained in:
parent
0db65ccb6b
commit
746bf1c15f
@ -23,7 +23,7 @@
|
|||||||
#include "tpms_app.hpp"
|
#include "tpms_app.hpp"
|
||||||
|
|
||||||
#include "baseband_api.hpp"
|
#include "baseband_api.hpp"
|
||||||
|
#include "audio.hpp"
|
||||||
#include "portapack.hpp"
|
#include "portapack.hpp"
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
|
|
||||||
@ -32,6 +32,8 @@ using namespace portapack;
|
|||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
#include "file_path.hpp"
|
#include "file_path.hpp"
|
||||||
|
|
||||||
|
namespace pmem = portapack::persistent_memory;
|
||||||
|
|
||||||
namespace tpms {
|
namespace tpms {
|
||||||
|
|
||||||
namespace format {
|
namespace format {
|
||||||
@ -147,6 +149,7 @@ TPMSAppView::TPMSAppView(NavigationView&) {
|
|||||||
baseband::run_image(portapack::spi_flash::image_tag_tpms);
|
baseband::run_image(portapack::spi_flash::image_tag_tpms);
|
||||||
|
|
||||||
add_children({&rssi,
|
add_children({&rssi,
|
||||||
|
&field_volume,
|
||||||
&channel,
|
&channel,
|
||||||
&options_band,
|
&options_band,
|
||||||
&options_pressure,
|
&options_pressure,
|
||||||
@ -179,9 +182,15 @@ TPMSAppView::TPMSAppView(NavigationView&) {
|
|||||||
if (logger) {
|
if (logger) {
|
||||||
logger->append(logs_dir / u"TPMS.TXT");
|
logger->append(logs_dir / u"TPMS.TXT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pmem::beep_on_packets()) {
|
||||||
|
audio::set_rate(audio::Rate::Hz_24000);
|
||||||
|
audio::output::start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TPMSAppView::~TPMSAppView() {
|
TPMSAppView::~TPMSAppView() {
|
||||||
|
audio::output::stop();
|
||||||
receiver_model.disable();
|
receiver_model.disable();
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
@ -214,6 +223,10 @@ void TPMSAppView::on_packet(const tpms::Packet& packet) {
|
|||||||
entry.update(reading);
|
entry.update(reading);
|
||||||
recent_entries_view.set_dirty();
|
recent_entries_view.set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pmem::beep_on_packets()) {
|
||||||
|
baseband::request_audio_beep(1000, 24000, 60);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPMSAppView::on_show_list() {
|
void TPMSAppView::on_show_list() {
|
||||||
|
@ -143,6 +143,9 @@ class TPMSAppView : 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},
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proc_tpms.hpp"
|
#include "proc_tpms.hpp"
|
||||||
|
#include "audio_dma.hpp"
|
||||||
|
|
||||||
#include "dsp_fir_taps.hpp"
|
#include "dsp_fir_taps.hpp"
|
||||||
|
|
||||||
@ -60,7 +61,17 @@ void TPMSProcessor::execute(const buffer_c8_t& buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TPMSProcessor::on_message(const Message* const msg) {
|
||||||
|
if (msg->id == Message::ID::AudioBeep)
|
||||||
|
on_beep_message(*reinterpret_cast<const AudioBeepMessage*>(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TPMSProcessor::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<TPMSProcessor>()};
|
EventDispatcher event_dispatcher{std::make_unique<TPMSProcessor>()};
|
||||||
event_dispatcher.run();
|
event_dispatcher.run();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -140,6 +140,9 @@ class TPMSProcessor : public BasebandProcessor {
|
|||||||
shared_memory.application_queue.push(message);
|
shared_memory.application_queue.push(message);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
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};
|
||||||
|
Loading…
Reference in New Issue
Block a user