mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-09 23:03:38 +00:00
Added a beep duration parameter (#2013)
This commit is contained in:
parent
74442f197d
commit
308573918c
@ -149,9 +149,14 @@ static volatile const gpdma::channel::LLI* tx_next_lli = nullptr;
|
|||||||
static volatile const gpdma::channel::LLI* rx_next_lli = nullptr;
|
static volatile const gpdma::channel::LLI* rx_next_lli = nullptr;
|
||||||
|
|
||||||
static bool single_tx_buffer = false;
|
static bool single_tx_buffer = false;
|
||||||
|
static uint32_t beep_duration_downcounter = 0;
|
||||||
|
|
||||||
static void tx_transfer_complete() {
|
static void tx_transfer_complete() {
|
||||||
tx_next_lli = gpdma_channel_i2s0_tx.next_lli();
|
tx_next_lli = gpdma_channel_i2s0_tx.next_lli();
|
||||||
|
|
||||||
|
if (beep_duration_downcounter != 0)
|
||||||
|
if (--beep_duration_downcounter == 0)
|
||||||
|
beep_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tx_error() {
|
static void tx_error() {
|
||||||
@ -233,11 +238,16 @@ void shrink_tx_buffer(bool shrink) {
|
|||||||
lli_tx_loop[0].lli = lli_pointer(&lli_tx_loop[1]);
|
lli_tx_loop[0].lli = lli_pointer(&lli_tx_loop[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void beep_start(uint32_t freq, uint32_t sample_rate) {
|
void beep_start(uint32_t freq, uint32_t sample_rate, uint32_t beep_duration_ms) {
|
||||||
tone_gen.configure_beep(freq, sample_rate);
|
tone_gen.configure_beep(freq, sample_rate);
|
||||||
|
|
||||||
for (size_t i = 0; i < buffer_samples; i++)
|
for (size_t i = 0; i < buffer_samples; i++)
|
||||||
buffer_tx[i].left = buffer_tx[i].right = tone_gen.process_beep();
|
buffer_tx[i].left = buffer_tx[i].right = tone_gen.process_beep();
|
||||||
|
|
||||||
|
uint32_t beep_interrupt_count = beep_duration_ms * sample_rate / (1000 * transfer_samples);
|
||||||
|
if ((beep_duration_ms != 0) && (beep_interrupt_count == 0))
|
||||||
|
beep_interrupt_count = 1;
|
||||||
|
beep_duration_downcounter = beep_interrupt_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void beep_stop() {
|
void beep_stop() {
|
||||||
|
@ -47,7 +47,7 @@ void init_audio_in();
|
|||||||
void init_audio_out();
|
void init_audio_out();
|
||||||
void disable();
|
void disable();
|
||||||
void shrink_tx_buffer(bool shrink);
|
void shrink_tx_buffer(bool shrink);
|
||||||
void beep_start(uint32_t freq, uint32_t sample_rate);
|
void beep_start(uint32_t freq, uint32_t sample_rate, uint32_t beep_duration_ms);
|
||||||
void beep_stop();
|
void beep_stop();
|
||||||
|
|
||||||
audio::buffer_t tx_empty_buffer();
|
audio::buffer_t tx_empty_buffer();
|
||||||
|
@ -59,7 +59,7 @@ void SondeProcessor::on_message(const Message* const msg) {
|
|||||||
case Message::ID::RequestSignal:
|
case Message::ID::RequestSignal:
|
||||||
if ((*reinterpret_cast<const RequestSignalMessage*>(msg)).signal == RequestSignalMessage::Signal::BeepRequest) {
|
if ((*reinterpret_cast<const RequestSignalMessage*>(msg)).signal == RequestSignalMessage::Signal::BeepRequest) {
|
||||||
float rssi_ratio = (float)last_rssi / (float)RSSI_CEILING;
|
float rssi_ratio = (float)last_rssi / (float)RSSI_CEILING;
|
||||||
int beep_duration = 0;
|
uint32_t beep_duration = 0;
|
||||||
|
|
||||||
if (rssi_ratio <= PROPORTIONAL_BEEP_THRES) {
|
if (rssi_ratio <= PROPORTIONAL_BEEP_THRES) {
|
||||||
beep_duration = BEEP_MIN_DURATION;
|
beep_duration = BEEP_MIN_DURATION;
|
||||||
@ -69,9 +69,7 @@ void SondeProcessor::on_message(const Message* const msg) {
|
|||||||
beep_duration = BEEP_DURATION_RANGE + BEEP_MIN_DURATION;
|
beep_duration = BEEP_DURATION_RANGE + BEEP_MIN_DURATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio::dma::beep_start(beep_freq, AUDIO_SAMPLE_RATE);
|
audio::dma::beep_start(beep_freq, AUDIO_SAMPLE_RATE, beep_duration);
|
||||||
chThdSleepMilliseconds(beep_duration);
|
|
||||||
audio::dma::beep_stop();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user