diff --git a/firmware/application/ui_afsksetup.cpp b/firmware/application/ui_afsksetup.cpp index 7fd85f90..462f0563 100644 --- a/firmware/application/ui_afsksetup.cpp +++ b/firmware/application/ui_afsksetup.cpp @@ -70,6 +70,7 @@ AFSKSetupView::AFSKSetupView( TransmitterModel& transmitter_model ) : transmitter_model(transmitter_model) { + uint8_t rpt; add_children({ { &text_title, @@ -79,6 +80,10 @@ AFSKSetupView::AFSKSetupView( &field_mark, &text_space, &field_space, + &text_bw, + &field_bw, + &text_repeat, + &field_repeat, &checkbox_lsb, &checkbox_parity, &checkbox_datasize, @@ -93,7 +98,11 @@ AFSKSetupView::AFSKSetupView( field_mark.set_value(persistent_memory::afsk_mark_freq()*100); field_space.set_value(persistent_memory::afsk_space_freq()*100); - + field_bw.set_value(persistent_memory::afsk_bw()); + rpt = (persistent_memory::afsk_config() >> 8) & 0xFF; + if (rpt > 99) rpt = 5; + field_repeat.set_value(rpt); + button_setfreq.on_select = [this,&nav](Button&){ auto new_view = new FrequencyKeypadView { nav, this->transmitter_model.tuning_frequency() }; new_view->on_changed = [this](rf::Frequency f) { @@ -119,14 +128,16 @@ AFSKSetupView::AFSKSetupView( }; button_done.on_select = [this,&nav](Button&){ - uint8_t afsk_config = 0; + uint32_t afsk_config = 0; persistent_memory::set_afsk_mark(field_mark.value()/100); persistent_memory::set_afsk_space(field_space.value()/100); + persistent_memory::set_afsk_bw(field_bw.value()); if (checkbox_lsb.value() == true) afsk_config |= 1; if (checkbox_parity.value() == true) afsk_config |= 2; if (checkbox_datasize.value() == true) afsk_config |= 4; + afsk_config |= (field_repeat.value() << 8); persistent_memory::set_afsk_config(afsk_config); nav.pop(); diff --git a/firmware/application/ui_afsksetup.hpp b/firmware/application/ui_afsksetup.hpp index 15e11282..297f4a11 100644 --- a/firmware/application/ui_afsksetup.hpp +++ b/firmware/application/ui_afsksetup.hpp @@ -67,7 +67,7 @@ private: { 64, 104 }, 5, { 100, 32000 }, - 100, + 25, ' ' }; @@ -79,7 +79,31 @@ private: { 64, 120 }, 5, { 100, 32000 }, - 100, + 25, + ' ' + }; + + Text text_bw { + { 140, 104, 80, 16 }, + "BW: kHz" + }; + NumberField field_bw { + { 172, 104 }, + 3, + { 1, 40 }, + 1, + ' ' + }; + + Text text_repeat { + { 140, 120, 64, 16 }, + "Repeat: " + }; + NumberField field_repeat { + { 204, 120 }, + 2, + { 1, 99 }, + 1, ' ' }; diff --git a/firmware/application/ui_lcr.cpp b/firmware/application/ui_lcr.cpp index c0d64cff..0476eb55 100644 --- a/firmware/application/ui_lcr.cpp +++ b/firmware/application/ui_lcr.cpp @@ -283,17 +283,19 @@ LCRView::LCRView( shared_memory.afsk_phase_inc_mark = persistent_memory::afsk_mark_freq()*(65536*1024)/2280; shared_memory.afsk_phase_inc_space = persistent_memory::afsk_space_freq()*(65536*1024)/2280; + shared_memory.afsk_fmmod = persistent_memory::afsk_bw()*33; // ? + memset(shared_memory.lcrdata, 0, 256); memcpy(shared_memory.lcrdata, lcrframe_f, 256); shared_memory.afsk_transmit_done = false; - shared_memory.afsk_repeat = 5; // DEFAULT + shared_memory.afsk_repeat = ((persistent_memory::afsk_config() >> 8) & 0xFF); context().message_map[Message::ID::TXDone] = [this, &transmitter_model](const Message* const p) { const auto message = static_cast(p); if (message->n > 0) { - char str[8] = "0/5... "; - str[0] = hexify(5-message->n); + char str[8] = "0... "; + str[0] = hexify(message->n); text_status.set(str); } else { text_status.set("Done ! "); @@ -301,7 +303,7 @@ LCRView::LCRView( } }; - text_status.set("0/5... "); + text_status.set("0... "); transmitter_model.enable(); }; diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index c0bc619d..651bf4a0 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -149,9 +149,9 @@ SystemView::SystemView( // Initial view. // TODO: Restore from non-volatile memory? - if (persistent_memory::playing_dead() == 0x59) - navigation_view.push(new PlayDeadView { navigation_view, true }); - else + //if (persistent_memory::playing_dead() == 0x59) + // navigation_view.push(new PlayDeadView { navigation_view, true }); + //else navigation_view.push(new BMPView { navigation_view }); } diff --git a/firmware/baseband/main.cpp b/firmware/baseband/main.cpp index c8ee6370..660bd935 100755 --- a/firmware/baseband/main.cpp +++ b/firmware/baseband/main.cpp @@ -826,7 +826,7 @@ public: sample = sintab[(aphase & 0x03FF0000)>>16]; //FM - frq = sample * 500; + frq = sample * shared_memory.afsk_fmmod; phase = (phase + frq); sphase = phase + (256<<16); diff --git a/firmware/common/portapack_persistent_memory.cpp b/firmware/common/portapack_persistent_memory.cpp index ccf0c2c6..554894c1 100644 --- a/firmware/common/portapack_persistent_memory.cpp +++ b/firmware/common/portapack_persistent_memory.cpp @@ -64,6 +64,10 @@ using afsk_bitrate_range_t = range_t; constexpr afsk_bitrate_range_t afsk_bitrate_range { 600, 9600 }; constexpr int32_t afsk_bitrate_reset_value { 1200 }; +using afsk_bw_range_t = range_t; +constexpr afsk_bw_range_t afsk_bw_range { 1, 40 }; +constexpr int32_t afsk_bw_reset_value { 15 }; + /* struct must pack the same way on M4 and M0 cores. */ struct data_t { // General config @@ -74,6 +78,7 @@ struct data_t { int32_t afsk_mark_freq; int32_t afsk_space_freq; // Todo: optimize size, only 256 bytes of NVRAM ! int32_t afsk_bitrate; + int32_t afsk_bw; uint32_t afsk_config; // Play dead unlock @@ -130,6 +135,15 @@ void set_afsk_bitrate(const int32_t new_value) { data->afsk_bitrate = afsk_bitrate_range.clip(new_value); } +int32_t afsk_bw() { + afsk_bw_range.reset_if_outside(data->afsk_bw, afsk_bw_reset_value); + return data->afsk_bw; +} + +void set_afsk_bw(const int32_t new_value) { + data->afsk_bw = afsk_bw_range.clip(new_value); +} + uint32_t afsk_config() { return data->afsk_config; } diff --git a/firmware/common/portapack_persistent_memory.hpp b/firmware/common/portapack_persistent_memory.hpp index db9970c8..8b8da966 100644 --- a/firmware/common/portapack_persistent_memory.hpp +++ b/firmware/common/portapack_persistent_memory.hpp @@ -49,6 +49,9 @@ void set_afsk_bitrate(const int32_t new_value); uint32_t afsk_config(); void set_afsk_config(const uint32_t new_value); +int32_t afsk_bw(); +void set_afsk_bw(const int32_t new_value); + uint32_t playing_dead(); void set_playing_dead(const uint32_t new_value); diff --git a/firmware/common/portapack_shared_memory.hpp b/firmware/common/portapack_shared_memory.hpp index fc9b2a7d..9a8ccd55 100644 --- a/firmware/common/portapack_shared_memory.hpp +++ b/firmware/common/portapack_shared_memory.hpp @@ -48,6 +48,7 @@ struct SharedMemory { uint32_t afsk_phase_inc_mark; uint32_t afsk_phase_inc_space; uint8_t afsk_repeat; + uint32_t afsk_fmmod; bool afsk_transmit_done; }; diff --git a/firmware/portapack-h1-firmware.bin b/firmware/portapack-h1-firmware.bin index 960b19d6..9d94eb64 100644 Binary files a/firmware/portapack-h1-firmware.bin and b/firmware/portapack-h1-firmware.bin differ