mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-12-05 16:32:15 +00:00
Added CTCSS decoder in NFM RX
RSSI output is now pitch instead of PWM Disabled RSSI output in WBFM mode
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "portapack.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
using namespace portapack;
|
||||
using namespace tonekey;
|
||||
|
||||
#include "audio.hpp"
|
||||
#include "file.hpp"
|
||||
@@ -97,6 +98,7 @@ AnalogAudioView::AnalogAudioView(
|
||||
&field_vga,
|
||||
&options_modulation,
|
||||
&field_volume,
|
||||
&text_ctcss,
|
||||
&record_view,
|
||||
&waterfall,
|
||||
});
|
||||
@@ -203,6 +205,8 @@ void AnalogAudioView::remove_options_widget() {
|
||||
options_widget.reset();
|
||||
}
|
||||
|
||||
text_ctcss.hidden(true);
|
||||
|
||||
field_lna.set_style(nullptr);
|
||||
options_modulation.set_style(nullptr);
|
||||
field_frequency.set_style(nullptr);
|
||||
@@ -253,7 +257,7 @@ void AnalogAudioView::on_show_options_modulation() {
|
||||
break;
|
||||
|
||||
case ReceiverModel::Mode::NarrowbandFMAudio:
|
||||
widget = std::make_unique<NBFMOptionsView>(options_view_rect, &style_options_group);
|
||||
widget = std::make_unique<NBFMOptionsView>(nbfm_view_rect, &style_options_group);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -262,6 +266,8 @@ void AnalogAudioView::on_show_options_modulation() {
|
||||
|
||||
set_options_widget(std::move(widget));
|
||||
options_modulation.set_style(&style_options_group);
|
||||
|
||||
if (modulation == ReceiverModel::Mode::NarrowbandFMAudio) text_ctcss.hidden(false);
|
||||
}
|
||||
|
||||
void AnalogAudioView::on_frequency_step_changed(rf::Frequency f) {
|
||||
@@ -326,4 +332,24 @@ void AnalogAudioView::squelched() {
|
||||
if (exit_on_squelch) nav_.pop();
|
||||
}
|
||||
|
||||
void AnalogAudioView::handle_coded_squelch(const uint32_t value) {
|
||||
//const std::string value_string = to_string_dec_uint(value / 10) + "." + to_string_dec_uint(value % 10);
|
||||
float diff, min_diff = value;
|
||||
size_t min_idx { 0 };
|
||||
size_t c;
|
||||
|
||||
for (c = 0; c < KEY_TONES_NB; c++) {
|
||||
diff = abs(((float)value / 100.0) - tone_keys[c].second);
|
||||
if (diff < min_diff) {
|
||||
min_idx = c;
|
||||
min_diff = diff;
|
||||
}
|
||||
}
|
||||
|
||||
if (min_diff < 40)
|
||||
text_ctcss.set("CTCSS " + tone_keys[min_idx].first);
|
||||
else
|
||||
text_ctcss.set("???");
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
#include "ui_font_fixed_8x16.hpp"
|
||||
|
||||
#include "tone_key.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
constexpr Style style_options_group {
|
||||
@@ -68,7 +70,6 @@ private:
|
||||
{ 0 * 8, 0 * 16, 2 * 8, 1 * 16 },
|
||||
"BW",
|
||||
};
|
||||
|
||||
OptionsField options_config {
|
||||
{ 3 * 8, 0 * 16 },
|
||||
4,
|
||||
@@ -80,14 +81,13 @@ private:
|
||||
};
|
||||
|
||||
Text text_squelch {
|
||||
{ 9 * 8, 0 * 16, 7 * 8, 1 * 16 },
|
||||
"SQ /100"
|
||||
{ 9 * 8, 0 * 16, 8 * 8, 1 * 16 },
|
||||
"SQ /99"
|
||||
};
|
||||
|
||||
NumberField field_squelch {
|
||||
{ 12 * 8, 0 * 16 },
|
||||
3,
|
||||
{ 0, 100 },
|
||||
2,
|
||||
{ 0, 99 },
|
||||
1,
|
||||
' ',
|
||||
};
|
||||
@@ -108,6 +108,7 @@ private:
|
||||
static constexpr ui::Dim header_height = 3 * 16;
|
||||
|
||||
const Rect options_view_rect { 0 * 8, 1 * 16, 30 * 8, 1 * 16 };
|
||||
const Rect nbfm_view_rect { 0 * 8, 1 * 16, 18 * 8, 1 * 16 };
|
||||
|
||||
NavigationView& nav_;
|
||||
bool exit_on_squelch { false };
|
||||
@@ -154,6 +155,11 @@ private:
|
||||
1,
|
||||
' ',
|
||||
};
|
||||
|
||||
Text text_ctcss {
|
||||
{ 19 * 8, 1 * 16, 11 * 8, 1 * 16 },
|
||||
""
|
||||
};
|
||||
|
||||
std::unique_ptr<Widget> options_widget { };
|
||||
|
||||
@@ -181,6 +187,7 @@ private:
|
||||
void update_modulation(const ReceiverModel::Mode modulation);
|
||||
|
||||
void squelched();
|
||||
void handle_coded_squelch(const uint32_t value);
|
||||
|
||||
MessageHandlerRegistration message_handler_squelch_signal {
|
||||
Message::ID::RequestSignal,
|
||||
@@ -189,7 +196,14 @@ private:
|
||||
this->squelched();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
MessageHandlerRegistration message_handler_coded_squelch {
|
||||
Message::ID::CodedSquelch,
|
||||
[this](const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const CodedSquelchMessage*>(p);
|
||||
this->handle_coded_squelch(message.value);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -171,10 +171,9 @@ void set_fifo_data(const int8_t * data) {
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_pwmrssi(int32_t avg, bool enabled) {
|
||||
const PWMRSSIConfigureMessage message {
|
||||
void set_pitch_rssi(int32_t avg, bool enabled) {
|
||||
const PitchRSSIConfigureMessage message {
|
||||
enabled,
|
||||
1000, // 1kHz
|
||||
avg
|
||||
};
|
||||
send_message(&message);
|
||||
|
||||
@@ -63,7 +63,7 @@ void set_sstv_data(const uint8_t vis_code, const uint32_t pixel_duration);
|
||||
void set_audiotx_data(const uint32_t divider, const uint32_t bw, const uint32_t gain_x10,
|
||||
const uint32_t tone_key_delta, const float tone_key_mix_weight);
|
||||
void set_fifo_data(const int8_t * data);
|
||||
void set_pwmrssi(int32_t avg, bool enabled);
|
||||
void set_pitch_rssi(int32_t avg, bool enabled);
|
||||
void set_afsk_data(const uint32_t afsk_samples_per_bit, const uint32_t afsk_phase_inc_mark, const uint32_t afsk_phase_inc_space,
|
||||
const uint8_t afsk_repeat, const uint32_t afsk_bw, const uint8_t symbol_count);
|
||||
void kill_afsk();
|
||||
|
||||
@@ -79,7 +79,8 @@ const tone_key_t tone_keys[] = {
|
||||
{ "50 0Z", 254.100 },
|
||||
{ "Axient 28kHz", 28000.0 },
|
||||
{ "Sennheiser 32.768k", 32768.0 },
|
||||
{ "Sennheiser 32kHz", 32000.0 },
|
||||
{ "Sennheiser 32.000k", 32000.0 },
|
||||
{ "Sony 32.382k", 32382.0 },
|
||||
{ "Shure 19kHz", 19000.0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
using namespace ui;
|
||||
|
||||
#define KEY_TONES_NB (sizeof(tone_keys) / sizeof(tone_keys[0]))
|
||||
#define KEY_TONES_NB 56
|
||||
|
||||
namespace tonekey {
|
||||
|
||||
|
||||
@@ -36,21 +36,20 @@ using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
|
||||
void RecordView::toggle_pwmrssi() {
|
||||
pwmrssi_enabled = !pwmrssi_enabled;
|
||||
void RecordView::toggle_pitch_rssi() {
|
||||
pitch_rssi_enabled = !pitch_rssi_enabled;
|
||||
|
||||
// Send to RSSI widget
|
||||
const PWMRSSIConfigureMessage message {
|
||||
pwmrssi_enabled,
|
||||
64,
|
||||
const PitchRSSIConfigureMessage message {
|
||||
pitch_rssi_enabled,
|
||||
0
|
||||
};
|
||||
shared_memory.application_queue.push(message);
|
||||
|
||||
if( !pwmrssi_enabled ) {
|
||||
button_pwmrssi.set_foreground(Color::orange());
|
||||
if( !pitch_rssi_enabled ) {
|
||||
button_pitch_rssi.set_foreground(Color::orange());
|
||||
} else {
|
||||
button_pwmrssi.set_foreground(Color::green());
|
||||
button_pitch_rssi.set_foreground(Color::green());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +67,7 @@ RecordView::RecordView(
|
||||
{
|
||||
add_children({
|
||||
&rect_background,
|
||||
&button_pwmrssi,
|
||||
&button_pitch_rssi,
|
||||
&button_record,
|
||||
&text_record_filename,
|
||||
&text_record_dropped,
|
||||
@@ -77,8 +76,8 @@ RecordView::RecordView(
|
||||
|
||||
rect_background.set_parent_rect({ { 0, 0 }, size() });
|
||||
|
||||
button_pwmrssi.on_select = [this](ImageButton&) {
|
||||
this->toggle_pwmrssi();
|
||||
button_pitch_rssi.on_select = [this](ImageButton&) {
|
||||
this->toggle_pitch_rssi();
|
||||
};
|
||||
|
||||
button_record.on_select = [this](ImageButton&) {
|
||||
@@ -238,8 +237,8 @@ void RecordView::update_status_display() {
|
||||
text_record_dropped.set(s);
|
||||
}
|
||||
|
||||
if (pwmrssi_enabled) {
|
||||
button_pwmrssi.invert_colors();
|
||||
if (pitch_rssi_enabled) {
|
||||
button_pitch_rssi.invert_colors();
|
||||
}
|
||||
|
||||
if( sampling_rate ) {
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
private:
|
||||
void toggle();
|
||||
void toggle_pwmrssi();
|
||||
void toggle_pitch_rssi();
|
||||
Optional<File::Error> write_metadata_file(const std::filesystem::path& filename);
|
||||
|
||||
void on_tick_second();
|
||||
@@ -73,7 +73,7 @@ private:
|
||||
void handle_capture_thread_done(const File::Error error);
|
||||
void handle_error(const File::Error error);
|
||||
|
||||
bool pwmrssi_enabled = false;
|
||||
bool pitch_rssi_enabled = false;
|
||||
const std::filesystem::path filename_stem_pattern;
|
||||
const FileType file_type;
|
||||
const size_t write_size;
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
Color::black()
|
||||
};
|
||||
|
||||
ImageButton button_pwmrssi {
|
||||
ImageButton button_pitch_rssi {
|
||||
{ 2, 0 * 16, 3 * 8, 1 * 16 },
|
||||
&bitmap_rssipwm,
|
||||
Color::orange(),
|
||||
|
||||
@@ -75,16 +75,13 @@ void RSSI::paint(Painter& painter) {
|
||||
Color::black()
|
||||
);
|
||||
|
||||
if (pwmrssi_enabled) {
|
||||
const range_t<int> pwmrssi_avg_range { 0, 96 };
|
||||
const auto pwmrssi_avg = pwmrssi_avg_range.clip((avg_ - raw_min) * 96 / raw_delta);
|
||||
baseband::set_pwmrssi(pwmrssi_avg, true);
|
||||
}
|
||||
if (pitch_rssi_enabled)
|
||||
baseband::set_pitch_rssi((avg_ - raw_min) * 2000 / raw_delta, true);
|
||||
}
|
||||
|
||||
void RSSI::set_pwmrssi(bool enabled) {
|
||||
pwmrssi_enabled = enabled;
|
||||
if (!enabled) baseband::set_pwmrssi(0, false);
|
||||
void RSSI::set_pitch_rssi(bool enabled) {
|
||||
pitch_rssi_enabled = enabled;
|
||||
if (!enabled) baseband::set_pitch_rssi(0, false);
|
||||
}
|
||||
|
||||
void RSSI::on_statistics_update(const RSSIStatistics& statistics) {
|
||||
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
int32_t avg_;
|
||||
int32_t max_;
|
||||
|
||||
bool pwmrssi_enabled = false;
|
||||
bool pitch_rssi_enabled = false;
|
||||
|
||||
MessageHandlerRegistration message_handler_stats {
|
||||
Message::ID::RSSIStatistics,
|
||||
@@ -61,16 +61,16 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
MessageHandlerRegistration message_handler_pwmrssi {
|
||||
Message::ID::PWMRSSIConfigure,
|
||||
MessageHandlerRegistration message_handler_pitch_rssi {
|
||||
Message::ID::PitchRSSIConfigure,
|
||||
[this](const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const PWMRSSIConfigureMessage*>(p);
|
||||
this->set_pwmrssi(message.enabled);
|
||||
const auto message = *reinterpret_cast<const PitchRSSIConfigureMessage*>(p);
|
||||
this->set_pitch_rssi(message.enabled);
|
||||
}
|
||||
};
|
||||
|
||||
void on_statistics_update(const RSSIStatistics& statistics);
|
||||
void set_pwmrssi(bool enabled);
|
||||
void set_pitch_rssi(bool enabled);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user