diff --git a/firmware/application/bitmap.hpp b/firmware/application/bitmap.hpp index 9aacbc46..02195683 100644 --- a/firmware/application/bitmap.hpp +++ b/firmware/application/bitmap.hpp @@ -629,6 +629,28 @@ static constexpr Bitmap bitmap_icon_previous { { 16, 16 }, bitmap_icon_previous_data }; +static constexpr uint8_t bitmap_icon_cwgen_data[] = { + 0x00, 0x00, + 0x00, 0x00, + 0xC0, 0xC0, + 0x20, 0x21, + 0x20, 0x21, + 0x21, 0x21, + 0x21, 0x21, + 0x21, 0x21, + 0x12, 0x12, + 0x12, 0x12, + 0x12, 0x12, + 0x12, 0x12, + 0x12, 0x12, + 0x0C, 0x0C, + 0x00, 0x00, + 0x00, 0x00, +}; +static constexpr Bitmap bitmap_icon_cwgen { + { 16, 16 }, bitmap_icon_cwgen_data +}; + static constexpr uint8_t bitmap_icon_receivers_data[] = { 0xC0, 0x07, 0x30, 0x18, diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index d68b25d3..0e221012 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -29,7 +29,7 @@ //TEST: Imperial in whipcalc -//TODO: Roger beep in mic tx +//TODO: Optimize (and group ?) CTCSS tone gen code //TODO: Morse use prosigns //TODO: Morse live keying mode ? /* diff --git a/firmware/application/ui_mictx.cpp b/firmware/application/ui_mictx.cpp index 03e5a44a..3510e8f9 100644 --- a/firmware/application/ui_mictx.cpp +++ b/firmware/application/ui_mictx.cpp @@ -49,7 +49,6 @@ void MicTXView::update_vumeter() { void MicTXView::on_tx_done() { // Roger beep transmitted, stop transmitting - transmitting = false; set_tx(false); } @@ -89,8 +88,8 @@ void MicTXView::set_tx(bool enable) { ); gpio_tx.write(0); led_tx.off(); - transmitting = false; } + transmitting = false; } } @@ -126,7 +125,7 @@ void MicTXView::do_timing() { } else { // PTT disable :( const auto switches_state = get_switches_state(); - if (!switches_state[1]) // Left button + if (!switches_state[1] && transmitting) // Left button set_tx(false); } } diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index bc174697..660e56d7 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -322,9 +322,9 @@ TransmitterCodedMenuView::TransmitterCodedMenuView(NavigationView& nav) { TransmitterAudioMenuView::TransmitterAudioMenuView(NavigationView& nav) { add_items<4>({ { { "Soundboard", ui::Color::green(), &bitmap_icon_soundboard, [&nav](){ nav.push(); } }, - { "Numbers station", ui::Color::orange(),&bitmap_icon_numbers, [&nav](){ nav.push(); } }, + { "Numbers station", ui::Color::yellow(),&bitmap_icon_numbers, [&nav](){ nav.push(); } }, { "Microphone", ui::Color::green(), &bitmap_icon_microphone, [&nav](){ nav.push(); } }, - { "Whistle", ui::Color::yellow(),&bitmap_icon_whistle, [&nav](){ nav.push(); } }, + { "Whistle", ui::Color::orange(),&bitmap_icon_whistle, [&nav](){ nav.push(); } }, } }); on_left = [&nav](){ nav.pop(); }; } @@ -333,11 +333,11 @@ TransmitterAudioMenuView::TransmitterAudioMenuView(NavigationView& nav) { UtilitiesView::UtilitiesView(NavigationView& nav) { add_items<5>({ { - { "Frequency manager", ui::Color::green(), nullptr, [&nav](){ nav.push(); } }, - { "CW generator", ui::Color::green(), nullptr, [&nav](){ nav.push(); } }, - { "Whip antenna length", ui::Color::yellow(),nullptr, [&nav](){ nav.push(); } }, - { "Notepad", ui::Color::grey(), nullptr, [&nav](){ nav.push(); } }, - { "Wipe SD card", ui::Color::red(), nullptr, [&nav](){ nav.push(); } }, + { "Frequency manager", ui::Color::green(), nullptr, [&nav](){ nav.push(); } }, + { "CW generator", ui::Color::green(), &bitmap_icon_cwgen, [&nav](){ nav.push(); } }, + { "Whip antenna length", ui::Color::yellow(),nullptr, [&nav](){ nav.push(); } }, + { "Notepad", ui::Color::grey(), nullptr, [&nav](){ nav.push(); } }, + { "Wipe SD card", ui::Color::red(), nullptr, [&nav](){ nav.push(); } }, } }); on_left = [&nav](){ nav.pop(); }; } diff --git a/firmware/baseband/proc_mictx.cpp b/firmware/baseband/proc_mictx.cpp index 5cba94de..e9e74043 100644 --- a/firmware/baseband/proc_mictx.cpp +++ b/firmware/baseband/proc_mictx.cpp @@ -21,6 +21,7 @@ */ #include "proc_mictx.hpp" +#include "tonesets.hpp" #include "portapack_shared_memory.hpp" #include "sine_table_int8.hpp" #include "event_m4.hpp" @@ -37,18 +38,36 @@ void MicTXProcessor::execute(const buffer_c8_t& buffer){ for (size_t i = 0; i> 6] >> 8; // 1536000 / 64 = 24000 - sample = (sample * (int32_t)gain_x10) / 10; - - power += (sample < 0) ? -sample : sample; // Power mean for UI vu-meter - - if (!as) { - as = divider; - level_message.value = power / (divider / 4); // Why ? - shared_memory.application_queue.push(level_message); - power = 0; + if (!play_beep) { + sample = audio_buffer.p[i >> 6] >> 8; // 1536000 / 64 = 24000 + sample = (sample * (int32_t)gain_x10) / 10; + + power += (sample < 0) ? -sample : sample; // Power average for UI vu-meter + + if (!as) { + as = divider; + level_message.value = power / (divider / 4); // Why ? + shared_memory.application_queue.push(level_message); + power = 0; + } else { + as--; + } } else { - as--; + if (beep_timer) { + beep_timer--; + } else { + beep_timer = 76800; // 50ms @ 1536000Hz + if (beep_index == BEEP_TONES_NB) { + configured = false; + fm_delta = 0; // Zero-out the IQ output for the rest of the buffer + shared_memory.application_queue.push(txdone_message); + } else { + beep_phase_inc = beep_deltas[beep_index]; + beep_index++; + } + } + sample = sine_table_i8[(beep_phase & 0xFF000000U) >> 24]; + beep_phase += beep_phase_inc; } if (ctcss_enabled) { @@ -88,14 +107,18 @@ void MicTXProcessor::on_message(const Message* const msg) { divider = config_message.divider; ctcss_enabled = config_message.ctcss_enabled; ctcss_phase_inc = config_message.ctcss_phase_inc; + + txdone_message.done = true; + play_beep = false; configured = true; break; case Message::ID::RequestSignal: if (request_message.signal == RequestSignalMessage::Signal::BeepRequest) { - // TODO - txdone_message.done = true; + beep_index = 0; + beep_timer = 0; + play_beep = true; } break; diff --git a/firmware/baseband/proc_mictx.hpp b/firmware/baseband/proc_mictx.hpp index 4c63d847..a3208d3a 100644 --- a/firmware/baseband/proc_mictx.hpp +++ b/firmware/baseband/proc_mictx.hpp @@ -34,7 +34,7 @@ public: void on_message(const Message* const msg) override; private: - bool configured = false; + bool configured { false }; BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit }; @@ -49,10 +49,12 @@ private: uint32_t divider { }, gain_x10 { }; uint32_t as { 0 }; uint32_t fm_delta { 0 }; + bool play_beep { false }; bool ctcss_enabled { false }; uint32_t ctcss_phase_inc { }; uint32_t ctcss_phase { 0 }, phase { 0 }, sphase { 0 }; int32_t ctcss_sample { 0 }, sample { 0 }, sample_mixed { }, delta { }; + uint32_t beep_phase { 0 }, beep_phase_inc { }, beep_index { }, beep_timer { }; uint64_t power { 0 }; int8_t re { 0 }, im { 0 }; diff --git a/firmware/application/tonesets.hpp b/firmware/common/tonesets.hpp similarity index 93% rename from firmware/application/tonesets.hpp rename to firmware/common/tonesets.hpp index f19fb702..4f8450fb 100644 --- a/firmware/application/tonesets.hpp +++ b/firmware/common/tonesets.hpp @@ -23,13 +23,15 @@ #ifndef __TONESETS_H__ #define __TONESETS_H__ -#include "portapack.hpp" +#include #define TONES_SAMPLERATE 1536000 #define TONES_DELTA_COEF ((1ULL << 32) / TONES_SAMPLERATE) #define TONES_F2D(f) (uint32_t)(f * TONES_DELTA_COEF) +#define BEEP_TONES_NB 6 + #define DTMF_C0 TONES_F2D(1209) #define DTMF_C1 TONES_F2D(1336) #define DTMF_C2 TONES_F2D(1477) @@ -116,4 +118,13 @@ const uint32_t zvei_deltas[16] = { TONES_F2D(680) }; +const uint32_t beep_deltas[BEEP_TONES_NB] = { + TONES_F2D(1475), + TONES_F2D(740), + TONES_F2D(587), + TONES_F2D(1109), + TONES_F2D(831), + TONES_F2D(740) +}; + #endif/*__TONESETS_H__*/ diff --git a/firmware/graphics/icon_cwgen.png b/firmware/graphics/icon_cwgen.png new file mode 100644 index 00000000..85cfc5b7 Binary files /dev/null and b/firmware/graphics/icon_cwgen.png differ diff --git a/firmware/portapack-h1-havoc.bin b/firmware/portapack-h1-havoc.bin index 3fc5051e..b66c4f6c 100644 Binary files a/firmware/portapack-h1-havoc.bin and b/firmware/portapack-h1-havoc.bin differ