Skip to content

Commit

Permalink
Avoid "overloading" of the GUI by high-frequency call to vfo_update().
Browse files Browse the repository at this point in the history
  • Loading branch information
dl1ycf committed Jun 3, 2019
1 parent 084b409 commit fe63d0d
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 44 deletions.
21 changes: 15 additions & 6 deletions README.MIDI
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ provided as an example. The basic rules for the file are

DEVICE=CMD PL

will accept the "CMD PL-1" MIDI controller. Note that events are processed
without looking at the channel number. This is so because for the Behringer
controller, one can accidentally change the channel number by hitting a key.
will accept the "CMD PL-1" MIDI controller.

- The following lines all must contain one of the strings
"KEY=", "CTRL=", or "PITCH=". The syntax is as follows:
Expand All @@ -35,10 +33,15 @@ provided as an example. The basic rules for the file are

The syntay is

KEY=<nr> ACTION=<action> <modifier>
KEY=<nr> CHAN=<chan> ACTION=<action> <modifier>

where <nr> is the Number of the Midi Note
and <action> is the key-word for a SDR "action" (see below)
where <nr> is the Number of the Midi Note, <chan> is the MIDI
channel where the event is expected.

The key words with the line can be given in any order. If
CHAN= is omitted, MIDI events from any channel are accepted.

<action> is the key-word for a SDR "action" (see below)
and <modifier> can be omitted, or can be the string "ONOFF".
If the "ONOFF" modifier is there, an action is taken both upon
Note-On and Note-Off events (usually: when pressing and releasing
Expand Down Expand Up @@ -108,6 +111,12 @@ provided as an example. The basic rules for the file are
generated, since the controller values are always in the range
0-127 and the threshold for fast and very-fast are never reached.

For wheels, there can be an additional directive DELAY=<delay>,
if this is given, it specifies a delay time (in msec) in which no
further WHEEL event is processed. If a wheel is used, for example,
to cycle through the filter settings, a delay takes care that this
does not go too fast.

PITCH: MIDI PITCH sliders
=========================

Expand Down
12 changes: 11 additions & 1 deletion ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,21 @@ int ext_set_frequency(void *data) {
return 0;
}

int ext_vfo_update(void *data) {
static guint vfo_timeout=0;

static int vfo_timeout_cb(void * data) {
vfo_timeout=0;
vfo_update();
return 0;
}

int ext_vfo_update(void *data) {
if (vfo_timeout ==0) {
vfo_timeout=g_timeout_add(100, vfo_timeout_cb, NULL);
}
return 0;
}

int ext_vfo_filter_changed(void *data) {
vfo_filter_changed((int)(uintptr_t)data);
return 0;
Expand Down
3 changes: 2 additions & 1 deletion filter_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "receiver.h"
#include "vfo.h"
#include "button_text.h"
#include "ext.h"

static GtkWidget *parent_window=NULL;

Expand Down Expand Up @@ -87,7 +88,7 @@ static gboolean deviation_select_cb (GtkWidget *widget, gpointer data) {
set_button_text_color(last_filter,"black");
last_filter=widget;
set_button_text_color(last_filter,"orange");
vfo_update();
g_idle_add(ext_vfo_update,NULL);
return FALSE;
}

Expand Down
5 changes: 3 additions & 2 deletions freqent_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "receiver.h"
#include "vfo.h"
#include "button_text.h"
#include "ext.h"

static GtkWidget *parent_window=NULL;
static GtkWidget *dialog=NULL;
Expand Down Expand Up @@ -140,12 +141,12 @@ static gboolean freqent_select_cb (GtkWidget *widget, gpointer data) {
}
}
setFrequency(f);
vfo_update();
g_idle_add(ext_vfo_update,NULL);

set = 1;
}
}
vfo_update();
g_idle_add(ext_vfo_update,NULL);
return FALSE;
}

Expand Down
6 changes: 3 additions & 3 deletions gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ static void encoder_changed(int action,int pos) {
if(protocol==NEW_PROTOCOL) {
schedule_high_priority();
}
vfo_update();
g_idle_add(ext_vfo_update,NULL);
break;
case ENCODER_CW_SPEED:
value=(double)cw_keyer_speed;
Expand All @@ -1375,7 +1375,7 @@ static void encoder_changed(int action,int pos) {
value=60.0;
}
cw_keyer_speed=(int)value;
vfo_update();
g_idle_add(ext_vfo_update,NULL);
break;
case ENCODER_CW_FREQUENCY:
value=(double)cw_keyer_sidetone_frequency;
Expand All @@ -1386,7 +1386,7 @@ static void encoder_changed(int action,int pos) {
value=1000.0;
}
cw_keyer_sidetone_frequency=(int)value;
vfo_update();
g_idle_add(ext_vfo_update,NULL);
break;
case ENCODER_PANADAPTER_HIGH:
value=(double)active_receiver->panadapter_high;
Expand Down
2 changes: 1 addition & 1 deletion gpio_mraa.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ static int vfo_encoder_changed(void *data) {
//entry->frequency=entry->frequency+(pos*step);
//setFrequency(entry->frequency);
setFrequency(entry->frequency+ddsOffset+(pos*step));
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}
free(data);
return 0;
Expand Down
3 changes: 2 additions & 1 deletion noise_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "radio.h"
#include "vfo.h"
#include "button_text.h"
#include "ext.h"

static GtkWidget *parent_window=NULL;

Expand Down Expand Up @@ -66,7 +67,7 @@ void update_noise() {
SetRXAEMNRRun(active_receiver->id, active_receiver->nr2);
SetRXAANFRun(active_receiver->id, active_receiver->anf);
SetRXASNBARun(active_receiver->id, active_receiver->snb);
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

static void nb_none_cb(GtkWidget *widget, gpointer data) {
Expand Down
3 changes: 2 additions & 1 deletion step_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "new_menu.h"
#include "radio.h"
#include "vfo.h"
#include "ext.h"

static GtkWidget *parent_window=NULL;

Expand All @@ -51,7 +52,7 @@ static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_d

static gboolean step_select_cb (GtkWidget *widget, gpointer data) {
step=steps[(uintptr_t)data];
vfo_update();
g_idle_add(ext_vfo_update,NULL);
return FALSE;
}

Expand Down
18 changes: 9 additions & 9 deletions toolbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static gboolean rit_timer_cb(gpointer data) {
if(protocol==NEW_PROTOCOL) {
schedule_high_priority();
}
vfo_update();
g_idle_add(ext_vfo_update,NULL);
return TRUE;
}

Expand Down Expand Up @@ -195,7 +195,7 @@ void ctun_cb (GtkWidget *widget, gpointer data) {
}
vfo[id].ctun_frequency=vfo[id].frequency;
set_offset(active_receiver,vfo[id].offset);
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

static void atob_cb (GtkWidget *widget, gpointer data) {
Expand All @@ -217,15 +217,15 @@ static void split_cb (GtkWidget *widget, gpointer data) {
} else {
tx_set_mode(transmitter,vfo[VFO_A].mode);
}
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

static void rit_enable_cb(GtkWidget *widget, gpointer data) {
vfo[active_receiver->id].rit_enabled=vfo[active_receiver->id].rit_enabled==1?0:1;
if(protocol==NEW_PROTOCOL) {
schedule_high_priority();
}
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

static void rit_cb(GtkWidget *widget, gpointer data) {
Expand All @@ -236,7 +236,7 @@ static void rit_cb(GtkWidget *widget, gpointer data) {
if(protocol==NEW_PROTOCOL) {
schedule_high_priority();
}
vfo_update();
g_idle_add(ext_vfo_update,NULL);
if(i<0) {
rit_minus_timer=g_timeout_add(200,rit_timer_cb,(gpointer)(long)i);
} else {
Expand All @@ -246,7 +246,7 @@ static void rit_cb(GtkWidget *widget, gpointer data) {

static void rit_clear_cb(GtkWidget *widget, gpointer data) {
vfo[active_receiver->id].rit=0;
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

static void freq_cb(GtkWidget *widget, gpointer data) {
Expand All @@ -259,7 +259,7 @@ static void mem_cb(GtkWidget *widget, gpointer data) {

static void vox_cb(GtkWidget *widget, gpointer data) {
vox_enabled=vox_enabled==1?0:1;
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

static void stop() {
Expand Down Expand Up @@ -332,7 +332,7 @@ static void exit_cb(GtkWidget *widget, gpointer data) {

void lock_cb(GtkWidget *widget, gpointer data) {
locked=locked==1?0:1;
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

void mox_cb(GtkWidget *widget, gpointer data) {
Expand Down Expand Up @@ -625,7 +625,7 @@ void sim_function_cb(GtkWidget *widget, gpointer data) {
function=0;
}
update_toolbar_labels();
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

GtkWidget *toolbar_init(int my_width, int my_height, GtkWidget* parent) {
Expand Down
4 changes: 2 additions & 2 deletions transmitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ extern void cw_audio_write(double sample);
static gint update_out_of_band(gpointer data) {
TRANSMITTER *tx=(TRANSMITTER *)data;
tx->out_of_band=0;
vfo_update();
g_idle_add(ext_vfo_update,NULL);
return FALSE;
}

Expand Down Expand Up @@ -1102,7 +1102,7 @@ void tx_set_ps(TRANSMITTER *tx,int state) {
usleep(100000);
tx->puresignal=0;
}
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

void tx_set_twotone(TRANSMITTER *tx,int state) {
Expand Down
22 changes: 11 additions & 11 deletions vfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void vfo_band_changed(int b) {
tx_set_mode(transmitter,vfo[VFO_A].mode);
}
calcDriveLevel();
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

void vfo_bandstack_changed(int b) {
Expand Down Expand Up @@ -342,7 +342,7 @@ void vfo_bandstack_changed(int b) {
tx_set_mode(transmitter,vfo[VFO_A].mode);
}
calcDriveLevel();
vfo_update();
g_idle_add(ext_vfo_update,NULL);

}

Expand Down Expand Up @@ -380,7 +380,7 @@ void vfo_mode_changed(int m) {
tx_set_mode(transmitter,vfo[VFO_A].mode);
}

vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

void vfo_filter_changed(int f) {
Expand All @@ -401,7 +401,7 @@ void vfo_filter_changed(int f) {
break;
}

vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

void vfo_a_to_b() {
Expand All @@ -421,7 +421,7 @@ void vfo_a_to_b() {
if(split) {
tx_set_mode(transmitter,vfo[VFO_B].mode);
}
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

void vfo_b_to_a() {
Expand All @@ -438,7 +438,7 @@ void vfo_b_to_a() {
if(!split) {
tx_set_mode(transmitter,vfo[VFO_B].mode);
}
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

void vfo_a_swap_b() {
Expand Down Expand Up @@ -491,7 +491,7 @@ void vfo_a_swap_b() {
} else {
tx_set_mode(transmitter,vfo[VFO_A].mode);
}
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}

void vfo_step(int steps) {
Expand All @@ -507,7 +507,7 @@ void vfo_step(int steps) {
BANDSTACK_ENTRY* entry=bandstack_entry_get_current();
setFrequency(active_receiver->frequency+(steps*step));
#endif
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}
}

Expand All @@ -529,7 +529,7 @@ void vfo_move(long long hz) {
break;
}
receiver_frequency_changed(active_receiver);
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}
}

Expand Down Expand Up @@ -586,7 +586,7 @@ void vfo_move_to(long long hz) {
}
#endif
#endif
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}
}

Expand Down Expand Up @@ -903,7 +903,7 @@ vfo_step_select_cb (GtkWidget *widget,
gpointer data)
{
step=steps[(int)data];
vfo_update();
g_idle_add(ext_vfo_update,NULL);
}
*/

Expand Down
Loading

0 comments on commit fe63d0d

Please sign in to comment.