Whistle now works

Moved BW widget in txview
String-ized LCR and AFSK message generator
This commit is contained in:
furrtek 2017-04-18 12:55:49 +01:00
parent fbc054ca75
commit d59ee08f41
30 changed files with 312 additions and 215 deletions

View File

@ -135,16 +135,17 @@ set(CPPSRC
debounce.cpp debounce.cpp
touch.cpp touch.cpp
touch_adc.cpp touch_adc.cpp
adsb.cpp protocols/adsb.cpp
protocols/bht.cpp
protocols/dcs.cpp
protocols/lcr.cpp
protocols/rds.cpp
afsk.cpp afsk.cpp
audio.cpp audio.cpp
${COMMON}/bch_code.cpp ${COMMON}/bch_code.cpp
bht.cpp
ctcss.cpp ctcss.cpp
dcs.cpp
encoder.cpp encoder.cpp
freqman.cpp freqman.cpp
rds.cpp
${COMMON}/lcd_ili9341.cpp ${COMMON}/lcd_ili9341.cpp
${COMMON}/ui.cpp ${COMMON}/ui.cpp
${COMMON}/ui_text.cpp ${COMMON}/ui_text.cpp
@ -270,6 +271,7 @@ set(INCDIR ${CMAKE_CURRENT_BINARY_DIR} ${COMMON} ${PORTINC} ${KERNINC} ${TESTINC
${FATFSINC} ${FATFSINC}
${CHIBIOS}/os/various ${CHIBIOS}/os/various
bitmaps bitmaps
protocols
) )
# #

View File

@ -26,7 +26,7 @@
namespace afsk { namespace afsk {
void generate_data(const char * in_message, char * out_data) { void generate_data(const std::string & in_message, char * out_data) {
const afsk_formats_t * format_def; const afsk_formats_t * format_def;
uint8_t pm, pp, bit, cp, cur_byte, new_byte; uint8_t pm, pp, bit, cp, cur_byte, new_byte;
uint16_t dp; uint16_t dp;
@ -40,7 +40,7 @@ void generate_data(const char * in_message, char * out_data) {
if (format_def->data_bits == 7) { if (format_def->data_bits == 7) {
if (!format_def->use_LUT) { if (!format_def->use_LUT) {
for (dp = 0; dp < strlen(in_message); dp++) { for (dp = 0; dp < in_message.length(); dp++) {
pp = pm; pp = pm;
new_byte = 0; new_byte = 0;
cur_byte = in_message[dp]; cur_byte = in_message[dp];
@ -55,14 +55,10 @@ void generate_data(const char * in_message, char * out_data) {
out_data[dp++] = 0; out_data[dp++] = 0;
out_data[dp] = 0; out_data[dp] = 0;
} else { } else {
for (dp = 0; dp < strlen(in_message); dp++) { for (dp = 0; dp < in_message.length(); dp++) {
pp = pm; pp = pm;
// Do not apply LUT on checksum (last byte) ? cur_byte = in_message[dp];
if (dp != strlen(in_message) - 1)
cur_byte = alt_lookup[(uint8_t)in_message[dp] & 0x7F];
else
cur_byte = in_message[dp];
for (cp = 0; cp < 8; cp++) for (cp = 0; cp < 8; cp++)
if ((cur_byte >> cp) & 1) pp++; if ((cur_byte >> cp) & 1) pp++;

View File

@ -54,19 +54,7 @@ const afsk_formats_t afsk_formats[4] = {
{ "8-Even-0 ", "8E0", 8, EVEN, 1, true, false } { "8-Even-0 ", "8E0", 8, EVEN, 1, true, false }
}; };
// TODO: Complete table void generate_data(const std::string & in_message, char * out_data);
const char alt_lookup[128] = {
0, 0, 0, 0x5F, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0F, // 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10
0xF8, 0, 0x99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20 !"#$%&'()*+,-./
0xF5, 0, 0x94, 0x55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1C, 0, 0, // 30 0123456789:;<=>?
0, 0x3C, 0x9C, 0x5D, 0, 0, 0, 0, 0, 0x44, 0x85, 0, 0xD5, 0x14, 0, 0, // 40 @ABCDEFGHIJKLMNO
0xF0, 0, 0, 0x50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 50 PQRSTUVWXYZ[\]^_
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60 `abcdefghijklmno
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x7F // 70 pqrstuvwxyz{|}~
};
void generate_data(const char * in_message, char * out_data);
} /* namespace afsk */ } /* namespace afsk */

View File

@ -96,6 +96,17 @@ void set_tones_config(const uint32_t bw, const uint32_t pre_silence, const uint1
send_message(&message); send_message(&message);
} }
void kill_tone() {
const TonesConfigureMessage message {
0,
0,
0,
false,
false
};
send_message(&message);
}
void set_sstv_data(const uint8_t vis_code, const uint32_t pixel_duration) { void set_sstv_data(const uint8_t vis_code, const uint32_t pixel_duration) {
const SSTVConfigureMessage message { const SSTVConfigureMessage message {
vis_code, vis_code,
@ -117,6 +128,18 @@ void set_afsk_data(const uint32_t afsk_samples_per_bit, const uint32_t afsk_phas
send_message(&message); send_message(&message);
} }
void kill_afsk() {
const AFSKConfigureMessage message {
0,
0,
0,
0,
0,
false
};
send_message(&message);
}
void set_audiotx_data(const uint32_t divider, const uint32_t bw, const uint32_t gain_x10, void set_audiotx_data(const uint32_t divider, const uint32_t bw, const uint32_t gain_x10,
const bool ctcss_enabled, const uint32_t ctcss_phase_inc) { const bool ctcss_enabled, const uint32_t ctcss_phase_inc) {
const AudioTXConfigMessage message { const AudioTXConfigMessage message {

View File

@ -58,6 +58,7 @@ struct WFMConfig {
void set_tone(const uint32_t index, const uint32_t delta, const uint32_t duration); void set_tone(const uint32_t index, const uint32_t delta, const uint32_t duration);
void set_tones_config(const uint32_t bw, const uint32_t pre_silence, const uint16_t tone_count, void set_tones_config(const uint32_t bw, const uint32_t pre_silence, const uint16_t tone_count,
const bool dual_tone, const bool audio_out); const bool dual_tone, const bool audio_out);
void kill_tone();
void set_sstv_data(const uint8_t vis_code, const uint32_t pixel_duration); void set_sstv_data(const uint8_t vis_code, const uint32_t pixel_duration);
void set_audiotx_data(const uint32_t divider, const uint32_t bw, const uint32_t gain_x10, void set_audiotx_data(const uint32_t divider, const uint32_t bw, const uint32_t gain_x10,
const bool ctcss_enabled, const uint32_t ctcss_phase_inc); const bool ctcss_enabled, const uint32_t ctcss_phase_inc);
@ -65,6 +66,7 @@ void set_fifo_data(const int8_t * data);
void set_pwmrssi(int32_t avg, bool enabled); void set_pwmrssi(int32_t avg, bool enabled);
void set_afsk_data(const uint32_t afsk_samples_per_bit, const uint32_t afsk_phase_inc_mark, const uint32_t afsk_phase_inc_space, void set_afsk_data(const uint32_t afsk_samples_per_bit, const uint32_t afsk_phase_inc_mark, const uint32_t afsk_phase_inc_space,
const uint8_t afsk_repeat, const uint32_t afsk_bw, const bool afsk_alt_format); const uint8_t afsk_repeat, const uint32_t afsk_bw, const bool afsk_alt_format);
void kill_afsk();
void set_ook_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint8_t repeat, void set_ook_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint8_t repeat,
const uint32_t pause_symbols); const uint32_t pause_symbols);
void set_fsk_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint32_t shift, void set_fsk_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint32_t shift,

View File

@ -0,0 +1,73 @@
/*
* 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 "lcr.hpp"
#include "string_format.hpp"
//#include "portapack_persistent_memory.hpp"
namespace lcr {
std::string generate_message(std::string rgsb, std::vector<std::string> litterals, size_t option_ec) {
const std::string ec_lut[4] = { "A", "J", "N", "S" }; // Eclairage (Auto, Jour, Nuit)
char eom[3] = { 3, 0, 0 }; // EOM and space for checksum
uint8_t i;
std::string lcr_message { 127, 127, 127, 127, 127, 127, 127, 15 }; // Modem sync and SOM
char checksum = 0;
// Pad litterals to 7 chars (not required ?)
for (auto & litteral : litterals)
while (litteral.length() < 7)
litteral += ' ';
// Compose LCR message
lcr_message += rgsb;
lcr_message += "PA ";
i = 1;
for (auto & litteral : litterals) {
lcr_message += "AM=";
lcr_message += to_string_dec_uint(i, 1);
lcr_message += " AF=\"";
lcr_message += litteral;
lcr_message += "\" CL=0 ";
i++;
}
lcr_message += "EC=";
lcr_message += ec_lut[option_ec];
lcr_message += " SAB=0";
// Checksum
i = 7; // Skip modem sync
while (lcr_message[i])
checksum ^= lcr_message[i++];
checksum ^= eom[0]; // EOM char
checksum &= 0x7F; // Trim
eom[1] = checksum;
lcr_message += eom;
return lcr_message;
}
} /* namespace lcr */

View File

@ -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.
*/
#include "ui.hpp"
#include <cstring>
#include <string>
#include <vector>
#ifndef __LCR_H__
#define __LCR_H__
namespace lcr {
std::string generate_message(std::string rgsb, std::vector<std::string> litterals, size_t option_ec);
} /* namespace lcr */
#endif/*__LCR_H__*/

View File

@ -281,7 +281,7 @@ DebugMenuView::DebugMenuView(NavigationView& nav) {
on_left = [&nav](){ nav.pop(); }; on_left = [&nav](){ nav.pop(); };
} }
DebugLCRView::DebugLCRView(NavigationView& nav, std::string lcr_string, uint8_t checksum) { DebugLCRView::DebugLCRView(NavigationView& nav, std::string lcr_string) {
std::string debug_text; std::string debug_text;
@ -299,7 +299,7 @@ DebugLCRView::DebugLCRView(NavigationView& nav, std::string lcr_string, uint8_t
debug_text += "\n\n"; debug_text += "\n\n";
debug_text += "Length: " + to_string_dec_uint(lcr_string.length()) + '\n'; debug_text += "Length: " + to_string_dec_uint(lcr_string.length()) + '\n';
debug_text += "Checksum: " + to_string_dec_uint(checksum) + '\n'; debug_text += "Checksum: " + to_string_dec_uint(lcr_string.back()) + '\n';
console.write(debug_text); console.write(debug_text);

View File

@ -210,7 +210,7 @@ private:
class DebugLCRView : public View { class DebugLCRView : public View {
public: public:
DebugLCRView(NavigationView& nav, std::string lcrstring, uint8_t checksum); DebugLCRView(NavigationView& nav, std::string lcrstring);
void focus() override; void focus() override;

View File

@ -25,6 +25,7 @@
#include "ui_debug.hpp" #include "ui_debug.hpp"
#include "afsk.hpp" #include "afsk.hpp"
#include "lcr.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "string_format.hpp" #include "string_format.hpp"
@ -47,58 +48,6 @@ LCRView::~LCRView() {
baseband::shutdown(); baseband::shutdown();
} }
void LCRView::generate_message() {
const char lcr_init[8] = { 127, 127, 127, 127, 127, 127, 127, 15 }; // Modem sync and SOM
const char ec_lut[4][2] = { { 'A', 0x00 }, // Eclairage (Auto, Jour, Nuit)
{ 'J', 0x00 },
{ 'N', 0x00 },
{ 'S', 0x00 } };
char eom[3] = { 3, 0, 0 }; // EOM and space for checksum
uint8_t i;
button_setrgsb.set_text(rgsb);
// Pad litterals to 7 chars (not required ?)
for (i = 0; i < 5; i++)
while (strlen(litteral[i]) < 7)
strcat(litteral[i], " ");
// Compose LCR message
memset(lcr_message, 0, 512);
memcpy(lcr_message, lcr_init, 8);
strcat(lcr_message, rgsb); // Address
strcat(lcr_message, "PA ");
for (i = 0; i < 5; i++) {
if (checkboxes[i].value() == true) {
strcat(lcr_message, "AM=");
strcat(lcr_message, to_string_dec_uint(i + 1, 1).c_str());
strcat(lcr_message, " AF=\"");
strcat(lcr_message, litteral[i]);
strcat(lcr_message, "\" CL=0 ");
}
}
strcat(lcr_message, "EC=");
strcat(lcr_message, ec_lut[options_ec.selected_index()]);
strcat(lcr_message, " SAB=0");
// Checksum
checksum = 0;
i = 7; // Skip modem sync
while (lcr_message[i])
checksum ^= lcr_message[i++];
checksum ^= eom[0]; // EOM char
checksum &= 0x7F; // Trim
eom[1] = checksum;
strcat(lcr_message, eom);
afsk::generate_data(lcr_message, lcr_message_data);
}
void LCRView::paint(Painter& painter) { void LCRView::paint(Painter& painter) {
uint8_t i; uint8_t i;
std::string final_str; std::string final_str;
@ -134,6 +83,17 @@ void LCRView::paint(Painter& painter) {
text_recap.set(final_str); text_recap.set(final_str);
} }
std::vector<std::string> LCRView::parse_litterals() {
std::vector<std::string> litterals;
for (size_t i = 0; i < 5; i++) {
if (checkboxes[i].value())
litterals.push_back(litteral[i]);
}
return litterals;
}
void LCRView::update_progress() { void LCRView::update_progress() {
char str[16]; char str[16];
@ -162,8 +122,6 @@ void LCRView::update_progress() {
} }
void LCRView::on_txdone(int n) { void LCRView::on_txdone(int n) {
char str[16];
if (n > 0) { if (n > 0) {
// Repeating... // Repeating...
repeat_index = n + 1; repeat_index = n + 1;
@ -177,25 +135,13 @@ void LCRView::on_txdone(int n) {
// Done transmitting // Done transmitting
if ((tx_mode == SCAN) && (scan_index < (scan_count - 1))) { if ((tx_mode == SCAN) && (scan_index < (scan_count - 1))) {
transmitter_model.disable(); transmitter_model.disable();
if (abort_scan) { // Next address
// Kill scan process scan_index++;
strcpy(str, "Abort @"); strcpy(rgsb, &scan_list[options_scanlist.selected_index()].addresses[scan_index * 5]);
strcat(str, rgsb); scan_progress++;
text_status.set(str); repeat_index = 1;
progress.set_value(0); update_progress();
tx_mode = IDLE; start_tx(true);
abort_scan = false;
button_scan.set_style(&style_val);
button_scan.set_text("SCAN");
} else {
// Next address
scan_index++;
strcpy(rgsb, &scan_list[options_scanlist.selected_index()].addresses[scan_index * 5]);
scan_progress++;
repeat_index = 1;
update_progress();
start_tx(true);
}
} else { } else {
transmitter_model.disable(); transmitter_model.disable();
tx_mode = IDLE; tx_mode = IDLE;
@ -230,7 +176,8 @@ void LCRView::start_tx(const bool scan) {
update_progress(); update_progress();
} }
generate_message(); button_setrgsb.set_text(rgsb);
afsk::generate_data(lcr::generate_message(rgsb, parse_litterals(), options_ec.selected_index()), lcr_message_data);
switch (portapack::persistent_memory::afsk_format()) { switch (portapack::persistent_memory::afsk_format()) {
case 0: case 0:
@ -259,10 +206,10 @@ void LCRView::start_tx(const bool scan) {
baseband::set_afsk_data( baseband::set_afsk_data(
(153600 * 5) / portapack::persistent_memory::afsk_bitrate(), (153600 * 5) / portapack::persistent_memory::afsk_bitrate(),
portapack::persistent_memory::afsk_mark_freq() * 437 * 5, //(0x40000 * 256) / (153600 / 25), portapack::persistent_memory::afsk_mark_freq() * 437 * 5, // (0x40000 * 256) / (153600 / 25),
portapack::persistent_memory::afsk_space_freq() * 437 * 5, //(0x40000 * 256) / (153600 / 25), portapack::persistent_memory::afsk_space_freq() * 437 * 5, // (0x40000 * 256) / (153600 / 25),
afsk_repeats, afsk_repeats,
portapack::persistent_memory::afsk_bw() * 115, // See proc_afsk.cpp portapack::persistent_memory::afsk_bw() * 115, // See proc_afsk.cpp
afsk_format afsk_format
); );
} }
@ -355,8 +302,7 @@ LCRView::LCRView(NavigationView& nav) {
}; };
button_lcrdebug.on_select = [this, &nav](Button&) { button_lcrdebug.on_select = [this, &nav](Button&) {
generate_message(); nav.push<DebugLCRView>(lcr::generate_message(rgsb, parse_litterals(), options_ec.selected_index()));
nav.push<DebugLCRView>(std::string(lcr_message), checksum);
}; };
button_transmit.on_select = [this](Button&) { button_transmit.on_select = [this](Button&) {
@ -364,12 +310,22 @@ LCRView::LCRView(NavigationView& nav) {
}; };
button_scan.on_select = [this](Button&) { button_scan.on_select = [this](Button&) {
char str[16];
if (tx_mode == IDLE) { if (tx_mode == IDLE) {
button_scan.set_style(&style_cancel); button_scan.set_style(&style_cancel);
button_scan.set_text("ABORT"); button_scan.set_text("ABORT");
start_tx(true); start_tx(true);
} else { } else {
abort_scan = true; // Kill scan process
baseband::kill_afsk();
strcpy(str, "Abort @");
strcat(str, rgsb);
text_status.set(str);
progress.set_value(0);
tx_mode = IDLE;
button_scan.set_style(&style_val);
button_scan.set_text("SCAN");
} }
}; };
@ -383,8 +339,6 @@ LCRView::LCRView(NavigationView& nav) {
checkboxes[n].set_value(true); checkboxes[n].set_value(true);
set_dirty(); set_dirty();
start_tx(false); start_tx(false);
} else if (tx_mode == SCAN) {
abort_scan = true;
} }
}; };
} }

View File

@ -79,18 +79,16 @@ private:
}; };
tx_modes tx_mode = IDLE; tx_modes tx_mode = IDLE;
bool abort_scan = false;
uint8_t scan_count { 0 }, scan_index { 0 }; uint8_t scan_count { 0 }, scan_index { 0 };
double scan_progress { 0 }; double scan_progress { 0 };
char litteral[5][8] = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 } }; char litteral[5][8] = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 } };
char rgsb[5] = { 0 }; char rgsb[5] = { 0 };
char lcr_message[512]; char lcr_message[512];
char lcr_message_data[512]; char lcr_message_data[512];
char checksum = 0;
rf::Frequency f { 0 }; rf::Frequency f { 0 };
uint8_t repeat_index { 0 }; uint8_t repeat_index { 0 };
void generate_message(); std::vector<std::string> parse_litterals();
void update_progress(); void update_progress();
void start_tx(const bool scan); void start_tx(const bool scan);
void on_txdone(int n); void on_txdone(int n);

View File

@ -208,7 +208,7 @@ MorseView::MorseView(
tx_view.on_stop = [this]() { tx_view.on_stop = [this]() {
if (ookthread) chThdTerminate(ookthread); if (ookthread) chThdTerminate(ookthread);
transmitter_model.disable(); transmitter_model.disable();
baseband::set_tones_config(0, 0, 0, false, false); baseband::kill_tone();
tx_view.set_transmitting(false); tx_view.set_transmitting(false);
}; };
} }

View File

@ -326,7 +326,7 @@ TransmitterAudioMenuView::TransmitterAudioMenuView(NavigationView& nav) {
{ "Soundboard", ui::Color::green(), &bitmap_icon_soundboard, [&nav](){ nav.push<SoundBoardView>(); } }, { "Soundboard", ui::Color::green(), &bitmap_icon_soundboard, [&nav](){ nav.push<SoundBoardView>(); } },
{ "Numbers station", ui::Color::yellow(),&bitmap_icon_numbers, [&nav](){ nav.push<NumbersStationView>(); } }, { "Numbers station", ui::Color::yellow(),&bitmap_icon_numbers, [&nav](){ nav.push<NumbersStationView>(); } },
{ "Microphone", ui::Color::green(), &bitmap_icon_microphone, [&nav](){ nav.push<MicTXView>(); } }, { "Microphone", ui::Color::green(), &bitmap_icon_microphone, [&nav](){ nav.push<MicTXView>(); } },
{ "Whistle", ui::Color::orange(),&bitmap_icon_whistle, [&nav](){ nav.push<WhistleView>(); } }, { "Whistle", ui::Color::green(), &bitmap_icon_whistle, [&nav](){ nav.push<WhistleView>(); } },
} }); } });
on_left = [&nav](){ nav.pop(); }; on_left = [&nav](){ nav.pop(); };
} }

View File

@ -36,12 +36,13 @@ void ScriptView::on_frequency_select() {
} }
void ScriptView::on_edit_freq(rf::Frequency f) { void ScriptView::on_edit_freq(rf::Frequency f) {
(void)f;
//frequencies[menu_view.highlighted()].value = f; //frequencies[menu_view.highlighted()].value = f;
setup_list(); setup_list();
} }
void ScriptView::on_edit_desc(NavigationView& nav) { void ScriptView::on_edit_desc(NavigationView& nav) {
(void)nav;
} }
void ScriptView::on_delete() { void ScriptView::on_delete() {
@ -50,7 +51,7 @@ void ScriptView::on_delete() {
} }
void ScriptView::setup_list() { void ScriptView::setup_list() {
size_t n; //size_t n;
menu_view.clear(); menu_view.clear();

View File

@ -100,11 +100,11 @@ private:
}; };
Text text_bw { Text text_bw {
{ 11 * 8, 1 * 8, 9 * 8, 1 * 16 }, { 11 * 8, 2 * 8, 9 * 8, 1 * 16 },
"BW: kHz" "BW: kHz"
}; };
NumberField field_bw { NumberField field_bw {
{ 14 * 8, 1 * 8 }, { 14 * 8, 2 * 8 },
3, 3,
{ 1, 150 }, { 1, 150 },
1, 1,

View File

@ -22,92 +22,86 @@
#include "ui_whistle.hpp" #include "ui_whistle.hpp"
#include "ui_receiver.hpp" #include "ui_receiver.hpp"
#include "tonesets.hpp"
#include "portapack.hpp" #include "baseband_api.hpp"
#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp"
#include "portapack_persistent_memory.hpp"
#include <cstring> #include <cstring>
#include <stdio.h> #include <stdio.h>
using namespace hackrf::one; using namespace portapack;
namespace ui { namespace ui {
void WhistleView::start_tx() {
baseband::set_tone(
0,
field_tone.value() * TONES_DELTA_COEF,
(checkbox_stop.value()) ? field_stop.value() * TONES_SAMPLERATE : 0xFFFFFFFF); // (Almost) infinite duration :)
shared_memory.bb_data.tones_data.message[0] = 0;
transmitter_model.set_sampling_rate(1536000);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable();
baseband::set_tones_config(transmitter_model.bandwidth(), 0, 1, false, false);
tx_mode = SINGLE;
}
void WhistleView::on_tx_progress(const bool done) {
if (done) {
transmitter_model.disable();
tx_view.set_transmitting(false);
tx_mode = IDLE;
}
}
void WhistleView::focus() { void WhistleView::focus() {
button_transmit.focus(); tx_view.focus();
} }
WhistleView::~WhistleView() { WhistleView::~WhistleView() {
//transmitter_model.disable(); transmitter_model.disable();
baseband::shutdown();
} }
void WhistleView::paint(Painter& painter) {
(void)painter;
}
Button WhistleView::button_scan = {
{ 76, 270, 72, 32 },
"SCAN"
};
WhistleView::WhistleView( WhistleView::WhistleView(
NavigationView& nav NavigationView& nav
) )
{ {
baseband::run_image(portapack::spi_flash::image_tag_tones);
add_children({ add_children({
&button_transmit, &labels,
&button_exit &field_tone,
&checkbox_stop,
&field_stop,
&tx_view
}); });
button_transmit.on_select = [this](Button&){ field_tone.set_value(1520);
/*uint16_t c; field_stop.set_value(15);
ui::Context context;
tx_view.on_edit_frequency = [this, &nav]() {
make_frame(); auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {
shared_memory.afsk_samples_per_bit = 228000/persistent_memory::afsk_bitrate(); receiver_model.set_tuning_frequency(f);
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; };
for (c = 0; c < 256; c++) { tx_view.on_start = [this]() {
shared_memory.lcrdata[c] = this->lcrframe[c]; if (tx_mode == IDLE) {
tx_view.set_transmitting(true);
start_tx();
} }
shared_memory.afsk_transmit_done = false;
shared_memory.afsk_repeat = 5; // DEFAULT
text_status.set("Send...");*/
//transmitter_model.enable();
}; };
button_exit.on_select = [&nav](Button&){ tx_view.on_stop = [this]() {
nav.pop(); baseband::kill_tone();
}; };
//static VirtualTimer vt1;
//msg_t msg, result;
/*static EvTimer evt;
static EventListener el0;
evtInit(&evt, MS2ST(2000));
evtStart(&evt);
chEvtRegister(&evt.et_es, &el0, 0);*/
//chVTSet(&vt1, MS2ST(2000), whistle_th, (void *)&mbox);
//while(1) {
/*result = chMBFetch(&mbox, &msg, TIME_INFINITE);
if(result == RDY_OK) {
if(msg & 1)
button_scan.set_text("POUET");
}*/
//chThdSleepMilliseconds(500);
//}
} }
} /* namespace ui */ } /* namespace ui */

View File

@ -24,7 +24,7 @@
#include "ui_widget.hpp" #include "ui_widget.hpp"
#include "ui_painter.hpp" #include "ui_painter.hpp"
#include "ui_navigation.hpp" #include "ui_navigation.hpp"
#include "ui_font_fixed_8x16.hpp" #include "ui_transmitter.hpp"
#include "message.hpp" #include "message.hpp"
#include "transmitter_model.hpp" #include "transmitter_model.hpp"
@ -36,33 +36,59 @@ public:
~WhistleView(); ~WhistleView();
void focus() override; void focus() override;
void paint(Painter& painter) override;
static void whistle_th(void *p); std::string title() const override { return "Whistle"; };
private: private:
rf::Frequency f; void start_tx();
void on_tx_progress(const bool done);
Text text_status { enum tx_modes {
{ 172, 196, 64, 16 }, IDLE = 0,
"Ready" SINGLE
}; };
Checkbox checkbox_am_a { tx_modes tx_mode = IDLE;
{ 16, 68 },
20, Labels labels {
"" { { 3 * 8, 4 * 8 }, "Tone frequency: Hz", Color::light_grey() },
{ { 22 * 8, 8 * 8 + 4 }, "s.", Color::light_grey() }
}; };
Button button_transmit { NumberField field_tone {
{ 24, 270, 48, 32 }, { 19 * 8, 4 * 8 },
"TX" 4,
{ 1, 9999 },
5,
' '
}; };
static Button button_scan; Checkbox checkbox_stop {
{ 5 * 8, 8 * 8 },
10,
"Stop after"
};
Button button_exit { NumberField field_stop {
{ 176, 270, 48, 32 }, { 20 * 8, 8 * 8 + 4 },
"Exit" 2,
{ 1, 99 },
1,
' '
};
TransmitterView tx_view {
16 * 16,
10000,
12
};
MessageHandlerRegistration message_handler_tx_done {
Message::ID::TXDone,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const TXDoneMessage*>(p);
this->on_tx_progress(message.done);
}
}; };
}; };

Binary file not shown.

View File

@ -124,22 +124,25 @@ void AFSKProcessor::on_message(const Message* const msg) {
const auto message = *reinterpret_cast<const AFSKConfigureMessage*>(msg); const auto message = *reinterpret_cast<const AFSKConfigureMessage*>(msg);
if (message.id == Message::ID::AFSKConfigure) { if (message.id == Message::ID::AFSKConfigure) {
afsk_samples_per_bit = message.samples_per_bit; if (message.samples_per_bit) {
afsk_phase_inc_mark = message.phase_inc_mark; afsk_samples_per_bit = message.samples_per_bit;
afsk_phase_inc_space = message.phase_inc_space; afsk_phase_inc_mark = message.phase_inc_mark;
afsk_repeat = message.repeat - 1; afsk_phase_inc_space = message.phase_inc_space;
afsk_bw = message.bw; afsk_repeat = message.repeat - 1;
afsk_format = message.format; afsk_bw = message.bw;
afsk_format = message.format;
s = 0;
sample_count = afsk_samples_per_bit; s = 0;
repeat_counter = 0; sample_count = afsk_samples_per_bit;
bit_pos = 0; repeat_counter = 0;
byte_pos = 0; bit_pos = 0;
cur_byte = 0; byte_pos = 0;
ext_byte = 0; cur_byte = 0;
cur_bit = 0; ext_byte = 0;
configured = true; cur_bit = 0;
configured = true;
} else
configured = false; // Kill
} }
} }

Binary file not shown.

Binary file not shown.