summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lcd.c6
-rw-r--r--lcd.h1
-rw-r--r--menus.c169
3 files changed, 80 insertions, 96 deletions
diff --git a/lcd.c b/lcd.c
index 24b8dc1..d98c0b0 100644
--- a/lcd.c
+++ b/lcd.c
@@ -210,6 +210,12 @@ void LCD_write_padded_spaces(int row, int col, char *LCD_string, int width)
}
+void LCD_write_padded_to_end_of_line(int row, int col, char *LCD_string)
+{
+ LCD_write_padded_spaces (row, col, LCD_string, LCD_cols - col - strlen (LCD_string));
+}
+
+
static void LCD_make_custom_chars()
{
/* define custom LCD characters 2 and 3 (up arrow and down arrow).*/
diff --git a/lcd.h b/lcd.h
index a88953e..5b7dbc7 100644
--- a/lcd.h
+++ b/lcd.h
@@ -13,4 +13,5 @@ void LCD_display_extended_message(char *response, gboolean show_change_message,
void LCD_clear();
void LCD_write(int row, int col, char *LCD_string);
void LCD_write_padded_spaces(int row, int col, char *LCD_string, int width);
+void LCD_write_padded_to_end_of_line(int row, int col, char *LCD_string);
void LCD_initialize(void);
diff --git a/menus.c b/menus.c
index f50481a..0946d11 100644
--- a/menus.c
+++ b/menus.c
@@ -1600,9 +1600,9 @@ static void Submenu_Display(int change_selection)
LCD_write(3,0,Press_Change_Message);
if (Submenu_max_entry>0) {
- gchar *tmp_str = NULL; //FIXME
- char mode_name[Submenu_maximum_entries][LCD_col_width+1];
+ gchar* mode_name[Submenu_maximum_entries];
+
int current_operating_mode = 0;
LCD_write(0,19,"Mode:");
@@ -1610,351 +1610,333 @@ static void Submenu_Display(int change_selection)
for (i=0; i<=Submenu_max_entry; ++i) {
switch (Submenu_Structure[i]-channel) {
case mode_freq_int:
- strcpy(mode_name[i],"Internal");
+ mode_name[i] = g_strdup("Internal");
if (globals.ChannelState[channel].trigger_source==source_internal) {
current_operating_mode=i;
}
break;
case mode_freq_ext:
- strcpy(mode_name[i],"External");
+ mode_name[i] = g_strdup("External");
if (globals.ChannelState[channel].trigger_source==source_external) {
current_operating_mode=i;
}
break;
case mode_freq_man:
- strcpy(mode_name[i],"Manual");
+ mode_name[i] = g_strdup("Manual");
if (globals.ChannelState[channel].trigger_source==source_manual) {
current_operating_mode=i;
}
break;
case mode_freq_hold:
- strcpy(mode_name[i],"Hold");
+ mode_name[i] = g_strdup("Hold");
if (globals.ChannelState[channel].trigger_source==source_hold) {
current_operating_mode=i;
}
break;
case mode_func_sin:
- strcpy(mode_name[i],"Sine");
+ mode_name[i] = g_strdup("Sine");
if (globals.ChannelState[channel].func_mode==sin_mode_on) {
current_operating_mode=i;
}
break;
case mode_func_tri:
- strcpy(mode_name[i],"Triangle");
+ mode_name[i] = g_strdup("Triangle");
if (globals.ChannelState[channel].func_mode==tri_mode_on) {
current_operating_mode=i;
}
break;
case mode_func_squ:
- strcpy(mode_name[i],"Square");
+ mode_name[i] = g_strdup("Square");
if (globals.ChannelState[channel].func_mode==squ_mode_on) {
current_operating_mode=i;
}
break;
case mode_func_pulse:
- strcpy(mode_name[i],"Pulse");
+ mode_name[i] = g_strdup("Pulse");
if (globals.ChannelState[channel].func_mode==pulse_mode_on) {
current_operating_mode=i;
}
break;
case mode_func_amp:
- strcpy(mode_name[i],"Amplify");
+ mode_name[i] = g_strdup("Amplify");
if (globals.ChannelState[channel].func_mode==amp_mode_on) {
current_operating_mode=i;
}
break;
case mode_delay_norm:
- strcpy(mode_name[i],"Normal");
+ mode_name[i] = g_strdup("Normal");
if (globals.ChannelState[channel].double_pulse==double_off) {
current_operating_mode=i;
}
break;
case mode_delay_dbl:
- strcpy(mode_name[i],"Double Pulse");
+ mode_name[i] = g_strdup("Double Pulse");
if (globals.ChannelState[channel].double_pulse==double_on) {
current_operating_mode=i;
}
break;
case mode_pw_norm:
- strcpy(mode_name[i],"Normal");
+ mode_name[i] = g_strdup("Normal");
if (globals.ChannelState[channel].func_mode==pulse_mode_on
&& globals.ChannelState[channel].hold_setting==hold_width && globals.ChannelState[channel].ab_mode==pw_normal) {
current_operating_mode=i;
}
break;
case mode_pw_duty:
- strcpy(mode_name[i],"Duty Cycle");
+ mode_name[i] = g_strdup("Duty Cycle");
if (globals.ChannelState[channel].func_mode==pulse_mode_on
&& globals.ChannelState[channel].hold_setting==hold_duty && globals.ChannelState[channel].ab_mode==pw_normal) {
current_operating_mode=i;
}
break;
case mode_pw_inout:
- strcpy(mode_name[i],"PWin=PWout");
+ mode_name[i] = g_strdup("PWin=PWout");
if (globals.ChannelState[channel].func_mode==pulse_mode_on && globals.ChannelState[channel].ab_mode==pw_in_out) {
current_operating_mode=i;
}
break;
case mode_pw_dc:
- strcpy(mode_name[i],"DC output");
+ mode_name[i] = g_strdup("DC output");
if (globals.ChannelState[channel].func_mode==dc_mode_on) {
current_operating_mode=i;
}
break;
case mode_output_on:
- strcpy(mode_name[i],"Output On");
+ mode_name[i] = g_strdup("Output On");
if (globals.ChannelState[channel].output_state==output_on) {
current_operating_mode=i;
}
break;
case mode_output_off:
- strcpy(mode_name[i],"Output Off");
+ mode_name[i] = g_strdup("Output Off");
if (globals.ChannelState[channel].output_state==output_off) {
current_operating_mode=i;
}
break;
case mode_go_to_local:
- strcpy(mode_name[i],"Go To Local");
+ mode_name[i] = g_strdup("Go To Local");
break;
case mode_inv_no:
- strcpy(mode_name[i],"NO (normal)");
+ mode_name[i] = g_strdup("NO (normal)");
if (globals.ChannelState[channel].polarity==pol_norm) {
current_operating_mode=i;
}
break;
case mode_inv_yes:
- strcpy(mode_name[i],"YES (inverted)");
+ mode_name[i] = g_strdup("YES (inverted)");
if (globals.ChannelState[channel].polarity==pol_complement) {
current_operating_mode=i;
}
break;
case mode_gate_losync:
- strcpy(mode_name[i],"Sync,TTL-low");
+ mode_name[i] = g_strdup("Sync,TTL-low");
if (globals.ChannelState[channel].gate_type==gate_sync && globals.ChannelState[channel].gate_level==gate_low) {
current_operating_mode=i;
}
break;
case mode_gate_hisync:
- strcpy(mode_name[i],"Sync,TTL-hi");
+ mode_name[i] = g_strdup("Sync,TTL-hi");
if (globals.ChannelState[channel].gate_type==gate_sync && globals.ChannelState[channel].gate_level==gate_high) {
current_operating_mode=i;
}
break;
case mode_gate_loasync:
- strcpy(mode_name[i],"Async,TTL-low");
+ mode_name[i] = g_strdup("Async,TTL-low");
if (globals.ChannelState[channel].gate_type==gate_async && globals.ChannelState[channel].gate_level==gate_low) {
current_operating_mode=i;
}
break;
case mode_gate_hiasync:
- strcpy(mode_name[i],"Async,TTL-hi");
+ mode_name[i] = g_strdup("Async,TTL-hi");
if (globals.ChannelState[channel].gate_type==gate_async && globals.ChannelState[channel].gate_level==gate_high) {
current_operating_mode=i;
}
break;
case mode_gpib_address:
- strcpy(mode_name[i],"GPIB address");
+ mode_name[i] = g_strdup("GPIB address");
break;
case mode_rs232_settings:
- strcpy(mode_name[i],"RS232 setup");
+ mode_name[i] = g_strdup("RS232 setup");
break;
case mode_model_info:
- strcpy(mode_name[i],"Model info");
+ mode_name[i] = g_strdup("Model info");
break;
case mode_network:
- strcpy(mode_name[i],"Network info");
+ mode_name[i] = g_strdup("Network info");
break;
case mode_password:
- strcpy(mode_name[i],"Pwd~default");
+ mode_name[i] = g_strdup("Pwd~default");
break;
case mode_selfcal:
- strcpy(mode_name[i],"Self Cal");
+ mode_name[i] = g_strdup("Self Cal");
break;
case mode_exit_normal_submenu:
- strcpy(mode_name[i],"Exit");
+ mode_name[i] = g_strdup("Exit");
break;
case mode_load:
- strcpy(mode_name[i],"Load Settings");
+ mode_name[i] = g_strdup("Load Settings");
break;
case mode_save:
- strcpy(mode_name[i],"Save Settings");
+ mode_name[i] = g_strdup("Save Settings");
break;
case mode_load_0:
- strcpy(mode_name[i],"Storage 0");
+ case mode_save_0:
+ mode_name[i] = g_strdup("Storage 0");
break;
case mode_load_1:
- strcpy(mode_name[i],"Storage 1");
+ case mode_save_1:
+ mode_name[i] = g_strdup("Storage 1");
break;
case mode_load_2:
- strcpy(mode_name[i],"Storage 2");
+ case mode_save_2:
+ mode_name[i] = g_strdup("Storage 2");
break;
case mode_load_3:
- strcpy(mode_name[i],"Storage 3");
- break;
- case mode_save_0:
- strcpy(mode_name[i],"Storage 0");
- break;
- case mode_save_1:
- strcpy(mode_name[i],"Storage 1");
- break;
- case mode_save_2:
- strcpy(mode_name[i],"Storage 2");
- break;
- case mode_save_3:
- strcpy(mode_name[i],"Storage 3");
+ case mode_save_3:
+ mode_name[i] = g_strdup("Storage 3");
break;
case mode_change_rs232:
- strcpy(mode_name[i],"Change values");
+ mode_name[i] = g_strdup("Change values");
break;
case mode_default_rs232:
- strcpy(mode_name[i],"Default");
+ mode_name[i] = g_strdup("Default");
break;
case mode_exit_rs232:
- strcpy(mode_name[i],"Exit");
+ mode_name[i] = g_strdup("Exit");
break;
case mode_zout_max:
- strcpy(mode_name[i],"Zout = ");
- gchar *temp1 = g_strdup_printf ("%d\xf4", globals.Flash.zout_max[channel]);
- strcat(mode_name[i],temp1);
- g_free (temp1);
+ mode_name[i] = g_strdup_printf ("Zout = %d\xf4", globals.Flash.zout_max[channel]);
if (globals.ChannelState[channel].zout==globals.Flash.zout_max[channel]) {
current_operating_mode=i;
}
break;
case mode_zout_min:
- strcpy(mode_name[i],"Zout = ");
- gchar *temp2 = g_strdup_printf ("%d\xf4", globals.Flash.zout_min[channel]);
- strcat(mode_name[i],temp2);
- g_free (temp2);
+ mode_name[i] = g_strdup_printf ("Zout = %d\xf4", globals.Flash.zout_min[channel]);
if (globals.ChannelState[channel].zout==globals.Flash.zout_min[channel]) {
current_operating_mode=i;
}
break;
case mode_logic_ttl:
- strcpy(mode_name[i],"TTL levels");
+ mode_name[i] = g_strdup("TTL levels");
if (globals.ChannelState[channel].logic_level==logic_ttl) {
current_operating_mode=i;
}
break;
case mode_logic_ecl:
- strcpy(mode_name[i],"ECL levels");
+ mode_name[i] = g_strdup("ECL levels");
if (globals.ChannelState[channel].logic_level==logic_ecl) {
current_operating_mode=i;
}
break;
case mode_amp_normal:
- strcpy(mode_name[i],"Normal");
+ mode_name[i] = g_strdup("Normal");
if (globals.ChannelState[channel].amp_mode==amp_mode_normal) {
current_operating_mode=i;
}
break;
case mode_amp_ea:
- strcpy(mode_name[i],"Ext Control");
+ mode_name[i] = g_strdup("Ext Control");
if (globals.ChannelState[channel].amp_mode==amp_mode_ea) {
current_operating_mode=i;
}
break;
case mode_amp_amplify:
- strcpy(mode_name[i],"Ext Amplify");
+ mode_name[i] = g_strdup("Ext Amplify");
if (globals.ChannelState[channel].amp_mode==amp_mode_amplify) {
current_operating_mode=i;
}
break;
case mode_os_normal:
- strcpy(mode_name[i],"Normal");
+ mode_name[i] = g_strdup("Normal");
if (globals.ChannelState[channel].os_mode==os_mode_normal) {
current_operating_mode=i;
}
break;
case mode_os_eo:
- strcpy(mode_name[i],"Ext Control");
+ mode_name[i] = g_strdup("Ext Control");
if (globals.ChannelState[channel].os_mode==os_mode_eo) {
current_operating_mode=i;
}
break;
case mode_amp_min:
if (globals.Flash.voltage_enabled[channel]) {
- String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","V",&tmp_str,YES,LCD_col_width);
+ String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","V",mode_name[i],YES,LCD_col_width);
} else {
- String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","A",&tmp_str,YES,LCD_col_width);
+ String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","A",mode_name[i],YES,LCD_col_width);
}
- strcpy (mode_name[i], tmp_str); // FIXME
-
if (fabs(globals.ChannelState[channel].amplitude-globals.Flash.min_ampl[channel])<globals.Flash.ampl_zero_equiv[channel]) {
current_operating_mode=i;
}
break;
case mode_amp_max:
if (globals.Flash.voltage_enabled[channel]) {
- String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","V",&tmp_str,YES,LCD_col_width);
+ String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","V",mode_name[i],YES,LCD_col_width);
} else {
- String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","A",&tmp_str,YES,LCD_col_width);
+ String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","A",mode_name[i],YES,LCD_col_width);
}
- strcpy (mode_name[i], tmp_str); // FIXME
-
if (fabs(globals.ChannelState[channel].amplitude-globals.Flash.max_ampl[channel])<globals.Flash.ampl_zero_equiv[channel]) {
current_operating_mode=i;
}
break;
case mode_1200:
- strcpy(mode_name[i],"1200 baud");
+ mode_name[i] = g_strdup("1200 baud");
if (globals.Flash.baud==1200) {
current_operating_mode=i;
}
break;
case mode_2400:
- strcpy(mode_name[i],"2400 baud");
+ mode_name[i] = g_strdup("2400 baud");
if (globals.Flash.baud==2400) {
current_operating_mode=i;
}
break;
case mode_4800:
- strcpy(mode_name[i],"4800 baud");
+ mode_name[i] = g_strdup("4800 baud");
if (globals.Flash.baud==4800) {
current_operating_mode=i;
}
break;
case mode_9600:
- strcpy(mode_name[i],"9600 baud");
+ mode_name[i] = g_strdup("9600 baud");
if (globals.Flash.baud==9600) {
current_operating_mode=i;
}
break;
case mode_19200:
- strcpy(mode_name[i],"19200 baud");
+ mode_name[i] = g_strdup("19200 baud");
if (globals.Flash.baud==19200) {
current_operating_mode=i;
}
break;
case mode_38400:
- strcpy(mode_name[i],"38400 baud");
+ mode_name[i] = g_strdup("38400 baud");
if (globals.Flash.baud==38400) {
current_operating_mode=i;
}
break;
case mode_57600:
- strcpy(mode_name[i],"57600 baud");
+ mode_name[i] = g_strdup("57600 baud");
if (globals.Flash.baud==57600) {
current_operating_mode=i;
}
break;
case mode_115200:
- strcpy(mode_name[i],"115200 baud");
+ mode_name[i] = g_strdup("115200 baud");
if (globals.Flash.baud==115200) {
current_operating_mode=i;
}
break;
case mode_hand_hard:
- strcpy(mode_name[i],"Hardware");
+ mode_name[i] = g_strdup("Hardware");
if (globals.Flash.hardhand) {
current_operating_mode=i;
}
break;
case mode_hand_off:
- strcpy(mode_name[i],"None");
+ mode_name[i] = g_strdup("None");
if (!globals.Flash.hardhand) {
current_operating_mode=i;
}
@@ -1981,14 +1963,7 @@ static void Submenu_Display(int change_selection)
}
for (i=base_entry; ( (i<=Submenu_max_entry) && (i< (base_entry+4)) ); ++i) {
- int add_spaces, j;
-
- add_spaces=LCD_col_width-strlen(mode_name[i]);
-
- for (j=0; j<add_spaces; j++) {
- strcat(mode_name[i]," ");
- }
- LCD_write(i-base_entry,26,mode_name[i]);
+ LCD_write_padded_to_end_of_line(i-base_entry, 26, mode_name[i]);
}
LCD_write(Submenu_Selected_Item-base_entry,25,"~");
@@ -2002,7 +1977,9 @@ static void Submenu_Display(int change_selection)
LCD_write(3,39,"\x3");
}
- g_free (tmp_str);
+ for (i=0; i<Submenu_maximum_entries; i++) {
+ g_free (mode_name[i]);
+ }
}
}