mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 19:54:39 +00:00
Merge pull request #263 from euquiq/JAMMER-TX_COOLDOWN_TIMERS_IN_SECONDS
JAMMER NOW INCLUDES TWO TIMERS
This commit is contained in:
commit
64bdd3e018
@ -274,6 +274,7 @@ void JammerView::start_tx() {
|
||||
transmitter_model.enable();
|
||||
|
||||
baseband::set_jammer(true, (JammerType)options_type.selected_index(), options_speed.selected_index_value());
|
||||
mscounter = 0; //euquiq: Reset internal ms counter for do_timer()
|
||||
} else {
|
||||
if (out_of_ranges)
|
||||
nav_.display_modal("Error", "Jamming bandwidth too large.\nMust be less than 24MHz.");
|
||||
@ -289,6 +290,59 @@ 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)
|
||||
{
|
||||
if (++seconds >= field_timepause.value())
|
||||
{ //Re-start TX
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (++seconds >= field_timetx.value()) //Start cooling period:
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
JammerView::JammerView(
|
||||
@ -309,6 +363,9 @@ JammerView::JammerView(
|
||||
&text_range_total,
|
||||
&options_speed,
|
||||
&options_hop,
|
||||
&field_timetx,
|
||||
&field_timepause,
|
||||
&field_jitter,
|
||||
&button_transmit
|
||||
});
|
||||
|
||||
@ -321,8 +378,11 @@ JammerView::JammerView(
|
||||
options_hop.set_selected_index(1); // 50ms
|
||||
button_transmit.set_style(&style_val);
|
||||
|
||||
field_timetx.set_value(30);
|
||||
field_timepause.set_value(1);
|
||||
|
||||
button_transmit.on_select = [this](Button&) {
|
||||
if (jamming)
|
||||
if (jamming || cooling)
|
||||
stop_tx();
|
||||
else
|
||||
start_tx();
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "transmitter_model.hpp"
|
||||
#include "message.hpp"
|
||||
#include "jammer.hpp"
|
||||
#include "lfsr_random.hpp"
|
||||
|
||||
using namespace jammer;
|
||||
|
||||
@ -57,78 +58,11 @@ private:
|
||||
.foreground = Color::grey(),
|
||||
};
|
||||
|
||||
/*static constexpr jammer_range_t range_presets[] = {
|
||||
// GSM900 Orange
|
||||
{ true, 935000000, 945000000 }, // BW:10M
|
||||
// GSM1800 Orange
|
||||
{ true, 1808000000, 1832000000 }, // BW:24M
|
||||
|
||||
// GSM900 SFR
|
||||
{ true, 950000000, 960000000 }, // BW:10M
|
||||
// GSM1800 SFR
|
||||
{ true, 1832000000, 1853000000 }, // BW:21M
|
||||
|
||||
// GSM900 Bouygues
|
||||
{ true, 925000000, 935000000 }, // BW:10M
|
||||
// GSM1800 Bouygues
|
||||
{ true, 1858000000, 1880000000 }, // BW:22M
|
||||
|
||||
// GSM900 Free
|
||||
{ true, 945000000, 950000000 }, // BW:5M
|
||||
|
||||
// GSM-R
|
||||
{ true, 921000000, 925000000 }, // BW:4M
|
||||
|
||||
// DECT
|
||||
{ true, 1880000000, 1900000000 }, // BW: 20MHz
|
||||
|
||||
// PMV AFSK
|
||||
{ true, 162930000, 162970000 }, // BW: 40kHz
|
||||
|
||||
// ISM 433
|
||||
{ true, 433050000, 434790000 }, // Center: 433.92MHz BW: 0.2%
|
||||
|
||||
// ISM 868
|
||||
{ true, 868000000, 868200000 }, // Center: 868.2MHz BW: 40kHz
|
||||
|
||||
// GPS L1
|
||||
{ true, 1575420000 - 500000, 1575420000 + 500000 }, // BW: 1MHz
|
||||
// GPS L2
|
||||
{ true, 1227600000 - 1000000, 1227600000 + 1000000 }, // BW: 2MHz
|
||||
|
||||
// WLAN 2.4G CH1
|
||||
{ true, 2412000000 - 11000000, 2412000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH2
|
||||
{ true, 2417000000 - 11000000, 2417000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH3
|
||||
{ true, 2422000000 - 11000000, 2422000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH4
|
||||
{ true, 2427000000 - 11000000, 2427000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH5
|
||||
{ true, 2432000000 - 11000000, 2432000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH6
|
||||
{ true, 2437000000 - 11000000, 2437000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH7
|
||||
{ true, 2442000000 - 11000000, 2442000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH8
|
||||
{ true, 2447000000 - 11000000, 2447000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH9
|
||||
{ true, 2452000000 - 11000000, 2452000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH10
|
||||
{ true, 2457000000 - 11000000, 2457000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH11
|
||||
{ true, 2462000000 - 11000000, 2462000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH12
|
||||
{ true, 2467000000 - 11000000, 2467000000 + 11000000}, // BW: 22MHz
|
||||
// WLAN 2.4G CH13
|
||||
{ true, 2472000000 - 11000000, 2472000000 + 11000000}, // BW: 22MHz
|
||||
};*/
|
||||
|
||||
Labels labels {
|
||||
{ { 2 * 8, 9 * 8 + 4 }, "Start", Color::light_grey() },
|
||||
{ { 23 * 8, 9 * 8 + 4 }, "Stop", Color::light_grey() },
|
||||
{ { 12 * 8, 6 * 8 }, "Center", Color::light_grey() },
|
||||
{ { 12 * 8 + 4, 14 * 8 }, "Width", Color::light_grey() }
|
||||
{ { 2 * 8, 8 * 8 + 4 }, "Start", Color::light_grey() },
|
||||
{ { 23 * 8, 8 * 8 + 4 }, "Stop", Color::light_grey() },
|
||||
{ { 12 * 8, 5 * 8 - 4}, "Center", Color::light_grey() },
|
||||
{ { 12 * 8 + 4, 13 * 8 }, "Width", Color::light_grey() }
|
||||
};
|
||||
|
||||
Checkbox check_enabled {
|
||||
@ -143,19 +77,19 @@ private:
|
||||
};
|
||||
|
||||
Button button_start {
|
||||
{ 0 * 8, 6 * 16, 11 * 8, 28 },
|
||||
{ 0 * 8, 11 * 8, 11 * 8, 28 },
|
||||
""
|
||||
};
|
||||
Button button_stop {
|
||||
{ 19 * 8, 6 * 16, 11 * 8, 28 },
|
||||
{ 19 * 8, 11 * 8, 11 * 8, 28 },
|
||||
""
|
||||
};
|
||||
Button button_center {
|
||||
{ 76, 4 * 16, 11 * 8, 28 },
|
||||
{ 76, 4 * 15 - 4, 11 * 8, 28 },
|
||||
""
|
||||
};
|
||||
Button button_width {
|
||||
{ 76, 8 * 16, 11 * 8, 28 },
|
||||
{ 76, 8 * 15, 11 * 8, 28 },
|
||||
""
|
||||
};
|
||||
};
|
||||
@ -178,12 +112,17 @@ private:
|
||||
NavigationView& nav_;
|
||||
|
||||
void start_tx();
|
||||
void on_timer();
|
||||
void stop_tx();
|
||||
void set_jammer_channel(uint32_t i, uint32_t width, uint64_t center, uint32_t duration);
|
||||
void on_retune(const rf::Frequency freq, const uint32_t range);
|
||||
|
||||
JammerChannel * jammer_channels = (JammerChannel*)shared_memory.bb_data.data;
|
||||
bool jamming { false };
|
||||
bool cooling { false }; //euquiq: Indicates jammer in cooldown
|
||||
uint16_t seconds = 0; //euquiq: seconds counter for toggling tx / cooldown
|
||||
int16_t mscounter = 0; //euquiq: Internal ms counter for do_timer()
|
||||
lfsr_word_t lfsr_v = 1; //euquiq: Used to generate "random" Jitter
|
||||
|
||||
static constexpr Style style_val {
|
||||
.font = font::fixed_8x16,
|
||||
@ -209,13 +148,19 @@ private:
|
||||
};
|
||||
|
||||
Labels labels {
|
||||
{ { 3 * 8, 12 * 16 }, "Type:", Color::light_grey() },
|
||||
{ { 2 * 8, 13 * 16 }, "Speed:", Color::light_grey() },
|
||||
{ { 5 * 8, 14 * 16 }, "Hop:", Color::light_grey() }
|
||||
{ { 2 * 8, 23 * 8 }, "Type:", Color::light_grey() },
|
||||
{ { 1 * 8, 25 * 8 }, "Speed:", Color::light_grey() },
|
||||
{ { 3 * 8, 27 * 8 }, "Hop:", Color::light_grey() },
|
||||
{ { 4 * 8, 29 * 8 }, "TX:", Color::light_grey() },
|
||||
{ { 1 * 8, 31 * 8 }, "Sle3p:", Color::light_grey() }, //euquiq: Token of appreciation to TheSle3p, which made this ehnancement a reality with his bounty.
|
||||
{ { 0 * 8, 33 * 8 }, "Jitter:", Color::light_grey() }, //Maybe the repository curator can keep the "mystype" for some versions.
|
||||
{ { 11 * 8, 29 * 8 }, "Secs.", Color::light_grey() },
|
||||
{ { 11 * 8, 31 * 8 }, "Secs.", Color::light_grey() },
|
||||
{ { 11 * 8, 33 * 8 }, "/60", Color::light_grey() }
|
||||
};
|
||||
|
||||
OptionsField options_type {
|
||||
{ 9 * 8, 12 * 16 },
|
||||
{ 7 * 8, 23 * 8 },
|
||||
8,
|
||||
{
|
||||
{ "Rand FSK", 0 },
|
||||
@ -226,16 +171,16 @@ private:
|
||||
};
|
||||
|
||||
Text text_range_number {
|
||||
{ 22 * 8, 12 * 16, 2 * 8, 16 },
|
||||
{ 16 * 8, 23 * 8, 2 * 8, 16 },
|
||||
"--"
|
||||
};
|
||||
Text text_range_total {
|
||||
{ 24 * 8, 12 * 16, 3 * 8, 16 },
|
||||
{ 18 * 8, 23 * 8, 3 * 8, 16 },
|
||||
"/--"
|
||||
};
|
||||
|
||||
OptionsField options_speed {
|
||||
{ 9 * 8, 13 * 16 },
|
||||
{ 7 * 8, 25 * 8 },
|
||||
6,
|
||||
{
|
||||
{ "10Hz ", 10 },
|
||||
@ -247,7 +192,7 @@ private:
|
||||
};
|
||||
|
||||
OptionsField options_hop {
|
||||
{ 9 * 8, 14 * 16 },
|
||||
{ 7 * 8, 27 * 8 },
|
||||
5,
|
||||
{
|
||||
{ "10ms ", 1 },
|
||||
@ -259,9 +204,33 @@ private:
|
||||
{ "10s ", 1000 }
|
||||
}
|
||||
};
|
||||
|
||||
NumberField field_timetx {
|
||||
{ 7 * 8, 29 * 8 },
|
||||
3,
|
||||
{ 1, 180 },
|
||||
1,
|
||||
' ',
|
||||
};
|
||||
|
||||
NumberField field_timepause {
|
||||
{ 8 * 8, 31 * 8 },
|
||||
2,
|
||||
{ 1, 60 },
|
||||
1,
|
||||
' ',
|
||||
};
|
||||
|
||||
NumberField field_jitter {
|
||||
{ 8 * 8, 33 * 8 },
|
||||
2,
|
||||
{ 1, 60 },
|
||||
1,
|
||||
' ',
|
||||
};
|
||||
|
||||
Button button_transmit {
|
||||
{ 9 * 8, 16 * 16, 96, 48 },
|
||||
{ 148, 212, 80, 80},
|
||||
"START"
|
||||
};
|
||||
|
||||
@ -272,6 +241,14 @@ private:
|
||||
this->on_retune(message->freq, message->range);
|
||||
}
|
||||
};
|
||||
|
||||
MessageHandlerRegistration message_handler_frame_sync {
|
||||
Message::ID::DisplayFrameSync,
|
||||
[this](const Message* const) {
|
||||
this->on_timer();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
|
@ -488,7 +488,7 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
|
||||
{ "APRS", ui::Color::green(), &bitmap_icon_aprs, [&nav](){ nav.push<APRSTXView>(); } },
|
||||
{ "BHT Xy/EP", ui::Color::green(), &bitmap_icon_bht, [&nav](){ nav.push<BHTView>(); } },
|
||||
{ "GPS Sim", ui::Color::yellow(), &bitmap_icon_gps_sim, [&nav](){ nav.push<GpsSimAppView>(); } },
|
||||
{ "Jammer", ui::Color::yellow(), &bitmap_icon_jammer, [&nav](){ nav.push<JammerView>(); } },
|
||||
{ "Jammer", ui::Color::green(), &bitmap_icon_jammer, [&nav](){ nav.push<JammerView>(); } },
|
||||
{ "Key fob", ui::Color::orange(), &bitmap_icon_keyfob, [&nav](){ nav.push<KeyfobView>(); } },
|
||||
{ "LGE tool", ui::Color::yellow(), &bitmap_icon_lge, [&nav](){ nav.push<LGEView>(); } },
|
||||
{ "Morse", ui::Color::green(), &bitmap_icon_morse, [&nav](){ nav.push<MorseView>(); } },
|
||||
|
Loading…
Reference in New Issue
Block a user