From 50c5c4a453a56ddb70e65910820fff06bb22000d Mon Sep 17 00:00:00 2001 From: sq8mvy Date: Wed, 18 Mar 2020 01:06:16 +0100 Subject: [PATCH] Improved operation of the "frames per second" setting. --- display_menu.c | 2 ++ radio.c | 2 +- receiver.c | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/display_menu.c b/display_menu.c index 995ff72..2097ffb 100644 --- a/display_menu.c +++ b/display_menu.c @@ -79,7 +79,9 @@ static void filled_cb(GtkWidget *widget, gpointer data) { static void frames_per_second_value_changed_cb(GtkWidget *widget, gpointer data) { updates_per_second=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); + active_receiver->fps=updates_per_second; calculate_display_average(active_receiver); + set_displaying(active_receiver, 1); } static void panadapter_high_value_changed_cb(GtkWidget *widget, gpointer data) { diff --git a/radio.c b/radio.c index 1b82210..e4536f7 100644 --- a/radio.c +++ b/radio.c @@ -2325,7 +2325,7 @@ void calculate_display_average(RECEIVER *rx) { double t=0.001*display_average_time; display_avb = exp(-1.0 / ((double)rx->fps * t)); - display_average = max(2, (int)min(60, (double)rx->fps * t)); + display_average = max(2, (int)fmin(60, (double)rx->fps * t)); SetDisplayAvBackmult(rx->id, 0, display_avb); SetDisplayNumAverage(rx->id, 0, display_average); } diff --git a/receiver.c b/receiver.c index 583cc32..dc6694e 100644 --- a/receiver.c +++ b/receiver.c @@ -589,7 +589,8 @@ static gint update_display(gpointer data) { void set_displaying(RECEIVER *rx,int state) { rx->displaying=state; if(state) { - rx->update_timer_id=gdk_threads_add_timeout_full(G_PRIORITY_HIGH_IDLE,1000/rx->fps, update_display, rx, NULL); + if(rx->update_timer_id>=0) g_source_remove(rx->update_timer_id); + rx->update_timer_id=g_timeout_add_full(G_PRIORITY_HIGH_IDLE,1000/rx->fps, update_display, rx, NULL); } else { rx->update_timer_id=-1; } @@ -690,7 +691,7 @@ static void init_analyzer(RECEIVER *rx) { int max_w = fft_size + (int) min(keep_time * (double) rx->fps, keep_time * (double) fft_size * (double) rx->fps); - overlap = (int)max(0.0, ceil(fft_size - (double)rx->sample_rate / (double)rx->fps)); + overlap = (int)fmax(0.0, ceil(fft_size - (double)rx->sample_rate / (double)rx->fps)); //g_print("SetAnalyzer id=%d buffer_size=%d overlap=%d\n",rx->id,rx->buffer_size,overlap); -- 2.45.2