diff --git a/doc/README.md b/doc/README.md deleted file mode 100644 index a6c7c49d..00000000 --- a/doc/README.md +++ /dev/null @@ -1,5 +0,0 @@ -![Stealth mode icon](stealth.png) - -If enabled (green), transmitting will be done with the screen's backlight off. -The TX LED will also be blinking to indicate activity. -Turn the backlight on again by pressing any button. diff --git a/firmware/application/CMakeLists.txt b/firmware/application/CMakeLists.txt index e0c756db..3d168011 100644 --- a/firmware/application/CMakeLists.txt +++ b/firmware/application/CMakeLists.txt @@ -159,6 +159,7 @@ set(CPPSRC ui_bht_tx.cpp ui_channel.cpp ui_closecall.cpp + ui_cw.cpp ui_debug.cpp ui_encoders.cpp ui_font_fixed_8x16.cpp diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index 485eca06..39652aa4 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -29,9 +29,18 @@ //TEST: Imperial in whipcalc +//TODO: Morse transmition time estimate +//TODO: Morse live keying mode ? +/* +Keying speed: 60 or 75 PARIS +Continuous (Fox-oring) +12s transmit, 48s space (Sprint 1/5th) +60s transmit, 240s space (Classic 1/5 min) +60s transmit, 360s space (Classic 1/7 min) +*/ //TODO: Use transmittermodel bw setting //TODO: Use Labels widget wherever possible -//TODO: Use TransmitterView in Morse, TEDI/LCR, Numbers, whistle, jammer... +//TODO: Use TransmitterView in TEDI/LCR, Numbers, whistle, ... //TODO: FreqMan: Add and rename categories //TODO: FreqMan: Sort by category in edit screen //TODO: FreqMan: Cap entry count per category (only done for total entries right now) diff --git a/firmware/application/ui_closecall.hpp b/firmware/application/ui_closecall.hpp index 7558f6d0..836c2011 100644 --- a/firmware/application/ui_closecall.hpp +++ b/firmware/application/ui_closecall.hpp @@ -47,6 +47,7 @@ public: void on_show() override; void on_hide() override; void focus() override; + std::string title() const override { return "Close Call"; }; private: @@ -75,7 +76,7 @@ private: uint8_t slices_counter { 0 }; int16_t last_channel { 0 }; uint32_t weight { 0 }; - uint64_t frequency_acc { 0 }; + int64_t frequency_acc { 0 }; rf::Frequency scan_span { 0 }, resolved_frequency { 0 }; uint16_t locked_imax { 0 }; uint8_t slicemax_pow[32]; // Todo: Cap max slices ! diff --git a/firmware/application/ui_cw.cpp b/firmware/application/ui_cw.cpp new file mode 100644 index 00000000..0bb043a3 --- /dev/null +++ b/firmware/application/ui_cw.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. + * Copyright (C) 2016 Furrtek + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "ui_cw.hpp" + +#include "portapack.hpp" +#include "baseband_api.hpp" + +#include +#include + +using namespace portapack; + +namespace ui { + +void CWTXView::focus() { + tx_view.focus(); +} + +CWTXView::~CWTXView() { + transmitter_model.disable(); + baseband::shutdown(); +} + +void CWTXView::start_tx() { + transmitter_model.set_sampling_rate(1536000U); // Not important + transmitter_model.set_rf_amp(true); + transmitter_model.set_baseband_bandwidth(1750000); // Not important + transmitter_model.enable(); +} + +void CWTXView::stop_tx() { + transmitter_model.disable(); +} + +CWTXView::CWTXView( + NavigationView& nav +) +{ + baseband::run_image(portapack::spi_flash::image_tag_noop); + + add_children({ + &tx_view + }); + + tx_view.on_edit_frequency = [this, &nav]() { + auto new_view = nav.push(receiver_model.tuning_frequency()); + new_view->on_changed = [this](rf::Frequency f) { + receiver_model.set_tuning_frequency(f); + }; + }; + + tx_view.on_start = [this]() { + start_tx(); + tx_view.set_transmitting(true); + }; + + tx_view.on_stop = [this]() { + stop_tx(); + tx_view.set_transmitting(false); + }; + +} + +} /* namespace ui */ diff --git a/firmware/application/ui_cw.hpp b/firmware/application/ui_cw.hpp new file mode 100644 index 00000000..b65833b0 --- /dev/null +++ b/firmware/application/ui_cw.hpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. + * Copyright (C) 2016 Furrtek + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __CW_TX_H__ +#define __CW_TX_H__ + +#include "ui.hpp" +#include "ui_widget.hpp" +#include "ui_navigation.hpp" +#include "ui_transmitter.hpp" + +#include "portapack.hpp" +#include "message.hpp" + +namespace ui { + +class CWTXView : public View { +public: + CWTXView(NavigationView& nav); + ~CWTXView(); + + void focus() override; + + std::string title() const override { return "CW generator"; }; + +private: + void start_tx(); + void stop_tx(); + + TransmitterView tx_view { + 8 * 16, + 10000, + 12 + }; +}; + +} /* namespace ui */ + +#endif/*__CW_TX_H__*/ diff --git a/firmware/application/ui_morse.cpp b/firmware/application/ui_morse.cpp index 20638b70..c95a8534 100644 --- a/firmware/application/ui_morse.cpp +++ b/firmware/application/ui_morse.cpp @@ -20,14 +20,6 @@ * Boston, MA 02110-1301, USA. */ -/* -Keying speed: 60 or 75 PARIS -Continuous (Fox-oring) -12s transmit, 48s space (Sprint 1/5th) -60s transmit, 240s space (Classic 1/5 min) -60s transmit, 360s space (Classic 1/7 min) -*/ - #include "ui_morse.hpp" #include "portapack.hpp" @@ -43,8 +35,6 @@ using namespace portapack; using namespace morse; using namespace hackrf::one; -// TODO: Live keying mode: Dit on left key, dah on right ? - namespace ui { void MorseView::on_set_text(NavigationView& nav) { @@ -66,32 +56,22 @@ void MorseView::paint(Painter&) { } static WORKING_AREA(ookthread_wa, 256); + static msg_t ookthread_fn(void * arg) { uint32_t v = 0, delay = 0; size_t i = 0; uint8_t * message = shared_memory.bb_data.tones_data.message; + uint8_t symbol; MorseView * arg_c = (MorseView*)arg; chRegSetThreadName("ookthread"); for (i = 0; i < arg_c->symbol_count; i++) { if (chThdShouldTerminate()) break; - if (message[i] == 0) { - v = 1; - delay = MORSE_DOT; - } else if (message[i] == 1) { - v = 1; - delay = MORSE_DASH; - } else if (message[i] == 2) { - v = 0; - delay = MORSE_SYMBOL_SPACE; - } else if (message[i] == 3) { - v = 0; - delay = MORSE_LETTER_SPACE; - } else if (message[i] == 4) { - v = 0; - delay = MORSE_WORD_SPACE; - } + symbol = message[i]; + + v = (symbol < 2) ? 1 : 0; + delay = morse_symbols[v]; gpio_tx.write(v); arg_c->on_tx_progress(i, false); diff --git a/firmware/application/ui_morse.hpp b/firmware/application/ui_morse.hpp index 1f535e45..4deacbd2 100644 --- a/firmware/application/ui_morse.hpp +++ b/firmware/application/ui_morse.hpp @@ -54,6 +54,9 @@ public: void paint(Painter& painter) override; void on_tx_progress(const int progress, const bool done); + + std::string title() const override { return "Morse TX"; }; + uint32_t time_unit_ms { 0 }; size_t symbol_count { 0 }; private: diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index d07050fe..678b1714 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -35,6 +35,7 @@ #include "ui_adsbtx.hpp" #include "ui_bht_tx.hpp" #include "ui_closecall.hpp" +#include "ui_cw.hpp" #include "ui_debug.hpp" #include "ui_encoders.hpp" #include "ui_freqman.hpp" @@ -305,10 +306,10 @@ TransmitterCodedMenuView::TransmitterCodedMenuView(NavigationView& nav) { add_items<8>({ { { "ADS-B Mode S", ui::Color::orange(),&bitmap_icon_adsb, [&nav](){ nav.push(); } }, { "BHT Xy/EP", ui::Color::yellow(),&bitmap_icon_bht, [&nav](){ nav.push(); } }, - { "Morse beacon", ui::Color::yellow(),&bitmap_icon_morse, [&nav](){ nav.push(); } }, + { "Morse code", ui::Color::green(), &bitmap_icon_morse, [&nav](){ nav.push(); } }, { "Nuoptix DTMF timecode", ui::Color::green(), &bitmap_icon_nuoptix, [&nav](){ nav.push(); } }, { "OOK remote encoders", ui::Color::green(), &bitmap_icon_remote, [&nav](){ nav.push(); } }, - { "POCSAG", ui::Color::cyan(), &bitmap_icon_pocsag, [&nav](){ nav.push(); } }, + { "POCSAG", ui::Color::green(), &bitmap_icon_pocsag, [&nav](){ nav.push(); } }, { "RDS", ui::Color::green(), &bitmap_icon_rds, [&nav](){ nav.push(); } }, { "TEDI/LCR AFSK", ui::Color::green(), &bitmap_icon_lcr, [&nav](){ nav.push(); } }, } }); @@ -330,8 +331,9 @@ TransmitterAudioMenuView::TransmitterAudioMenuView(NavigationView& nav) { /* UtilitiesView *****************************************************************/ UtilitiesView::UtilitiesView(NavigationView& nav) { - add_items<4>({ { + 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(); } }, diff --git a/firmware/application/ui_transmitter.cpp b/firmware/application/ui_transmitter.cpp index b4f41945..f89b8004 100644 --- a/firmware/application/ui_transmitter.cpp +++ b/firmware/application/ui_transmitter.cpp @@ -136,6 +136,9 @@ TransmitterView::TransmitterView( if (on_edit_frequency) on_edit_frequency(); }; + field_frequency.on_change = [this](rf::Frequency f) { + transmitter_model.set_tuning_frequency(f); + }; button_start.on_select = [this](Button&){ if (transmitting_) { diff --git a/firmware/baseband/CMakeLists.txt b/firmware/baseband/CMakeLists.txt index 1a38cf8a..bf452fef 100644 --- a/firmware/baseband/CMakeLists.txt +++ b/firmware/baseband/CMakeLists.txt @@ -400,6 +400,14 @@ set(MODE_CPPSRC ) DeclareTargets(PADS ads) + +### No op + +set(MODE_CPPSRC + proc_noop.cpp +) +DeclareTargets(PNOP no_operation) + ### HackRF "factory" firmware add_custom_command( diff --git a/firmware/baseband/proc_noop.cpp b/firmware/baseband/proc_noop.cpp new file mode 100644 index 00000000..d6443f23 --- /dev/null +++ b/firmware/baseband/proc_noop.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. + * Copyright (C) 2016 Furrtek + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "proc_noop.hpp" +#include "event_m4.hpp" + +#include + +void NOOPProcessor::execute(const buffer_c8_t& buffer) { + for (size_t i = 0; i() }; + event_dispatcher.run(); + return 0; +} diff --git a/firmware/baseband/proc_noop.hpp b/firmware/baseband/proc_noop.hpp new file mode 100644 index 00000000..97efe0c4 --- /dev/null +++ b/firmware/baseband/proc_noop.hpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. + * Copyright (C) 2016 Furrtek + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PROC_NOOP_H__ +#define __PROC_NOOP_H__ + +#include "baseband_processor.hpp" +#include "baseband_thread.hpp" + +class NOOPProcessor : public BasebandProcessor { +public: + void execute(const buffer_c8_t& buffer) override; + +private: + BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit }; +}; + +#endif diff --git a/firmware/common/morse.cpp b/firmware/common/morse.cpp index adef04dc..e8c6a752 100644 --- a/firmware/common/morse.cpp +++ b/firmware/common/morse.cpp @@ -72,16 +72,14 @@ size_t morse_encode(std::string& message, const uint32_t time_unit_ms, const uin memcpy(shared_memory.bb_data.tones_data.message, morse_message, i); // Setup tone "symbols" - tone_defs[0].delta = TONES_F2D(tone); // 0: Dot - tone_defs[0].duration = (TONES_SAMPLERATE * MORSE_DOT * time_unit_ms) / 1000; - tone_defs[1].delta = TONES_F2D(tone); // 1: Dash - tone_defs[1].duration = (TONES_SAMPLERATE * MORSE_DASH * time_unit_ms) / 1000; - tone_defs[2].delta = 0; // 2: Symbol space - tone_defs[2].duration = (TONES_SAMPLERATE * MORSE_SYMBOL_SPACE * time_unit_ms) / 1000; - tone_defs[3].delta = 0; // 3: Letter space - tone_defs[3].duration = (TONES_SAMPLERATE * MORSE_LETTER_SPACE * time_unit_ms) / 1000; - tone_defs[4].delta = 0; // 4: Word space - tone_defs[4].duration = (TONES_SAMPLERATE * MORSE_WORD_SPACE * time_unit_ms) / 1000; + for (c = 0; c < 5; c++) { + if (c < 2) + tone_defs[c].delta = TONES_F2D(tone); // Dot and dash + else + tone_defs[c].delta = 0; // Pause + + tone_defs[c].duration = (TONES_SAMPLERATE * morse_symbols[c] * time_unit_ms) / 1000; + } return i; } diff --git a/firmware/common/morse.hpp b/firmware/common/morse.hpp index 73058111..92ad9809 100644 --- a/firmware/common/morse.hpp +++ b/firmware/common/morse.hpp @@ -34,6 +34,14 @@ #define MORSE_WORD_SPACE 7 namespace morse { + +const uint32_t morse_symbols[5] = { + MORSE_DOT, + MORSE_DASH, + MORSE_SYMBOL_SPACE, + MORSE_LETTER_SPACE, + MORSE_WORD_SPACE +}; size_t morse_encode(std::string& message, const uint32_t time_unit_ms, const uint32_t tone); diff --git a/firmware/common/spi_image.hpp b/firmware/common/spi_image.hpp index 353cd4f7..aac1982c 100644 --- a/firmware/common/spi_image.hpp +++ b/firmware/common/spi_image.hpp @@ -84,6 +84,8 @@ constexpr image_tag_t image_tag_adsb_tx { 'P', 'A', 'D', 'S' }; constexpr image_tag_t image_tag_replay { 'P', 'R', 'E', 'P' }; constexpr image_tag_t image_tag_fsktx { 'P', 'F', 'S', 'K' }; +constexpr image_tag_t image_tag_noop { 'P', 'N', 'O', 'P' }; + constexpr image_tag_t image_tag_hackrf { 'H', 'R', 'F', '1' }; struct chunk_t { diff --git a/firmware/portapack-h1-havoc.bin b/firmware/portapack-h1-havoc.bin index 5692c201..ebb10184 100644 Binary files a/firmware/portapack-h1-havoc.bin and b/firmware/portapack-h1-havoc.bin differ