From cd1b18c4e87c0de1a5396ca5554ac8a7890d49c9 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 31 Dec 1999 20:01:39 -0500 Subject: more elegant mode_name array handling --- menus.c | 142 +++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 74 insertions(+), 68 deletions(-) (limited to 'menus.c') 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])