From 71bf58bd71e9fa7c529c603371770562546f3eeb Mon Sep 17 00:00:00 2001 From: c vw Date: Wed, 11 Mar 2020 12:30:18 +0100 Subject: [PATCH] Make SetPK field write-able --- ps_menu.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ps_menu.c b/ps_menu.c index 5cbf8e7..9334cbd 100644 --- a/ps_menu.c +++ b/ps_menu.c @@ -39,6 +39,8 @@ static GtkWidget *get_pk; static GtkWidget *set_pk; static GtkWidget *tx_att; +static double pk_val; +static char pk_text[16]; /* * PureSignal 2.0 parameters and declarations */ @@ -105,6 +107,20 @@ static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_d return FALSE; } +static void setpk_cb(GtkWidget *widget, gpointer data) { + double newpk=-1.0; + const gchar *text; + text = gtk_entry_get_text(GTK_ENTRY(widget)); + sscanf(text,"%lf",&newpk); + if (newpk > 0.01 && newpk < 1.01 && fabs(newpk-pk_val) > 0.01) { + pk_val=newpk; + SetPSHWPeak(transmitter->id, pk_val); + } + // Display new value. If illegal text has been entered, display new one. + sprintf(pk_text,"%6.3f",pk_val); + gtk_entry_set_text(GTK_ENTRY(set_pk),pk_text); +} + // // This is called every 100 msec and therefore // must be a state machine @@ -546,14 +562,13 @@ void ps_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),lbl,col,row,1,1); col++; - double pk; - char pk_text[16]; - GetPSHWPeak(transmitter->id,&pk); - sprintf(pk_text,"%6.3f",pk); + GetPSHWPeak(transmitter->id,&pk_val); + sprintf(pk_text,"%6.3f",pk_val); set_pk=gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(set_pk),pk_text); gtk_grid_attach(GTK_GRID(grid),set_pk,col,row,1,1); gtk_entry_set_width_chars(GTK_ENTRY(set_pk), 10); + g_signal_connect(set_pk, "activate", G_CALLBACK(setpk_cb), NULL); col++; lbl=gtk_label_new("TX ATT"); -- 2.45.2