Added back frequency display for CTCSS

Attempted to fix replay, just fixed StreamBuffer read() and added
waterfall display...
Updated binary
This commit is contained in:
furrtek
2017-12-06 13:20:51 +00:00
parent d77337dd77
commit 3221992ad1
18 changed files with 133 additions and 54 deletions
+1 -2
View File
@@ -333,12 +333,11 @@ void AnalogAudioView::squelched() {
}
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++) {
for (c = 0; c < tone_keys.size(); c++) {
diff = abs(((float)value / 100.0) - tone_keys[c].second);
if (diff < min_diff) {
min_idx = c;
+1
View File
@@ -27,6 +27,7 @@
//TEST: Check AFSK transmit end, skips last bits ?
//TEST: Imperial in whipcalc
//BUG: Crash on rename file with long filename
//BUG: Auto backlight off doesn't work anymore
//BUG: CPLD-related rx ok, tx bad, see portapack.cpp lines 214+ to disable CPLD overlay
//BUG: REPLAY See what's wrong with quality (format, or need for interpolation filter ?)
+5 -6
View File
@@ -51,7 +51,7 @@ ReplayAppView::ReplayAppView(
&field_frequency_step,
&field_rf_amp,
&replay_view,
//&waterfall,
&waterfall,
});
replay_view.set_file_list(file_list);
@@ -89,17 +89,16 @@ ReplayAppView::~ReplayAppView() {
void ReplayAppView::on_hide() {
// TODO: Terrible kludge because widget system doesn't notify Waterfall that
// it's being shown or hidden.
//waterfall.on_hide();
waterfall.on_hide();
View::on_hide();
}
/*void ReplayAppView::set_parent_rect(const Rect new_parent_rect) {
void ReplayAppView::set_parent_rect(const Rect new_parent_rect) {
View::set_parent_rect(new_parent_rect);
const ui::Rect waterfall_rect { 0, header_height, new_parent_rect.width(), static_cast<ui::Dim>(new_parent_rect.height() - header_height) };
const ui::Rect waterfall_rect { 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height };
waterfall.set_parent_rect(waterfall_rect);
}*/
}
void ReplayAppView::focus() {
if (!file_error) {
+2 -5
View File
@@ -41,7 +41,7 @@ public:
void on_hide() override;
//void set_parent_rect(const Rect new_parent_rect) override;
void set_parent_rect(const Rect new_parent_rect) override;
void focus() override;
@@ -54,9 +54,6 @@ private:
static constexpr ui::Dim header_height = 2 * 16;
static constexpr uint32_t sampling_rate = 500000;
static constexpr uint32_t baseband_bandwidth = 2500000;
void on_target_frequency_changed(rf::Frequency f);
rf::Frequency target_frequency() const;
@@ -79,7 +76,7 @@ private:
16384, 3
};
//spectrum::WaterfallWidget waterfall { };
spectrum::WaterfallWidget waterfall { };
};
} /* namespace ui */
+36 -4
View File
@@ -76,16 +76,48 @@ msg_t ReplayThread::static_fn(void* arg) {
Optional<File::Error> ReplayThread::run() {
BasebandReplay replay { &config };
BufferExchange buffers { &config };
StreamBuffer* prefill_buffer { nullptr };
// TESTING: Prefill
// While empty buffers fifo is not empty...
while (!buffers.empty()) {
prefill_buffer = buffers.get_prefill();
if (prefill_buffer == nullptr) {
buffers.put_app(prefill_buffer);
} else {
size_t blocks = prefill_buffer->capacity() / 512;
for (size_t c = 0; c < blocks; c++) {
auto read_result = reader->read(&((uint8_t*)prefill_buffer->data())[c * 512], 512);
if( read_result.is_error() ) {
return read_result.error();
}
}
prefill_buffer->set_size(prefill_buffer->capacity());
buffers.put(prefill_buffer);
//if (!buffers.put(prefill_buffer)) for(;;) {};
}
};
while( !chThdShouldTerminate() ) {
auto buffer = buffers.get();
auto read_result = reader->read(buffer->data(), buffer->capacity());
buffer->set_size(buffer->capacity());
if( read_result.is_error() ) {
return read_result.error();
size_t blocks = buffer->capacity() / 512;
for (size_t c = 0; c < blocks; c++) {
auto read_result = reader->read(&((uint8_t*)buffer->data())[c * 512], 512);
if( read_result.is_error() ) {
return read_result.error();
}
}
buffer->set_size(buffer->capacity());
buffers.put(buffer);
}
+15 -7
View File
@@ -20,12 +20,12 @@
* Boston, MA 02110-1301, USA.
*/
#include "tone_key.hpp"
#include "string_format.hpp"
#include "tone_key.hpp"
namespace tonekey {
const tone_key_t tone_keys[] = {
const tone_key_t tone_keys = {
{ "None", 0.0 },
{ "0 XZ", 67.000 },
{ "1 WZ", 69.400 },
@@ -90,14 +90,22 @@ void tone_keys_populate(OptionsField& field) {
options_t tone_key_options;
std::string tone_name;
for (size_t c = 0; c < KEY_TONES_NB; c++) {
if (c && (c < 51))
tone_name = "CTCSS " + tone_keys[c].first;
else
for (size_t c = 0; c < tone_keys.size(); c++) {
if (c && c < 51) {
auto f = tone_keys[c].second;
tone_name = "CTCSS " + tone_keys[c].first + " " + to_string_dec_uint(f) + "." + to_string_dec_uint((uint32_t)(f * 10) % 10);
} else {
tone_name = tone_keys[c].first;
}
tone_key_options.emplace_back(tone_name, c);
}
field.set_options(tone_key_options);
}
float tone_key_frequency(const uint32_t index) {
return tone_keys[index].second;
}
}
+3 -4
View File
@@ -28,15 +28,14 @@
using namespace ui;
#define KEY_TONES_NB 56
namespace tonekey {
using tone_key_t = std::pair<std::string, float>;
using tone_key_t = std::vector<std::pair<std::string, float>>;
extern const tone_key_t tone_keys[];
extern const tone_key_t tone_keys;
void tone_keys_populate(OptionsField& field);
float tone_key_frequency(const uint32_t index);
}
+1 -1
View File
@@ -59,7 +59,7 @@ void MicTXView::configure_baseband() {
sampling_rate / 20, // Update vu-meter at 20Hz
transmitting ? transmitter_model.channel_bandwidth() : 0,
mic_gain_x10,
TONES_F2D(tone_keys[tone_key_index].second),
TONES_F2D(tone_key_frequency(tone_key_index)),
0.2 // 20% mix
);
}
+1 -1
View File
@@ -91,7 +91,7 @@ void ReplayView::set_file_list(const std::vector<std::filesystem::path>& file_li
for (const auto& file : file_list) {
bbd_file.open("/" + file.string());
duration = bbd_file.size() / (2 * 2 * sampling_rate / 4);
duration = bbd_file.size() / (2 * 2 * sampling_rate / 8);
file_options.emplace_back(file.string().substr(0, 8), duration);
}
options_files.set_options(file_options);
+1 -1
View File
@@ -105,7 +105,7 @@ private:
std::unique_ptr<ReplayThread> replay_thread { };
MessageHandlerRegistration message_handler_capture_thread_error {
MessageHandlerRegistration message_handler_replay_thread_error {
Message::ID::CaptureThreadDone,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const ReplayThreadDoneMessage*>(p);
+1 -1
View File
@@ -127,7 +127,7 @@ void SoundBoardView::play_sound(uint16_t id) {
divider,
number_bw.value() * 1000,
10,
TONES_F2D(tone_keys[tone_key_index].second),
TONES_F2D(tone_key_frequency(tone_key_index)),
0.2 // 20% mix
);
}