diff --git a/firmware/application/ui_encoders.cpp b/firmware/application/ui_encoders.cpp index 5c1b1cac..0fc395cc 100644 --- a/firmware/application/ui_encoders.cpp +++ b/firmware/application/ui_encoders.cpp @@ -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(); } diff --git a/firmware/application/ui_encoders.hpp b/firmware/application/ui_encoders.hpp index a4f3054a..dc4fd3b8 100644 --- a/firmware/application/ui_encoders.hpp +++ b/firmware/application/ui_encoders.hpp @@ -187,6 +187,7 @@ private: waveform_buffer, 0, 0, + true, Color::yellow() }; diff --git a/firmware/application/ui_jammer.cpp b/firmware/application/ui_jammer.cpp index 297bf180..52a841c9 100644 --- a/firmware/application/ui_jammer.cpp +++ b/firmware/application/ui_jammer.cpp @@ -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(*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."); } } }; diff --git a/firmware/application/ui_jammer.hpp b/firmware/application/ui_jammer.hpp index 59eadeef..2d243934 100644 --- a/firmware/application/ui_jammer.hpp +++ b/firmware/application/ui_jammer.hpp @@ -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 } } }; diff --git a/firmware/application/ui_setup.hpp b/firmware/application/ui_setup.hpp index e01010dc..6ea21fdb 100644 --- a/firmware/application/ui_setup.hpp +++ b/firmware/application/ui_setup.hpp @@ -267,7 +267,7 @@ private: }; OptionsField options_bloff { - { 10 * 8, 6 * 16 + 4 }, + { 52, 6 * 16 + 8 }, 10, { { "5 seconds", 0 }, diff --git a/firmware/application/ui_whipcalc.cpp b/firmware/application/ui_whipcalc.cpp index e4179439..bc7c8e4e 100644 --- a/firmware/application/ui_whipcalc.cpp +++ b/firmware/application/ui_whipcalc.cpp @@ -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(); } } diff --git a/firmware/application/ui_whipcalc.hpp b/firmware/application/ui_whipcalc.hpp index ae1053e5..94c7f501 100644 --- a/firmware/application/ui_whipcalc.hpp +++ b/firmware/application/ui_whipcalc.hpp @@ -83,7 +83,7 @@ private: "-" }; Text text_result_ant500 { - { 2 * 8, 8 * 16, 14 * 16, 16 }, + { 2 * 8, 8 * 16, 26 * 16, 16 }, "-" }; diff --git a/firmware/common/ui_painter.hpp b/firmware/common/ui_painter.hpp index dd393884..84afa2b9 100644 --- a/firmware/common/ui_painter.hpp +++ b/firmware/common/ui_painter.hpp @@ -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); }; diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index d376b05b..fef1c5c2 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -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; + } } } diff --git a/firmware/common/ui_widget.hpp b/firmware/common/ui_widget.hpp index 31759437..eed09a30 100644 --- a/firmware/common/ui_widget.hpp +++ b/firmware/common/ui_widget.hpp @@ -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_; };