mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-27 16:17:31 -04:00
Morse TX loops
This commit is contained in:
parent
a5a3ba184a
commit
25ba2f1391
2 changed files with 72 additions and 3 deletions
|
@ -69,6 +69,25 @@ static msg_t ookthread_fn(void * arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static msg_t loopthread_fn(void * arg) {
|
||||||
|
MorseView * arg_c = (MorseView*)arg;
|
||||||
|
uint32_t wait = arg_c->loop;
|
||||||
|
|
||||||
|
chRegSetThreadName("loopthread");
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < wait; i++) {
|
||||||
|
if (chThdShouldTerminate()) break;
|
||||||
|
|
||||||
|
arg_c->on_loop_progress(i, false);
|
||||||
|
chThdSleepMilliseconds(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
arg_c->on_loop_progress(0, true);
|
||||||
|
chThdExit(0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void MorseView::on_set_text(NavigationView& nav) {
|
void MorseView::on_set_text(NavigationView& nav) {
|
||||||
text_prompt(nav, buffer, 28);
|
text_prompt(nav, buffer, 28);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +149,22 @@ void MorseView::on_tx_progress(const uint32_t progress, const bool done) {
|
||||||
if (done) {
|
if (done) {
|
||||||
transmitter_model.disable();
|
transmitter_model.disable();
|
||||||
progressbar.set_value(0);
|
progressbar.set_value(0);
|
||||||
|
|
||||||
|
if (loop && run) {
|
||||||
|
text_tx_duration.set("wait");
|
||||||
|
progressbar.set_max(loop);
|
||||||
|
progressbar.set_value(0);
|
||||||
|
loopthread = chThdCreateFromHeap(NULL, 1024, NORMALPRIO, loopthread_fn, this);
|
||||||
|
} else {
|
||||||
tx_view.set_transmitting(false);
|
tx_view.set_transmitting(false);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
progressbar.set_value(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MorseView::on_loop_progress(const uint32_t progress, const bool done) {
|
||||||
|
if (done) {
|
||||||
|
start_tx();
|
||||||
} else
|
} else
|
||||||
progressbar.set_value(progress);
|
progressbar.set_value(progress);
|
||||||
}
|
}
|
||||||
|
@ -155,6 +189,7 @@ MorseView::MorseView(
|
||||||
&field_speed,
|
&field_speed,
|
||||||
&field_tone,
|
&field_tone,
|
||||||
&options_modulation,
|
&options_modulation,
|
||||||
|
&options_loop,
|
||||||
&text_tx_duration,
|
&text_tx_duration,
|
||||||
&text_message,
|
&text_message,
|
||||||
&button_message,
|
&button_message,
|
||||||
|
@ -166,6 +201,7 @@ MorseView::MorseView(
|
||||||
field_speed.set_value(15); // 15wps
|
field_speed.set_value(15); // 15wps
|
||||||
field_tone.set_value(700); // 700Hz FM tone
|
field_tone.set_value(700); // 700Hz FM tone
|
||||||
options_modulation.set_selected_index(0); // CW mode
|
options_modulation.set_selected_index(0); // CW mode
|
||||||
|
options_loop.set_selected_index(0); // Off
|
||||||
|
|
||||||
checkbox_foxhunt.on_select = [this](Checkbox&, bool value) {
|
checkbox_foxhunt.on_select = [this](Checkbox&, bool value) {
|
||||||
foxhunt_mode = value;
|
foxhunt_mode = value;
|
||||||
|
@ -183,6 +219,10 @@ MorseView::MorseView(
|
||||||
modulation = (modulation_t)i;
|
modulation = (modulation_t)i;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
options_loop.on_change = [this](size_t i, uint32_t n) {
|
||||||
|
loop = n;
|
||||||
|
};
|
||||||
|
|
||||||
field_speed.on_change = [this](int32_t) {
|
field_speed.on_change = [this](int32_t) {
|
||||||
update_tx_duration();
|
update_tx_duration();
|
||||||
};
|
};
|
||||||
|
@ -199,12 +239,22 @@ MorseView::MorseView(
|
||||||
};
|
};
|
||||||
|
|
||||||
tx_view.on_start = [this]() {
|
tx_view.on_start = [this]() {
|
||||||
if (start_tx())
|
if (start_tx()) {
|
||||||
|
run = true;
|
||||||
tx_view.set_transmitting(true);
|
tx_view.set_transmitting(true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
tx_view.on_stop = [this]() {
|
tx_view.on_stop = [this]() {
|
||||||
|
run = false;
|
||||||
if (ookthread) chThdTerminate(ookthread);
|
if (ookthread) chThdTerminate(ookthread);
|
||||||
|
|
||||||
|
if (loopthread) {
|
||||||
|
chThdTerminate(loopthread);
|
||||||
|
chThdWait(loopthread);
|
||||||
|
loopthread = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
transmitter_model.disable();
|
transmitter_model.disable();
|
||||||
baseband::kill_tone();
|
baseband::kill_tone();
|
||||||
tx_view.set_transmitting(false);
|
tx_view.set_transmitting(false);
|
||||||
|
|
|
@ -54,11 +54,13 @@ public:
|
||||||
void paint(Painter& painter) override;
|
void paint(Painter& painter) override;
|
||||||
|
|
||||||
void on_tx_progress(const uint32_t progress, const bool done);
|
void on_tx_progress(const uint32_t progress, const bool done);
|
||||||
|
void on_loop_progress(const uint32_t progress, const bool done);
|
||||||
|
|
||||||
std::string title() const override { return "Morse TX"; };
|
std::string title() const override { return "Morse TX"; };
|
||||||
|
|
||||||
uint32_t time_unit_ms { 0 };
|
uint32_t time_unit_ms { 0 };
|
||||||
size_t symbol_count { 0 };
|
size_t symbol_count { 0 };
|
||||||
|
uint32_t loop { 0 };
|
||||||
private:
|
private:
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
std::string buffer { "PORTAPACK" };
|
std::string buffer { "PORTAPACK" };
|
||||||
|
@ -77,12 +79,15 @@ private:
|
||||||
void set_foxhunt(size_t i);
|
void set_foxhunt(size_t i);
|
||||||
|
|
||||||
Thread * ookthread { nullptr };
|
Thread * ookthread { nullptr };
|
||||||
|
Thread * loopthread { nullptr };
|
||||||
bool foxhunt_mode { false };
|
bool foxhunt_mode { false };
|
||||||
|
bool run { false };
|
||||||
|
|
||||||
Labels labels {
|
Labels labels {
|
||||||
{ { 4 * 8, 6 * 8 }, "Speed: wps", Color::light_grey() },
|
{ { 4 * 8, 6 * 8 }, "Speed: wps", Color::light_grey() },
|
||||||
{ { 4 * 8, 8 * 8 }, "Tone: Hz", Color::light_grey() },
|
{ { 4 * 8, 8 * 8 }, "Tone: Hz", Color::light_grey() },
|
||||||
{ { 4 * 8, 10 * 8 }, "Modulation:", Color::light_grey() },
|
{ { 4 * 8, 10 * 8 }, "Modulation:", Color::light_grey() },
|
||||||
|
{ { 4 * 8, 12 * 8 }, "Loop:", Color::light_grey() },
|
||||||
{ { 1 * 8, 25 * 8 }, "TX will last", Color::light_grey() }
|
{ { 1 * 8, 25 * 8 }, "TX will last", Color::light_grey() }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -134,6 +139,20 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
OptionsField options_loop {
|
||||||
|
{ 9 * 8, 12 * 8 },
|
||||||
|
6,
|
||||||
|
{
|
||||||
|
{ "Off", 0 },
|
||||||
|
{ "5 sec", 5 },
|
||||||
|
{ "10 sec", 10 },
|
||||||
|
{ "30 sec", 30 },
|
||||||
|
{ "1 min", 60 },
|
||||||
|
{ "3 min", 180 },
|
||||||
|
{ "5 min", 300 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Text text_tx_duration {
|
Text text_tx_duration {
|
||||||
{ 14 * 8, 25 * 8, 4 * 8, 16 },
|
{ 14 * 8, 25 * 8, 4 * 8, 16 },
|
||||||
"-"
|
"-"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue