summaryrefslogtreecommitdiff
path: root/menus.c
diff options
context:
space:
mode:
Diffstat (limited to 'menus.c')
-rw-r--r--menus.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/menus.c b/menus.c
index a2398bd..a8c9daa 100644
--- a/menus.c
+++ b/menus.c
@@ -8,7 +8,9 @@
#include "version.h"
#include "flash.h"
#include "nicutils.h"
+#include "menus.h"
#include <glib.h>
+#include <math.h>
/* define common strings */
@@ -155,7 +157,6 @@
/* KEY MENU-JUGGLING VARIABLES - controlling what is actually shown on the display */
-char temp[LCD_col_width+1];
int menu_cursor_pos;
int last_button_state; /* keeping track of button presses (software flip-flop) */
@@ -228,7 +229,6 @@ static int Menu_Is_Item_Visible(int LCD_entry)
void Menu_Update_Display(void)
{
- char units[2*LCD_col_width];
char a_string[2*LCD_col_width];
char b_string[2*LCD_col_width];
int LCD_entry, LCD_row, LCD_col;
@@ -711,15 +711,15 @@ void Menu_Update_Display(void)
}
strcat(a_string,":");
+ gchar *temp = NULL;
if (globals.ChannelState[chan].zout==globals.Flash.zout_max[chan]) {
- sprintf(temp, "%d", globals.Flash.zout_max[chan]);
+ temp = g_strdup_printf ("%d\xf4 ", globals.Flash.zout_max[chan]);
strcat(a_string,temp);
- strcat(a_string,"\xf4 ");
} else {
- sprintf(temp, "%d", globals.Flash.zout_min[chan]);
+ temp = g_strdup_printf ("%d\xf4 ", globals.Flash.zout_min[chan]);
strcat(a_string,temp);
- strcat(a_string,"\xf4 ");
}
+ g_free (temp);
Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_zout) && Menu_Is_Item_Visible(LCD_entry),
LCD_row,LCD_col,a_string,Show_No_Number,sig_dig-globals.Flash.ChanKey_zout,LCD_col_width-1,LCD_string);
@@ -1267,7 +1267,6 @@ static void Submenu_Display(int redraw)
int channel;
int current_operating_mode;
int add_spaces;
- int error_num;
char LCD_string[LCD_cols+1];
current_operating_mode=0;
@@ -1890,18 +1889,18 @@ static void Submenu_Display(int redraw)
break;
case mode_zout_max:
strcpy(mode_name[i],"Zout = ");
- sprintf(temp, "%d", globals.Flash.zout_max[channel]);
- strcat(mode_name[i],temp);
- strcat(mode_name[i],"\xf4");
+ gchar *temp1 = g_strdup_printf ("%d\xf4", globals.Flash.zout_max[channel]);
+ strcat(mode_name[i],temp1);
+ g_free (temp1);
if (globals.ChannelState[channel].zout==globals.Flash.zout_max[channel]) {
current_operating_mode=i;
}
break;
case mode_zout_min:
strcpy(mode_name[i],"Zout = ");
- sprintf(temp, "%d", globals.Flash.zout_min[channel]);
- strcat(mode_name[i],temp);
- strcat(mode_name[i],"\xf4");
+ gchar *temp2 = g_strdup_printf ("%d\xf4", globals.Flash.zout_min[channel]);
+ strcat(mode_name[i],temp2);
+ g_free (temp2);
if (globals.ChannelState[channel].zout==globals.Flash.zout_min[channel]) {
current_operating_mode=i;
}
@@ -2099,8 +2098,6 @@ static void Submenu_Display(int redraw)
}
}
-
- return OK;
}
@@ -2295,11 +2292,9 @@ static void Submenu_Service_Encoder(int encoder_change)
{
int error_num;
- int new_encoder_change;
- char num_string[32]; /* submenu_value in string form */
- char expon[32]; /* exponent portion of string */
+ char expon[32]; /* exponent portion of string */
int equivalent_integer; /* non-exponent part stripped of its decimal point */
- char new_string[32]; /* new parameter value to be loaded, string format */
+ char new_string[32]; /* new parameter value to be loaded, string format */
float new_value; /* new parameter value to be loaded */
float abs_Submenu_Value; /* absolute value of Submenu_Value */
int increment_size;
@@ -2487,9 +2482,10 @@ static void Submenu_Service_Encoder(int encoder_change)
}
}
+ gchar *num_string = NULL; /* submenu_value in string form */
/* get a string version of the floating value to be modified */
- Float_To_Text(3,abs_Submenu_Value,num_string);
+ Float_To_Text(3,abs_Submenu_Value,&num_string);
/* isolate the exponent and non-exponent parts */
strcpy(expon,num_string+5);
@@ -2532,6 +2528,8 @@ static void Submenu_Service_Encoder(int encoder_change)
equivalent_integer+=encoder_change;
}
+ g_free (num_string);
+
/* don't let it change too much */
if (equivalent_integer<1000) {
equivalent_integer=995;
@@ -2714,12 +2712,13 @@ static void Submenu_Service_Encoder(int encoder_change)
if (globals.Flash.min_offset[channel]==globals.Flash.max_offset[channel]) {
return;
}
- if (fabs(new_value) < globals.Flash.ampl_zero_equiv[channel])
+ if (fabs(new_value) < globals.Flash.ampl_zero_equiv[channel]) {
if (Submenu_Value<0.0) {
new_value=-smallest_allowed_number;
} else {
new_value=smallest_allowed_number;
}
+ }
if (error_num=Set_Offset(0,0,0,0,channel,new_value)) {
Submenu_Value=new_value;
@@ -2922,7 +2921,6 @@ static void Menu_Check_Buttons(void)
int upper_encoder_val;
int lower_encoder_val;
int encoder_change;
- int chan;
/* get keypad state */
Read_Keypad(&button_port_val,&upper_encoder_val,&lower_encoder_val);