diff --git a/firmware/application/ui_sonde.cpp b/firmware/application/ui_sonde.cpp index 8d505394..92720dc0 100644 --- a/firmware/application/ui_sonde.cpp +++ b/firmware/application/ui_sonde.cpp @@ -53,14 +53,14 @@ SondeView::SondeView(NavigationView& nav) { field_frequency.set_value(receiver_model.tuning_frequency()); field_frequency.set_step(receiver_model.frequency_step()); field_frequency.on_change = [this](rf::Frequency f) { - receiver_model.set_tuning_frequency(f); + set_target_frequency(f); field_frequency.set_value(f); }; field_frequency.on_edit = [this, &nav]() { // TODO: Provide separate modal method/scheme? auto new_view = nav.push(receiver_model.tuning_frequency()); new_view->on_changed = [this](rf::Frequency f) { - receiver_model.set_tuning_frequency(f); + set_target_frequency(f); field_frequency.set_value(f); }; }; @@ -74,6 +74,8 @@ SondeView::SondeView(NavigationView& nav) { static_cast(receiver_model.lna()), static_cast(receiver_model.vga()), }); + + set_target_frequency(402000000); /*logger = std::make_unique(); if( logger ) { @@ -90,8 +92,15 @@ void SondeView::focus() { field_vga.focus(); } -void SondeView::on_packet(const sonde::Packet& packet) { - text_debug.set("Got frame !"); +void SondeView::on_packet(const baseband::Packet& packet) { + std::string bin_string; + + for (size_t i = 0; i < 30; i++) { + bin_string += to_string_dec_uint(packet[i]); + } + + text_debug.set(bin_string); + /*if( logger ) { logger->on_packet(packet); }*/ @@ -100,4 +109,13 @@ void SondeView::on_packet(const sonde::Packet& packet) { }*/ } +void SondeView::set_target_frequency(const uint32_t new_value) { + target_frequency_ = new_value; + radio::set_tuning_frequency(tuning_frequency()); +} + +uint32_t SondeView::tuning_frequency() const { + return target_frequency_ - (sampling_rate / 4); +} + } /* namespace ui */ diff --git a/firmware/application/ui_sonde.hpp b/firmware/application/ui_sonde.hpp index 32f35ba9..b00b6336 100644 --- a/firmware/application/ui_sonde.hpp +++ b/firmware/application/ui_sonde.hpp @@ -67,6 +67,7 @@ public: private: //std::unique_ptr logger { }; + uint32_t target_frequency_ { }; FrequencyField field_frequency { { 0 * 8, 0 * 8 }, @@ -96,12 +97,16 @@ private: Message::ID::SondePacket, [this](Message* const p) { const auto message = static_cast(p); - const sonde::Packet packet { message->type, message->packet }; - this->on_packet(packet); + //const sonde::Packet packet { message->type, message->packet }; + //this->on_packet(packet); + this->on_packet(message->packet); } }; - void on_packet(const sonde::Packet& packet); + //void on_packet(const sonde::Packet& packet); + void on_packet(const baseband::Packet& packet); + void set_target_frequency(const uint32_t new_value); + uint32_t tuning_frequency() const; }; } /* namespace ui */ diff --git a/firmware/baseband/proc_sonde.cpp b/firmware/baseband/proc_sonde.cpp index d1af3dee..9743beb6 100644 --- a/firmware/baseband/proc_sonde.cpp +++ b/firmware/baseband/proc_sonde.cpp @@ -28,22 +28,23 @@ #include "event_m4.hpp" SondeProcessor::SondeProcessor() { - decim_0.configure(taps_200k_decim_0.taps, 33554432); - decim_1.configure(taps_200k_decim_1.taps, 131072); + decim_0.configure(taps_11k0_decim_0.taps, 33554432); + decim_1.configure(taps_11k0_decim_1.taps, 131072); } void SondeProcessor::execute(const buffer_c8_t& buffer) { /* 2.4576MHz, 2048 samples */ const auto decim_0_out = decim_0.execute(buffer, dst_buffer); - const auto decimator_out = decim_1.execute(decim_0_out, dst_buffer); + const auto decim_1_out = decim_1.execute(decim_0_out, dst_buffer); + const auto decimator_out = decim_1_out; - /* 307.2kHz, 256 samples */ + /* 38.4kHz, 32 samples */ feed_channel_stats(decimator_out); for(size_t i=0; i clock_recovery_fsk_19k2 { - 38400, 19200, { 0.0555f }, + // AIS: 19200, 9600 + clock_recovery::ClockRecovery clock_recovery_fsk_4800 { + 19200, 4800, { 0.0555f }, [this](const float raw_symbol) { const uint_fast8_t sliced_symbol = (raw_symbol >= 0.0f) ? 1 : 0; this->packet_builder_fsk_4800_M10.execute(sliced_symbol); @@ -78,7 +124,7 @@ private: PacketBuilder packet_builder_fsk_4800_M10 { { 0b11001100110011001010011001001100, 32, 1 }, { }, - { 102 * 8 }, + { 50 }, // { 102 * 8 }, [this](const baseband::Packet& packet) { const SondePacketMessage message { sonde::Packet::Type::M10, packet }; shared_memory.application_queue.push(message);