summaryrefslogtreecommitdiff
path: root/menus.c
diff options
context:
space:
mode:
Diffstat (limited to 'menus.c')
-rw-r--r--menus.c142
1 files changed, 74 insertions, 68 deletions
diff --git a/menus.c b/menus.c
index 0946d11..4c47319 100644
--- a/menus.c
+++ b/menus.c
@@ -1601,268 +1601,270 @@ static void Submenu_Display(int change_selection)
if (Submenu_max_entry>0) {
- gchar* mode_name[Submenu_maximum_entries];
+ GPtrArray *gparray = g_ptr_array_new ();
int current_operating_mode = 0;
LCD_write(0,19,"Mode:");
for (i=0; i<=Submenu_max_entry; ++i) {
+ gchar *mode_name;
+
switch (Submenu_Structure[i]-channel) {
case mode_freq_int:
- mode_name[i] = g_strdup("Internal");
+ mode_name = g_strdup("Internal");
if (globals.ChannelState[channel].trigger_source==source_internal) {
current_operating_mode=i;
}
break;
case mode_freq_ext:
- mode_name[i] = g_strdup("External");
+ mode_name = g_strdup("External");
if (globals.ChannelState[channel].trigger_source==source_external) {
current_operating_mode=i;
}
break;
case mode_freq_man:
- mode_name[i] = g_strdup("Manual");
+ mode_name = g_strdup("Manual");
if (globals.ChannelState[channel].trigger_source==source_manual) {
current_operating_mode=i;
}
break;
case mode_freq_hold:
- mode_name[i] = g_strdup("Hold");
+ mode_name = g_strdup("Hold");
if (globals.ChannelState[channel].trigger_source==source_hold) {
current_operating_mode=i;
}
break;
case mode_func_sin:
- mode_name[i] = g_strdup("Sine");
+ mode_name = g_strdup("Sine");
if (globals.ChannelState[channel].func_mode==sin_mode_on) {
current_operating_mode=i;
}
break;
case mode_func_tri:
- mode_name[i] = g_strdup("Triangle");
+ mode_name = g_strdup("Triangle");
if (globals.ChannelState[channel].func_mode==tri_mode_on) {
current_operating_mode=i;
}
break;
case mode_func_squ:
- mode_name[i] = g_strdup("Square");
+ mode_name = g_strdup("Square");
if (globals.ChannelState[channel].func_mode==squ_mode_on) {
current_operating_mode=i;
}
break;
case mode_func_pulse:
- mode_name[i] = g_strdup("Pulse");
+ mode_name = g_strdup("Pulse");
if (globals.ChannelState[channel].func_mode==pulse_mode_on) {
current_operating_mode=i;
}
break;
case mode_func_amp:
- mode_name[i] = g_strdup("Amplify");
+ mode_name = g_strdup("Amplify");
if (globals.ChannelState[channel].func_mode==amp_mode_on) {
current_operating_mode=i;
}
break;
case mode_delay_norm:
- mode_name[i] = g_strdup("Normal");
+ mode_name = g_strdup("Normal");
if (globals.ChannelState[channel].double_pulse==double_off) {
current_operating_mode=i;
}
break;
case mode_delay_dbl:
- mode_name[i] = g_strdup("Double Pulse");
+ mode_name = g_strdup("Double Pulse");
if (globals.ChannelState[channel].double_pulse==double_on) {
current_operating_mode=i;
}
break;
case mode_pw_norm:
- mode_name[i] = g_strdup("Normal");
+ mode_name = 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:
- mode_name[i] = g_strdup("Duty Cycle");
+ mode_name = 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:
- mode_name[i] = g_strdup("PWin=PWout");
+ mode_name = 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:
- mode_name[i] = g_strdup("DC output");
+ mode_name = g_strdup("DC output");
if (globals.ChannelState[channel].func_mode==dc_mode_on) {
current_operating_mode=i;
}
break;
case mode_output_on:
- mode_name[i] = g_strdup("Output On");
+ mode_name = g_strdup("Output On");
if (globals.ChannelState[channel].output_state==output_on) {
current_operating_mode=i;
}
break;
case mode_output_off:
- mode_name[i] = g_strdup("Output Off");
+ mode_name = g_strdup("Output Off");
if (globals.ChannelState[channel].output_state==output_off) {
current_operating_mode=i;
}
break;
case mode_go_to_local:
- mode_name[i] = g_strdup("Go To Local");
+ mode_name = g_strdup("Go To Local");
break;
case mode_inv_no:
- mode_name[i] = g_strdup("NO (normal)");
+ mode_name = g_strdup("NO (normal)");
if (globals.ChannelState[channel].polarity==pol_norm) {
current_operating_mode=i;
}
break;
case mode_inv_yes:
- mode_name[i] = g_strdup("YES (inverted)");
+ mode_name = g_strdup("YES (inverted)");
if (globals.ChannelState[channel].polarity==pol_complement) {
current_operating_mode=i;
}
break;
case mode_gate_losync:
- mode_name[i] = g_strdup("Sync,TTL-low");
+ mode_name = 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:
- mode_name[i] = g_strdup("Sync,TTL-hi");
+ mode_name = 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:
- mode_name[i] = g_strdup("Async,TTL-low");
+ mode_name = 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:
- mode_name[i] = g_strdup("Async,TTL-hi");
+ mode_name = 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:
- mode_name[i] = g_strdup("GPIB address");
+ mode_name = g_strdup("GPIB address");
break;
case mode_rs232_settings:
- mode_name[i] = g_strdup("RS232 setup");
+ mode_name = g_strdup("RS232 setup");
break;
case mode_model_info:
- mode_name[i] = g_strdup("Model info");
+ mode_name = g_strdup("Model info");
break;
case mode_network:
- mode_name[i] = g_strdup("Network info");
+ mode_name = g_strdup("Network info");
break;
case mode_password:
- mode_name[i] = g_strdup("Pwd~default");
+ mode_name = g_strdup("Pwd~default");
break;
case mode_selfcal:
- mode_name[i] = g_strdup("Self Cal");
+ mode_name = g_strdup("Self Cal");
break;
case mode_exit_normal_submenu:
- mode_name[i] = g_strdup("Exit");
+ mode_name = g_strdup("Exit");
break;
case mode_load:
- mode_name[i] = g_strdup("Load Settings");
+ mode_name = g_strdup("Load Settings");
break;
case mode_save:
- mode_name[i] = g_strdup("Save Settings");
+ mode_name = g_strdup("Save Settings");
break;
case mode_load_0:
case mode_save_0:
- mode_name[i] = g_strdup("Storage 0");
+ mode_name = g_strdup("Storage 0");
break;
case mode_load_1:
case mode_save_1:
- mode_name[i] = g_strdup("Storage 1");
+ mode_name = g_strdup("Storage 1");
break;
case mode_load_2:
case mode_save_2:
- mode_name[i] = g_strdup("Storage 2");
+ mode_name = g_strdup("Storage 2");
break;
case mode_load_3:
case mode_save_3:
- mode_name[i] = g_strdup("Storage 3");
+ mode_name = g_strdup("Storage 3");
break;
case mode_change_rs232:
- mode_name[i] = g_strdup("Change values");
+ mode_name = g_strdup("Change values");
break;
case mode_default_rs232:
- mode_name[i] = g_strdup("Default");
+ mode_name = g_strdup("Default");
break;
case mode_exit_rs232:
- mode_name[i] = g_strdup("Exit");
+ mode_name = g_strdup("Exit");
break;
case mode_zout_max:
- mode_name[i] = g_strdup_printf ("Zout = %d\xf4", globals.Flash.zout_max[channel]);
+ mode_name = 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:
- mode_name[i] = g_strdup_printf ("Zout = %d\xf4", globals.Flash.zout_min[channel]);
+ mode_name = 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:
- mode_name[i] = g_strdup("TTL levels");
+ mode_name = g_strdup("TTL levels");
if (globals.ChannelState[channel].logic_level==logic_ttl) {
current_operating_mode=i;
}
break;
case mode_logic_ecl:
- mode_name[i] = g_strdup("ECL levels");
+ mode_name = g_strdup("ECL levels");
if (globals.ChannelState[channel].logic_level==logic_ecl) {
current_operating_mode=i;
}
break;
case mode_amp_normal:
- mode_name[i] = g_strdup("Normal");
+ mode_name = g_strdup("Normal");
if (globals.ChannelState[channel].amp_mode==amp_mode_normal) {
current_operating_mode=i;
}
break;
case mode_amp_ea:
- mode_name[i] = g_strdup("Ext Control");
+ mode_name = g_strdup("Ext Control");
if (globals.ChannelState[channel].amp_mode==amp_mode_ea) {
current_operating_mode=i;
}
break;
case mode_amp_amplify:
- mode_name[i] = g_strdup("Ext Amplify");
+ mode_name = g_strdup("Ext Amplify");
if (globals.ChannelState[channel].amp_mode==amp_mode_amplify) {
current_operating_mode=i;
}
break;
case mode_os_normal:
- mode_name[i] = g_strdup("Normal");
+ mode_name = g_strdup("Normal");
if (globals.ChannelState[channel].os_mode==os_mode_normal) {
current_operating_mode=i;
}
break;
case mode_os_eo:
- mode_name[i] = g_strdup("Ext Control");
+ mode_name = 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",mode_name[i],YES,LCD_col_width);
+ String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","V",&mode_name,YES,LCD_col_width);
} else {
- String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","A",mode_name[i],YES,LCD_col_width);
+ String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","A",&mode_name,YES,LCD_col_width);
}
if (fabs(globals.ChannelState[channel].amplitude-globals.Flash.min_ampl[channel])<globals.Flash.ampl_zero_equiv[channel]) {
@@ -1871,9 +1873,9 @@ static void Submenu_Display(int change_selection)
break;
case mode_amp_max:
if (globals.Flash.voltage_enabled[channel]) {
- String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","V",mode_name[i],YES,LCD_col_width);
+ String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","V",&mode_name,YES,LCD_col_width);
} else {
- String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","A",mode_name[i],YES,LCD_col_width);
+ String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","A",&mode_name,YES,LCD_col_width);
}
if (fabs(globals.ChannelState[channel].amplitude-globals.Flash.max_ampl[channel])<globals.Flash.ampl_zero_equiv[channel]) {
@@ -1881,67 +1883,72 @@ static void Submenu_Display(int change_selection)
}
break;
case mode_1200:
- mode_name[i] = g_strdup("1200 baud");
+ mode_name = g_strdup("1200 baud");
if (globals.Flash.baud==1200) {
current_operating_mode=i;
}
break;
case mode_2400:
- mode_name[i] = g_strdup("2400 baud");
+ mode_name = g_strdup("2400 baud");
if (globals.Flash.baud==2400) {
current_operating_mode=i;
}
break;
case mode_4800:
- mode_name[i] = g_strdup("4800 baud");
+ mode_name = g_strdup("4800 baud");
if (globals.Flash.baud==4800) {
current_operating_mode=i;
}
break;
case mode_9600:
- mode_name[i] = g_strdup("9600 baud");
+ mode_name = g_strdup("9600 baud");
if (globals.Flash.baud==9600) {
current_operating_mode=i;
}
break;
case mode_19200:
- mode_name[i] = g_strdup("19200 baud");
+ mode_name = g_strdup("19200 baud");
if (globals.Flash.baud==19200) {
current_operating_mode=i;
}
break;
case mode_38400:
- mode_name[i] = g_strdup("38400 baud");
+ mode_name = g_strdup("38400 baud");
if (globals.Flash.baud==38400) {
current_operating_mode=i;
}
break;
case mode_57600:
- mode_name[i] = g_strdup("57600 baud");
+ mode_name = g_strdup("57600 baud");
if (globals.Flash.baud==57600) {
current_operating_mode=i;
}
break;
case mode_115200:
- mode_name[i] = g_strdup("115200 baud");
+ mode_name = g_strdup("115200 baud");
if (globals.Flash.baud==115200) {
current_operating_mode=i;
}
break;
case mode_hand_hard:
- mode_name[i] = g_strdup("Hardware");
+ mode_name = g_strdup("Hardware");
if (globals.Flash.hardhand) {
current_operating_mode=i;
}
break;
case mode_hand_off:
- mode_name[i] = g_strdup("None");
+ mode_name = g_strdup("None");
if (!globals.Flash.hardhand) {
current_operating_mode=i;
}
break;
+ default:
+ mode_name = g_strdup("??");
+ break;
}
+
+ g_ptr_array_add (gparray, (gpointer) mode_name);
}
/* If change_selection==NO, the submenu is being drawn from scratch.
@@ -1963,7 +1970,7 @@ static void Submenu_Display(int change_selection)
}
for (i=base_entry; ( (i<=Submenu_max_entry) && (i< (base_entry+4)) ); ++i) {
- LCD_write_padded_to_end_of_line(i-base_entry, 26, mode_name[i]);
+ LCD_write_padded_to_end_of_line(i-base_entry, 26, g_ptr_array_index (gparray, i));
}
LCD_write(Submenu_Selected_Item-base_entry,25,"~");
@@ -1977,9 +1984,8 @@ static void Submenu_Display(int change_selection)
LCD_write(3,39,"\x3");
}
- for (i=0; i<Submenu_maximum_entries; i++) {
- g_free (mode_name[i]);
- }
+ g_ptr_array_foreach (gparray, (GFunc) g_free, NULL);
+ g_ptr_array_free (gparray, TRUE);
}
}