diff --git a/main.c b/main.c index 07821cb..424b80c 100644 --- a/main.c +++ b/main.c @@ -615,7 +615,16 @@ int16_t dump_buffer[AUDIO_BUFFER_LEN]; int16_t dump_selection = 0; #endif -volatile int16_t wait_count = 0; +volatile uint8_t wait_count = 0; +volatile uint8_t accumerate_count = 0; + +const int8_t bandwidth_accumerate_count[] = { + 1, // 1kHz + 3, // 300Hz + 10, // 100Hz + 33, // 30Hz + 100 // 10Hz +}; float measured[2][POINTS_COUNT][2]; #endif @@ -643,13 +652,16 @@ void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n) (void)i2sp; (void)n; - if (wait_count > 0) { - if (wait_count == 1) + if (wait_count > 1) { + --wait_count; + } else if (wait_count > 0) { + if (accumerate_count > 0) { dsp_process(p, n); + accumerate_count--; + } #ifdef ENABLED_DUMP - duplicate_buffer_to_dump(p); + duplicate_buffer_to_dump(p); #endif - --wait_count; } #if PORT_SUPPORTS_RT @@ -871,20 +883,20 @@ bool sweep(bool break_on_operation) if (frequencies[i] == 0) break; delay = set_frequency(frequencies[i]); // 700 tlv320aic3204_select(0); // 60 CH0:REFLECT, reset and begin measure - DSP_START(delay + ((i == 0) ? 1 : 0)); // 1900 + dsp_start(delay + ((i == 0) ? 1 : 0)); // 1900 //================================================ // Place some code thats need execute while delay //================================================ - DSP_WAIT_READY; + dsp_wait(); // calculate reflection coefficient (*sample_func)(measured[0][i]); // 60 tlv320aic3204_select(1); // 60 CH1:TRANSMISSION, reset and begin measure - DSP_START(DELAY_CHANNEL_CHANGE); // 1700 + dsp_start(DELAY_CHANNEL_CHANGE); // 1700 //================================================ // Place some code thats need execute while delay //================================================ - DSP_WAIT_READY; + dsp_wait(); // calculate transmission coefficient (*sample_func)(measured[1][i]); // 60 // ======== 170 =========== diff --git a/nanovna.h b/nanovna.h index fd0eefc..276df10 100644 --- a/nanovna.h +++ b/nanovna.h @@ -473,6 +473,7 @@ typedef struct properties { #ifdef __VNA__ uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */ uint8_t _marker_smith_format; + uint8_t _bandwidth; #endif uint8_t _reserved[2]; uint32_t checksum; @@ -507,6 +508,7 @@ extern properties_t current_props; #define domain_mode current_props._domain_mode #define velocity_factor current_props._velocity_factor #define marker_smith_format current_props._marker_smith_format +#define bandwidth current_props._bandwidth #endif #define FREQ_IS_STARTSTOP() (!(config.freq_mode&FREQ_MODE_CENTER_SPAN)) diff --git a/ui.c b/ui.c index f89aca6..544d47b 100644 --- a/ui.c +++ b/ui.c @@ -637,6 +637,14 @@ menu_transform_filter_cb(int item, uint8_t data) domain_mode = (domain_mode & ~TD_FUNC) | data; ui_mode_normal(); } + +static void +menu_bandwidth_cb(int item) +{ + bandwidth = item; + draw_menu(); +} + static void choose_active_marker(void) { @@ -940,12 +948,23 @@ const menuitem_t menu_transform[] = { { MT_NONE, 0, NULL, NULL } // sentinel }; +const menuitem_t menu_bandwidth[] = { + { MT_CALLBACK, 0, "1 kHz", menu_bandwidth_cb }, + { MT_CALLBACK, 0, "300 Hz", menu_bandwidth_cb }, + { MT_CALLBACK, 0, "100 Hz", menu_bandwidth_cb }, + { MT_CALLBACK, 0, "30 Hz", menu_bandwidth_cb }, + { MT_CALLBACK, 0, "10 Hz", menu_bandwidth_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel +}; + const menuitem_t menu_display[] = { { MT_SUBMENU, 0, "TRACE", menu_trace }, { MT_SUBMENU, 0, "FORMAT", menu_format }, { MT_SUBMENU, 0, "SCALE", menu_scale }, { MT_SUBMENU, 0, "CHANNEL", menu_channel }, { MT_SUBMENU, 0, "TRANSFORM", menu_transform }, + { MT_SUBMENU, 0, "BANDWIDTH", menu_bandwidth }, { MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel }; @@ -1400,6 +1419,11 @@ menu_item_modify_attribute(const menuitem_t *menu, int item, *bg = DEFAULT_MENU_TEXT_COLOR; *fg = config.menu_normal_color; } + } else if (menu == menu_bandwidth) { + if (item == bandwidth) { + *bg = 0x0000; + *fg = 0xffff; + } } else if (menu == menu_transform) { if ((item == 0 && (domain_mode & DOMAIN_MODE) == DOMAIN_TIME) || (item == 1 && (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_IMPULSE)