Cosmetics + Jammer now in green + Jitter

I think the Jammer deserves a green icon, since it actually does it job pretty well.

Then there is a Jitter parameter. It allows to introduce a jitter from 1/60th of a second up to 60/60th of a second (a full one). It will delay / move forward either the TX or the cooldown period for a maximum of a half of the time you choose as jitter.

Meaning: If I choose 60/60th, a full second of jitter, it will produce a random number from 1 to 60.

Then it will calculate jitter = 30 - randomnumber

THen it will "add" that (positive or negative) time to the  time counter for the next jitter change of state.
This commit is contained in:
euquiq 2021-01-08 11:54:21 -03:00
parent 8859c3d80c
commit 928bce083a
3 changed files with 59 additions and 27 deletions

View file

@ -274,7 +274,6 @@ void JammerView::start_tx() {
transmitter_model.enable();
baseband::set_jammer(true, (JammerType)options_type.selected_index(), options_speed.selected_index_value());
cooling = false;
mscounter = 0; //euquiq: Reset internal ms counter for do_timer()
} else {
if (out_of_ranges)
@ -291,11 +290,13 @@ void JammerView::stop_tx() {
radio::disable();
baseband::set_jammer(false, JammerType::TYPE_FSK, 0);
jamming = false;
cooling = false;
}
//called each 1/60th of second
void JammerView::on_timer() {
if (++mscounter == 60) {
mscounter = 0;
if (jamming)
{
if (cooling)
@ -305,6 +306,15 @@ void JammerView::on_timer() {
transmitter_model.enable();
button_transmit.set_text("STOP");
baseband::set_jammer(true, (JammerType)options_type.selected_index(), options_speed.selected_index_value());
int32_t jitter_amount = field_jitter.value();
if (jitter_amount)
{
lfsr_v = lfsr_iterate(lfsr_v);
jitter_amount = (jitter_amount / 2) - (lfsr_v & jitter_amount);
mscounter += jitter_amount;
}
cooling = false;
seconds = 0;
}
@ -316,13 +326,22 @@ void JammerView::on_timer() {
transmitter_model.disable();
button_transmit.set_text("PAUSED");
baseband::set_jammer(false, JammerType::TYPE_FSK, 0);
int32_t jitter_amount = field_jitter.value();
if (jitter_amount)
{
lfsr_v = lfsr_iterate(lfsr_v);
jitter_amount = (jitter_amount / 2) - (lfsr_v & jitter_amount);
mscounter += jitter_amount;
}
cooling = true;
seconds = 0;
}
}
}
mscounter = 0;
}
}
@ -346,6 +365,7 @@ JammerView::JammerView(
&options_hop,
&field_timetx,
&field_timepause,
&field_jitter,
&button_transmit
});