Digital mode for waveform widget, 2.4GHZ WLAN channels in jammer

This commit is contained in:
furrtek 2017-01-17 07:00:42 +00:00
parent b10c88e271
commit 368f0f7fb0
10 changed files with 136 additions and 47 deletions

View File

@ -61,20 +61,18 @@ void EncodersView::generate_frame() {
}
void EncodersView::draw_waveform() {
uint32_t n, p = 0, length;
uint32_t n, length;
length = debug_text.length();
for (n = 0; n < length; n++) {
if (debug_text[n] == '0')
waveform_buffer[p] = -128;
waveform_buffer[n] = 0;
else
waveform_buffer[p] = 127;
waveform_buffer[p + 1] = waveform_buffer[p];
p += 2;
waveform_buffer[n] = 1;
}
waveform.set_length(length * 2);
waveform.set_length(length);
waveform.set_dirty();
}

View File

@ -187,6 +187,7 @@ private:
waveform_buffer,
0,
0,
true,
Color::yellow()
};

View File

@ -90,7 +90,7 @@ void JammerView::update_text(uint8_t id, rf::Frequency f) {
}
}
void JammerView::on_retune(const int64_t freq) {
void JammerView::on_retune(const rf::Frequency freq) {
if (freq > 0)
transmitter_model.set_tuning_frequency(freq);
}
@ -140,13 +140,13 @@ JammerView::JammerView(NavigationView& nav) {
});
const auto button_freq_fn = [this, &nav](Button& button) {
uint16_t id = button.id;
rf::Frequency * value_ptr;
if (id & 1)
if (button.id & 1)
value_ptr = &frequency_range[id].max;
else
value_ptr = &frequency_range[id].min;
auto new_view = nav.push<FrequencyKeypadView>(*value_ptr);
new_view->on_changed = [this, value_ptr](rf::Frequency f) {
*value_ptr = f;
@ -172,10 +172,8 @@ JammerView::JammerView(NavigationView& nav) {
text_info2.set_style(&style_info);
text_info3.set_style(&style_info);
options_preset.on_change = [this](size_t n, OptionsField::value_t v) {
(void)n;
for (uint8_t c = 0; c < 3; c++) {
options_preset.on_change = [this](size_t, OptionsField::value_t v) {
for (uint32_t c = 0; c < 3; c++) {
frequency_range[c].min = range_presets[v][c].min;
frequency_range[c].max = range_presets[v][c].max;
}
@ -186,7 +184,7 @@ JammerView::JammerView(NavigationView& nav) {
update_text(0, 0);
};
options_preset.set_selected_index(8); // Sigfox, because they deserve it
options_preset.set_selected_index(8);
button_transmit.on_select = [this, &nav, jammer_ranges](Button&) {
uint8_t c, i = 0;
@ -261,7 +259,7 @@ JammerView::JammerView(NavigationView& nav) {
transmitter_model.enable();
}
} else {
nav.display_modal("Error", "Jamming bandwidth too high.");
nav.display_modal("Error", "Jamming bandwidth too large.");
}
}
};

View File

@ -49,11 +49,11 @@ private:
freq_range_t frequency_range[3];
void update_text(uint8_t id, rf::Frequency f);
void on_retune(const int64_t freq);
void on_retune(const rf::Frequency freq);
// TODO: TDD UMTS, voir doc Arcep
// TODO: Wifi, BT: 2 400 et 2 483,5 MHz
const freq_range_t range_presets[10][3] = {
// TODO: BT: 2 400 et 2 483,5 MHz
const freq_range_t range_presets[23][3] = {
// Orange
{{ true, 935000000, 945000000 }, // GSM 900
{ true, 1808000000, 1832000000 }, // GSM 1800
@ -94,7 +94,7 @@ private:
{ false, 0, 0 },
{ false, 0, 0 }},
// Sigfox
// ISM 868
{{ true, 868000000, 868200000 }, // Center: 868.2MHz BW: 40kHz
{ false, 0, 0 },
{ false, 0, 0 }},
@ -102,7 +102,60 @@ private:
// GPS L1 & L2
{{ true, 1575420000 - 50000, 1575420000 + 50000}, // BW: 100kHz
{ true, 1227600000 - 50000, 1227600000 + 50000 }, // BW: 100kHz
{ false, 0, 0 }}
{ false, 0, 0 }},
// WLAN 2.4G CH1
{{ true, 2412000000 - 11000000, 2412000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH2
{{ true, 2417000000 - 11000000, 2417000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH3
{{ true, 2422000000 - 11000000, 2422000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH4
{{ true, 2427000000 - 11000000, 2427000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH5
{{ true, 2432000000 - 11000000, 2432000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH6
{{ true, 2437000000 - 11000000, 2437000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH7
{{ true, 2442000000 - 11000000, 2442000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH8
{{ true, 2447000000 - 11000000, 2447000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH9
{{ true, 2452000000 - 11000000, 2452000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH10
{{ true, 2457000000 - 11000000, 2457000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH11
{{ true, 2462000000 - 11000000, 2462000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH12
{{ true, 2467000000 - 11000000, 2467000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
// WLAN 2.4G CH13
{{ true, 2472000000 - 11000000, 2472000000 + 11000000}, // BW: 22MHz
{ false, 0, 0 },
{ false, 0, 0 }},
};
@ -166,18 +219,31 @@ private:
};
OptionsField options_preset {
{ 10 * 8, 3 * 16 },
8,
16,
{
{ "Orange ", 0 },
{ "SFR ", 1 },
{ "Bouygues", 2 },
{ "Free ", 3 },
{ "GSM-R ", 4 },
{ "DECT ", 5 },
{ "Optifib ", 6 },
{ "ISM 433 ", 7 },
{ "Sigfox ", 8 },
{ "GPS ", 9 }
{ "GSM Orange FR ", 0 },
{ "GSM SFR FR ", 1 },
{ "GSM Bouygues FR", 2 },
{ "GSM Free FR ", 3 },
{ "GSM-R FR ", 4 },
{ "DECT ", 5 },
{ "Optifib ", 6 },
{ "ISM 433 ", 7 },
{ "ISM 868 ", 8 },
{ "GPS ", 9 },
{ "WLAN 2.4G CH1 ", 10 },
{ "WLAN 2.4G CH2 ", 11 },
{ "WLAN 2.4G CH3 ", 12 },
{ "WLAN 2.4G CH4 ", 13 },
{ "WLAN 2.4G CH5 ", 14 },
{ "WLAN 2.4G CH6 ", 15 },
{ "WLAN 2.4G CH7 ", 16 },
{ "WLAN 2.4G CH8 ", 17 },
{ "WLAN 2.4G CH9 ", 18 },
{ "WLAN 2.4G CH10 ", 19 },
{ "WLAN 2.4G CH11 ", 20 },
{ "WLAN 2.4G CH12 ", 21 },
{ "WLAN 2.4G CH13 ", 22 }
}
};

View File

@ -267,7 +267,7 @@ private:
};
OptionsField options_bloff {
{ 10 * 8, 6 * 16 + 4 },
{ 52, 6 * 16 + 8 },
10,
{
{ "5 seconds", 0 },

View File

@ -54,7 +54,7 @@ void WhipCalcView::update_result() {
length /= 0.14;
if (int(length) <= 4) {
auto elements = to_string_dec_int((int)length, 1);
text_result_ant500.set(elements + " " + frac_str[((int(length * 10.0) % 10) + 1) / 3] + "elements");
text_result_ant500.set(elements + " " + frac_str[((int(length * 10.0) % 10) + 1) / 3] + "ANT500 elements");
} else {
text_result_ant500.set("-");
}
@ -106,6 +106,8 @@ WhipCalcView::WhipCalcView(
button_exit.on_select = [this, &nav](Button&) {
nav.pop();
};
update_result();
}
}

View File

@ -83,7 +83,7 @@ private:
"-"
};
Text text_result_ant500 {
{ 2 * 8, 8 * 16, 14 * 16, 16 },
{ 2 * 8, 8 * 16, 26 * 16, 16 },
"-"
};

View File

@ -57,9 +57,10 @@ public:
void paint_widget_tree(Widget* const w);
private:
void draw_hline(Point p, int width, const Color c);
void draw_vline(Point p, int height, const Color c);
private:
void paint_widget(Widget* const w);
};

View File

@ -1328,14 +1328,15 @@ Waveform::Waveform(
int8_t * data,
uint32_t length,
uint32_t offset,
bool digital,
Color color
) : Widget { parent_rect },
data_ { data },
length_ { length },
offset_ { offset },
digital_ { digital },
color_ { color }
{
data_ += offset_;
//set_focusable(false);
}
@ -1359,6 +1360,7 @@ void Waveform::paint(Painter& painter) {
Coord prev_x = screen_rect().location().x(), prev_y;
float x, x_inc;
Dim h = screen_rect().size().height();
int8_t * data_start = data_ + offset_;
// Clear
painter.fill_rectangle(screen_rect(), Color::black());
@ -1369,17 +1371,37 @@ void Waveform::paint(Painter& painter) {
if (!point_count) return;
x = prev_x + x_inc;
h = h / 2;
prev_y = y_offset + h - (*(data_) * y_scale);
for (n = 1; n < point_count; n++) {
y = y_offset + h - (*(data_ + n) * y_scale);
display.draw_line( {prev_x, prev_y}, {(Coord)x, y}, color_);
prev_x = x;
prev_y = y;
x += x_inc;
if (digital_) {
// Digital waveform: each value is an horizontal line
x = 0;
h--;
for (n = 0; n < point_count; n++) {
y = *(data_start++) ? h : 0;
if (n) {
if (y != prev_y)
painter.draw_vline( {x, y_offset}, h, color_);
}
painter.draw_hline( {x, y_offset + y}, ceil(x_inc), color_);
prev_y = y;
x += x_inc;
}
} else {
// Analog waveform: each value is a point's Y coordinate
x = prev_x + x_inc;
h = h / 2;
prev_y = y_offset + h - (*(data_start++) * y_scale);
for (n = 1; n < point_count; n++) {
y = y_offset + h - (*(data_start++) * y_scale);
display.draw_line( {prev_x, prev_y}, {(Coord)x, y}, color_);
prev_x = x;
prev_y = y;
x += x_inc;
}
}
}

View File

@ -507,7 +507,7 @@ private:
class Waveform : public Widget {
public:
Waveform(Rect parent_rect, int8_t * data, uint32_t length, uint32_t offset, Color color);
Waveform(Rect parent_rect, int8_t * data, uint32_t length, uint32_t offset, bool digital, Color color);
Waveform(const Waveform&) = delete;
Waveform(Waveform&&) = delete;
@ -523,6 +523,7 @@ private:
int8_t * data_;
uint32_t length_;
uint32_t offset_;
bool digital_ { false };
Color color_;
};