summaryrefslogtreecommitdiff
path: root/menus.c
diff options
context:
space:
mode:
Diffstat (limited to 'menus.c')
-rw-r--r--menus.c946
1 files changed, 415 insertions, 531 deletions
diff --git a/menus.c b/menus.c
index 874f120..105b78d 100644
--- a/menus.c
+++ b/menus.c
@@ -4,7 +4,6 @@
#include "error_utils.h"
#include "string_utils.h"
#include "device-functions.h"
-#include "dummy_functions.h"
#include "version.h"
#include "flash.h"
#include "nicutils.h"
@@ -30,13 +29,13 @@
/* To add a new menu: 1. add the menu name directly below */
/* 2. add the menu mode list choices directly below */
-/* 3. if it is to be shown on the main menu, update Menu_Update_Display(void); */
+/* 3. if it is to be shown on the main menu, update Show_Main_Menu(void); */
/* 4. update Submenu_Display(void), which builds the submenu */
/* 5. update Submenu_Implement_Changes(void), to do the actual functions */
/* KEY SUBROUTINES: */
-/* Menu_Update_Display(void); - displays the main menu */
+/* Show_Main_Menu(void); - displays the main menu */
/* Menu_Check_Buttons(void); - determines what to show based on button status */
/* (void); - clears any button presses */
/* Menu_Move_Pointer(int move_amount); - moves the pointer up and down the main menu */
@@ -129,8 +128,12 @@
#define mode_network 7200
#define mode_password 7300
#define mode_selfcal 7400
+#define mode_19200 7500
+#define mode_38400 7600
+#define mode_57600 7700
+#define mode_115200 7800
-#define Submenu_maximum_entries 8 /* used to be 4, before scrolling lists were added */
+#define Submenu_maximum_entries 10 /* used to be 4, before scrolling lists were added */
/* what parameter to adjust */
#define Show_frequency 0
@@ -154,9 +157,6 @@
#define Show_avrq_ampl 1900
-// FIXME - eliminate fixed width variables
-// FIXME - tidy up menu global vars
-
/* KEY MENU-JUGGLING VARIABLES - controlling what is actually shown on the display */
int menu_cursor_pos;
@@ -198,6 +198,7 @@ float Submenu_Value; /* actual value of the shown parameter (like frequency)
int Submenu_extra_fine; /* is the extra-fine mode on? */
+static void update_remote_mode ();
static int Menu_Is_Item_Visible(int LCD_entry);
static void Menu_Move_Pointer(int move_amount);
static void Display_Number_on_LCD(int Is_Item_Visible,int LCD_row,int LCD_col,char *start_string,int Show_What, int significant_digits, int width_of_column);
@@ -212,10 +213,13 @@ static void Nonstd_menu_network(void);
static void Read_Keypad(int *button_port_val, int *upper_encoder_val, int *lower_encoder_val);
-void Menu_Refresh()
+#define GPIB_REMOTE_AND_UNLOCKED (globals.Remote.gpib_remote && !globals.Remote.gpib_lock)
+#define GPIB_REMOTE_AND_LOCKED (globals.Remote.gpib_remote && globals.Remote.gpib_lock)
+
+
+static void update_remote_mode ()
{
- globals.Changes.update_whole_main_menu = YES;
- Menu_Update_Display();
+ GPIB_check_remote_status (&globals.Remote.gpib_remote, &globals.Remote.gpib_lock);
}
@@ -225,11 +229,27 @@ static int Menu_Is_Item_Visible(int LCD_entry)
}
-void Menu_Update_Display(void)
+
+void Update_Main_Menu_If_Visible(void)
+{
+ if ( (globals.MenuStatus.Type_Of_Menu == Main_Menu_On) &&
+ (globals.MenuStatus.Error_Screen == NO) &&
+ (globals.MenuStatus.Nonstd_Display == NO)) {
+ Show_Main_Menu();
+ }
+}
+
+
+void Show_Main_Menu(void)
{
- char a_string[2*LCD_col_width];
- char b_string[2*LCD_col_width];
+ if (!globals.Sys.startup_complete) return;
+
+ static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+ g_static_mutex_lock (&mutex); // can be triggered simultaneously by local or remote users
+
+ GString *menu_string = g_string_new ("");
+
int LCD_entry, LCD_row, LCD_col;
int sig_dig; /* number of significant digits to display */
int i;
@@ -241,7 +261,6 @@ void Menu_Update_Display(void)
(globals.MenuStatus.Error_Screen == YES) ||
(globals.MenuStatus.Nonstd_Display == YES) ) {
LCD_clear();
- globals.Changes.update_whole_main_menu = TRUE;
}
LCD_entry=-1;
@@ -275,9 +294,6 @@ void Menu_Update_Display(void)
for (chan=0; chan<(globals.Flash.ChanKey_frequency?globals.Flash.channels:1); ++chan) {
if (globals.ChannelState[chan].func_mode!=amp_mode_on) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_freq+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_freq+chan; /* keep track of what is displayed */
LCD_row=LCD_entry % LCD_rows; /* find next available row */
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1; /* find next available column */
@@ -285,27 +301,27 @@ void Menu_Update_Display(void)
show_item=Show_No_Number;
if (globals.ChannelState[chan].trigger_source==source_internal) {
- strcpy(a_string,"INT");
+ menu_string = g_string_append (menu_string, "INT");
show_item=Show_frequency+chan;
} else if (globals.ChannelState[chan].trigger_source==source_external) {
- strcpy(a_string,"EXT TRIG");
+ menu_string = g_string_append (menu_string, "EXT TRIG");
} else if (globals.ChannelState[chan].trigger_source==source_manual) {
- strcpy(a_string,"MAN TRIG");
+ menu_string = g_string_append (menu_string, "MAN TRIG");
} else if (globals.ChannelState[chan].trigger_source==source_hold) {
- strcpy(a_string,"HOLD TRIG");
+ menu_string = g_string_append (menu_string, "HOLD TRIG");
} else if (globals.ChannelState[chan].trigger_source==source_immediate) {
- strcpy(a_string,"IMMED TRIG");
+ menu_string = g_string_append (menu_string, "IMMED TRIG");
}
if (globals.Flash.ChanKey_frequency) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
if (globals.ChannelState[chan].trigger_source==source_internal) {
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
}
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_freq) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig,LCD_col_width-1);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -314,9 +330,6 @@ void Menu_Update_Display(void)
for (chan=0; chan<(globals.Flash.ChanKey_func_mode?globals.Flash.channels:1); ++chan) {
if (globals.Flash.is_func_gen[chan]) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_func+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_func+chan; /* keep track of what is displayed */
LCD_row=LCD_entry % LCD_rows; /* find next available row */
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1; /* find next available column */
@@ -324,23 +337,23 @@ void Menu_Update_Display(void)
show_item=Show_No_Number;
if (globals.ChannelState[chan].func_mode==pulse_mode_on) {
- strcpy(a_string,"SHAPE:PULSE");
+ menu_string = g_string_append (menu_string, "SHAPE:PULSE");
} else if (globals.ChannelState[chan].func_mode==sin_mode_on) {
- strcpy(a_string,"SHAPE:SINE");
+ menu_string = g_string_append (menu_string, "SHAPE:SINE");
} else if (globals.ChannelState[chan].func_mode==tri_mode_on) {
- strcpy(a_string,"SHAPE:TRI");
+ menu_string = g_string_append (menu_string, "SHAPE:TRI");
} else if (globals.ChannelState[chan].func_mode==squ_mode_on) {
- strcpy(a_string,"SHAPE:SQU");
+ menu_string = g_string_append (menu_string, "SHAPE:SQU");
} else if (globals.ChannelState[chan].func_mode==amp_mode_on) {
- strcpy(a_string,"SHAPE:AMP");
+ menu_string = g_string_append (menu_string, "SHAPE:AMP");
}
if (globals.Flash.ChanKey_func_mode) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_func) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig,LCD_col_width-1);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -353,25 +366,22 @@ void Menu_Update_Display(void)
|| (globals.ChannelState[chan].func_mode==dc_mode_on))
) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_delay+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_delay+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
if (globals.ChannelState[chan].double_pulse==double_off) {
- strcpy(a_string,"DLY");
+ menu_string = g_string_append (menu_string, "DLY");
} else {
- strcpy(a_string,"DBL");
+ menu_string = g_string_append (menu_string, "DBL");
}
if (globals.Flash.ChanKey_delay) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_delay) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,Show_delay+chan,sig_dig-globals.Flash.ChanKey_delay,LCD_col_width-1);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,Show_delay+chan,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
@@ -385,9 +395,6 @@ void Menu_Update_Display(void)
) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_pw+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_pw+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
@@ -398,38 +405,35 @@ void Menu_Update_Display(void)
if (globals.ChannelState[chan].ab_mode==pw_normal) {
if (globals.ChannelState[chan].hold_setting==hold_width) {
show_item=Show_pw+chan;
- strcpy(a_string,"PW");
+ menu_string = g_string_append (menu_string, "PW");
if (globals.Flash.ChanKey_pw) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
} else {
show_item=Show_duty_cycle+chan;
- strcpy(a_string,"DUTY");
+ menu_string = g_string_append (menu_string, "DUTY");
if (globals.Flash.ChanKey_pw) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
}
} else {
- strcpy(a_string,"PW");
+ menu_string = g_string_append (menu_string, "PW");
if (globals.Flash.ChanKey_pw) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string," IN=OUT");
+ menu_string = g_string_append (menu_string, " IN=OUT");
}
} else {
- strcpy(a_string,"PW");
+ menu_string = g_string_append (menu_string, "PW");
if (globals.Flash.ChanKey_pw) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,": DC");
+ menu_string = g_string_append (menu_string, ": DC");
}
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_pw) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig-globals.Flash.ChanKey_pw,LCD_col_width-1);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -444,21 +448,18 @@ void Menu_Update_Display(void)
) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_rise_time+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_rise_time+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
show_item=Show_rise_time+chan;
- strcpy(a_string,"TR");
+ menu_string = g_string_append (menu_string, "TR");
if (globals.Flash.ChanKey_rise_time) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_rise_time) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig-globals.Flash.ChanKey_rise_time,LCD_col_width-1);
+ menu_string = g_string_append (menu_string, ":");
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -468,9 +469,6 @@ void Menu_Update_Display(void)
for (chan=0; chan<(globals.Flash.ChanKey_amplitude?globals.Flash.channels:1); ++chan) {
if ((globals.Flash.voltage_enabled[chan] || globals.Flash.current_enabled[chan]) ) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_amp+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_amp+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
@@ -479,28 +477,26 @@ void Menu_Update_Display(void)
if (globals.ChannelState[chan].amp_mode==amp_mode_normal) {
show_item=Show_amplitude+chan;
- strcpy(a_string,"AMP");
+ menu_string = g_string_append (menu_string, "AMP");
if (globals.Flash.ChanKey_amplitude) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
} else if (globals.ChannelState[chan].amp_mode==amp_mode_ea) {
- strcpy(a_string,"AMP");
+ menu_string = g_string_append (menu_string, "AMP");
if (globals.Flash.ChanKey_amplitude) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":EXT");
+ menu_string = g_string_append (menu_string, ":EXT");
} else if (globals.ChannelState[chan].amp_mode==amp_mode_amplify) {
- strcpy(a_string,"AMP");
+ menu_string = g_string_append (menu_string, "AMP");
if (globals.Flash.ChanKey_amplitude) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":AMPLFY");
+ menu_string = g_string_append (menu_string, ":AMPLFY");
}
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_amp) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig-globals.Flash.ChanKey_amplitude,LCD_col_width-1);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -510,19 +506,16 @@ void Menu_Update_Display(void)
if (globals.Flash.enable_avrq_extra_ampls) {
for (chan=2; chan<5; ++chan) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_avrq+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_avrq+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
show_item=Show_avrq_ampl+chan;
- strcpy(a_string,"AMP");
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
- strcat(a_string,":");
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_amp) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig-1,LCD_col_width-1);
+ menu_string = g_string_append (menu_string, "AMP");
+ g_string_append_printf (menu_string, "%d", chan+1);
+ menu_string = g_string_append (menu_string, ":");
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -532,21 +525,18 @@ void Menu_Update_Display(void)
if (globals.Flash.soft_current_limit_enabled[chan]) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_soft_current_limit+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_soft_current_limit+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
show_item=Show_soft_current_limit+chan;
- strcpy(a_string,"LIM");
+ menu_string = g_string_append (menu_string, "LIM");
if (globals.Flash.ChanKey_current_limit) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_soft_current_limit) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig-globals.Flash.ChanKey_current_limit,LCD_col_width-1);
+ menu_string = g_string_append (menu_string, ":");
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -558,21 +548,18 @@ void Menu_Update_Display(void)
if ( globals.Flash.curr_slew[chan] ) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_slew+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_slew+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
show_item=Show_slew+chan;
- strcpy(a_string,"SL");
+ menu_string = g_string_append (menu_string, "SL");
if (globals.Flash.ChanKey_slew) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_slew) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig-globals.Flash.ChanKey_slew,LCD_col_width-1);
+ menu_string = g_string_append (menu_string, ":");
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -583,21 +570,18 @@ void Menu_Update_Display(void)
if (globals.Flash.max_burst_count[chan]>1) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_burst_count+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_burst_count+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
show_item=Show_Burst_Count+chan;
- strcpy(a_string,"N");
+ menu_string = g_string_append (menu_string, "N");
if (globals.Flash.ChanKey_Burst_Count) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_burst_count) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,0,LCD_col_width-1);
+ menu_string = g_string_append (menu_string, ":");
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,0,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -609,21 +593,18 @@ void Menu_Update_Display(void)
if ((globals.Flash.max_burst_count[chan]>1) && !globals.Flash.burst_func[chan]) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_burst_time+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_burst_time+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
show_item=Show_Burst_Time+chan;
- strcpy(a_string,"BUR");
+ menu_string = g_string_append (menu_string, "BUR");
if (globals.Flash.ChanKey_Burst_Time) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_burst_time) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig-globals.Flash.ChanKey_Burst_Time,LCD_col_width-1);
+ menu_string = g_string_append (menu_string, ":");
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -635,9 +616,6 @@ void Menu_Update_Display(void)
if ((globals.Flash.voltage_offset_enabled[chan] || globals.Flash.current_offset_enabled[chan])
&& (globals.ChannelState[chan].amp_mode!=amp_mode_amplify)) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_offset+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_offset+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
@@ -646,21 +624,20 @@ void Menu_Update_Display(void)
if (globals.ChannelState[chan].os_mode==os_mode_normal) {
show_item=Show_offset+chan;
- strcpy(a_string,"OS");
+ menu_string = g_string_append (menu_string, "OS");
if (globals.Flash.ChanKey_offset) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
} else {
- strcpy(a_string,"OS");
+ menu_string = g_string_append (menu_string, "OS");
if (globals.Flash.ChanKey_offset) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":EXT");
+ menu_string = g_string_append (menu_string, ":EXT");
}
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_os) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig-globals.Flash.ChanKey_offset,LCD_col_width-1);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -673,13 +650,13 @@ void Menu_Update_Display(void)
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
- strcpy(a_string,"Mon");
+ menu_string = g_string_append (menu_string, "Mon");
if (globals.Flash.ChanKey_Curr_Mon_value) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
- Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry),LCD_row,LCD_col,a_string,Show_monitor+chan,sig_dig-globals.Flash.ChanKey_Curr_Mon_value,LCD_col_width-1);
+ menu_string = g_string_append (menu_string, ":");
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry),LCD_row,LCD_col,menu_string->str,Show_monitor+chan,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
globals.ChannelState[chan].displayed_mon_val=globals.ChannelState[chan].Curr_Mon_value;
}
}
@@ -691,31 +668,24 @@ void Menu_Update_Display(void)
for (chan=0; chan<(globals.Flash.ChanKey_zout?globals.Flash.channels:1); ++chan) {
if (globals.Flash.switchable_zout[chan] && !globals.Flash.volt_ctrl_pw[chan]) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_zout+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_zout+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
- strcpy(a_string,"Zout");
+ menu_string = g_string_append (menu_string, "Zout");
if (globals.Flash.ChanKey_zout) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
- gchar *temp = NULL;
if (globals.ChannelState[chan].zout==globals.Flash.zout_max[chan]) {
- temp = g_strdup_printf ("%d\xf4 ", globals.Flash.zout_max[chan]);
- strcat(a_string,temp);
+ g_string_append_printf (menu_string, "%d\xf4 ", globals.Flash.zout_max[chan]);
} else {
- temp = g_strdup_printf ("%d\xf4 ", globals.Flash.zout_min[chan]);
- strcat(a_string,temp);
+ g_string_append_printf (menu_string, "%d\xf4 ", globals.Flash.zout_min[chan]);
}
- 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);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,Show_No_Number,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -724,21 +694,18 @@ void Menu_Update_Display(void)
for (chan=0; chan<(globals.Flash.ChanKey_load_type?globals.Flash.channels:1); ++chan) {
if (globals.Flash.switchable_load[chan]) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_loadtype+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_loadtype+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
show_item=Show_load_type+chan;
- strcpy(a_string,"Load");
+ menu_string = g_string_append (menu_string, "Load");
if (globals.Flash.ChanKey_load_type) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_load) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,sig_dig-globals.Flash.ChanKey_load_type,LCD_col_width-1);
+ menu_string = g_string_append (menu_string, ":");
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -748,28 +715,25 @@ void Menu_Update_Display(void)
if (globals.Flash.on_off_used)
for (chan=0; chan<(globals.Flash.ChanKey_output_state?globals.Flash.channels:1); ++chan) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_output_state+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_output_state+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
- strcpy(a_string,"Output");
+ menu_string = g_string_append (menu_string, "Output");
if (globals.Flash.ChanKey_output_state) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
if (globals.ChannelState[chan].output_state==output_on) {
- strcat(a_string,"ON");
+ menu_string = g_string_append (menu_string, "ON");
} else {
- strcat(a_string,"OFF");
+ menu_string = g_string_append (menu_string, "OFF");
}
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_output) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,Show_No_Number,sig_dig-globals.Flash.ChanKey_output_state,LCD_col_width-1);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,Show_No_Number,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
/*----- display primary routing, as appropriate -----*/
@@ -778,9 +742,6 @@ void Menu_Update_Display(void)
if (globals.Flash.routing_required[chan] > 0) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_route_primary+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_route_primary+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
@@ -788,17 +749,17 @@ void Menu_Update_Display(void)
show_item=Show_route_primary+chan;
if (globals.Flash.routing_required[chan] == 1) {
- strcpy(a_string,"Route");
+ menu_string = g_string_append (menu_string, "Route");
} else {
- strcpy(a_string,"ANOD");
+ menu_string = g_string_append (menu_string, "ANOD");
}
if (globals.Flash.ChanKey_route) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_routes) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,0,LCD_col_width-1);
+ menu_string = g_string_append (menu_string, ":");
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,0,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -809,23 +770,20 @@ void Menu_Update_Display(void)
if (globals.Flash.routing_required[chan] == 2) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_route_secondary+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_route_secondary+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
show_item=Show_route_secondary+chan;
- strcpy(a_string,"CATH");
+ menu_string = g_string_append (menu_string, "CATH");
if (globals.Flash.ChanKey_route) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_routes) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,show_item,0,LCD_col_width-1);
+ menu_string = g_string_append (menu_string, ":");
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,show_item,0,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -835,27 +793,24 @@ void Menu_Update_Display(void)
for (chan=0; chan<(globals.Flash.ChanKey_polarity?globals.Flash.channels:1); ++chan) {
if (globals.Flash.invert_allowed[chan]) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_invert+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_invert+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
- strcpy(a_string,"INVERT");
+ menu_string = g_string_append (menu_string, "INVERT");
if (globals.Flash.ChanKey_polarity) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
if (globals.ChannelState[chan].polarity==pol_norm) {
- strcat(a_string,"NO");
+ menu_string = g_string_append (menu_string, "NO");
} else {
- strcat(a_string,"YES");
+ menu_string = g_string_append (menu_string, "YES");
}
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_inv) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,Show_No_Number,sig_dig-globals.Flash.ChanKey_polarity,LCD_col_width-1);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,Show_No_Number,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -864,26 +819,23 @@ void Menu_Update_Display(void)
if (globals.Flash.logic_level_enabled) {
for (chan=0; chan<(globals.Flash.ChanKey_logic_level?globals.Flash.channels:1); ++chan) {
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_logic_level+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_logic_level+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
- strcpy(a_string,"Logic");
+ menu_string = g_string_append (menu_string, "Logic");
if (globals.Flash.ChanKey_logic_level) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
if (globals.ChannelState[chan].logic_level==logic_ttl) {
- strcat(a_string,"TTL");
+ menu_string = g_string_append (menu_string, "TTL");
} else {
- strcat(a_string,"ECL");
+ menu_string = g_string_append (menu_string, "ECL");
}
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_logic_level) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,Show_No_Number,sig_dig-globals.Flash.ChanKey_logic_level,LCD_col_width-1);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,Show_No_Number,sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
@@ -894,72 +846,86 @@ void Menu_Update_Display(void)
if (!globals.Flash.is_func_gen[chan]) {
{
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_gate+chan) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_gate+chan;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
- strcpy(a_string,"GAT");
+ menu_string = g_string_append (menu_string, "GAT");
if (globals.Flash.ChanKey_gate_type || globals.Flash.ChanKey_gate_level) {
- sprintf(b_string, "%d", chan+1);
- strcat(a_string,b_string);
+ g_string_append_printf (menu_string, "%d", chan+1);
}
- strcat(a_string,":");
+ menu_string = g_string_append (menu_string, ":");
if (globals.ChannelState[chan].gate_type==gate_sync && globals.ChannelState[chan].gate_level==gate_low) {
- strcat(a_string,"SYN,LO");
+ menu_string = g_string_append (menu_string, "SYN,LO");
} else if (globals.ChannelState[chan].gate_type==gate_sync && globals.ChannelState[chan].gate_level==gate_high) {
- strcat(a_string,"SYN,HI");
+ menu_string = g_string_append (menu_string, "SYN,HI");
} else if (globals.ChannelState[chan].gate_type==gate_async && globals.ChannelState[chan].gate_level==gate_low) {
- strcat(a_string,"ASY,LO");
+ menu_string = g_string_append (menu_string, "ASY,LO");
} else {
- strcat(a_string,"ASY,HI");
+ menu_string = g_string_append (menu_string, "ASY,HI");
}
- Display_Number_on_LCD((globals.Changes.update_whole_main_menu || globals.Changes.update_gate) && Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,a_string,Show_No_Number, sig_dig-(globals.Flash.ChanKey_gate_level | globals.Flash.ChanKey_gate_type),LCD_col_width-1);
+ Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,Show_No_Number, sig_dig,LCD_col_width-1);
+ g_string_erase (menu_string, 0, -1);
}
}
/*----- display remote/local, always -----*/
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_rem_loc) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_rem_loc;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
- gchar *ctrl_str = NULL;
+ update_remote_mode();
- switch (globals.control_mode) {
- case REMS_ctrl:
- ctrl_str = g_strdup ("GPIB CTRL");
- break;
- case RWLS_ctrl:
- ctrl_str = g_strdup ("GPIB LOCK");
- break;
- case RS232_ctrl:
- ctrl_str = g_strdup ("RS232 CTRL");
- break;
- case WEB_ctrl:
- ctrl_str = g_strdup ("WEB CTRL");
- break;
- case TELNET_ctrl:
- ctrl_str = g_strdup ("TELNET CTRL");
- break;
- case LWLS_ctrl:
- ctrl_str = g_strdup ("LOCAL LOCK");
- break;
- case LOCS_ctrl:
- default:
- ctrl_str = g_strdup ("LOCAL CTRL");
- break;
+ GString *raw_str = g_string_new ("");
+
+ if (!GPIB_REMOTE_AND_LOCKED) {
+ raw_str = g_string_append (raw_str, "LOCAL+");
}
- if (globals.Changes.update_whole_main_menu && Menu_Is_Item_Visible(LCD_entry)) {
+ if (globals.Remote.gpib_remote) {
+ raw_str = g_string_append (raw_str, "GPIB+");
+ }
+
+ if (globals.Remote.terminal_connections > 0) {
+ g_string_append_printf (raw_str, "%dTER", globals.Remote.terminal_connections);
+ }
+
+ if (globals.Remote.vxi_connections > 0) {
+ g_string_append_printf (raw_str, "%dVXI", globals.Remote.vxi_connections);
+ }
+
+ gchar *step1 = g_strdup (raw_str->str);
+ g_string_free (raw_str, TRUE);
+
+ // remove semicolon at end
+ gchar *step2 = conditional_regex_replace (TRUE, step1, "\\+$", "");
+ g_free (step1);
+
+ // shorten as required
+ gchar *step3 = conditional_regex_replace (strlen(step2) > LCD_col_width, step2, "LOCAL", "LO");
+ g_free (step2);
+
+ // shorten as required
+ gchar *step4 = conditional_regex_replace (strlen(step3) > LCD_col_width, step3, "TER", "T");
+ g_free (step3);
+
+ // shorten as required
+ gchar *step5 = conditional_regex_replace (strlen(step4) > LCD_col_width, step4, "GPIB", "GP");
+ g_free (step4);
+
+ // shorten as required
+ gchar *step6 = conditional_regex_replace (strlen(step5) > LCD_col_width, step5, "VXI", "V");
+ g_free (step5);
+
+ // finish
+ gchar *ctrl_str = g_strdup (step6);
+ g_free (step6);
+
+ if (Menu_Is_Item_Visible(LCD_entry)) {
LCD_write_padded_spaces(LCD_row,LCD_col,ctrl_str,LCD_col_width);
}
@@ -968,14 +934,11 @@ void Menu_Update_Display(void)
/*----- display memory, always -----*/
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_memory) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_memory;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
- if (globals.Changes.update_whole_main_menu && Menu_Is_Item_Visible(LCD_entry)) {
+ if (Menu_Is_Item_Visible(LCD_entry)) {
LCD_write_padded_spaces(LCD_row,LCD_col,"Memory menu",LCD_col_width);
}
@@ -983,14 +946,11 @@ void Menu_Update_Display(void)
/*----- display setup, always -----*/
++LCD_entry;
- if (Main_Menu_Structure[LCD_entry]!=Submenu1_setup) {
- globals.Changes.update_whole_main_menu=YES;
- }
Main_Menu_Structure[LCD_entry]=Submenu1_setup;
LCD_row=LCD_entry % LCD_rows;
LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1;
- if (globals.Changes.update_whole_main_menu && Menu_Is_Item_Visible(LCD_entry)) {
+ if (Menu_Is_Item_Visible(LCD_entry)) {
LCD_write_padded_spaces(LCD_row,LCD_col,"Setup menu",LCD_col_width);
}
@@ -1022,7 +982,9 @@ void Menu_Update_Display(void)
LCD_write_padded_spaces(LCD_row,LCD_col,"",LCD_col_width);
}
- globals.Changes.update_whole_main_menu=NO;
+ g_string_free (menu_string, TRUE);
+
+ g_static_mutex_unlock (&mutex);
}
@@ -1075,20 +1037,21 @@ static void Menu_Move_Pointer(int move_amount)
new_page=menu_cursor_pos / LCD_max_entries_per_page;
if (new_page!=old_page) {
- Menu_Refresh();
+ Show_Main_Menu();
}
-
}
static void Display_Number_on_LCD(int Is_Item_Visible,int LCD_row,int LCD_col,char *start_string,int Show_What, int significant_digits, int width_of_column)
{
+ if (!Is_Item_Visible) {
+ return;
+ }
+
+ gchar *LCD_string = NULL;
gchar *units = NULL;
int channel;
- char LCD_string[LCD_cols+1];
- LCD_string[0]=0;
-
channel=Show_What%100;
if (Show_What!=Show_No_Number) {
@@ -1228,15 +1191,14 @@ static void Display_Number_on_LCD(int Is_Item_Visible,int LCD_row,int LCD_col,ch
units = g_strdup("");
}
- String_Parameter_To_Text(Submenu_Value,significant_digits,start_string,units,LCD_string,show_plus_sign);
+ String_Parameter_To_Text(Submenu_Value,significant_digits,start_string,units,&LCD_string,show_plus_sign,width_of_column);
} else {
- strcpy(LCD_string,start_string);
+ LCD_string = g_strdup(start_string);
}
- if (Is_Item_Visible) {
- LCD_write_padded_spaces(LCD_row, LCD_col, LCD_string, width_of_column);
- }
+ LCD_write_padded_spaces(LCD_row, LCD_col, LCD_string, width_of_column);
+ g_free (LCD_string);
g_free (units);
}
@@ -1247,7 +1209,6 @@ static void Submenu_Display(int change_selection)
int i;
int channel;
- // FIXME - check for redundant clearing
if ( (globals.MenuStatus.Type_Of_Menu != Submenu_On) ||
(globals.MenuStatus.Error_Screen == YES) ||
(globals.MenuStatus.Nonstd_Display == YES) ||
@@ -1510,11 +1471,17 @@ static void Submenu_Display(int change_selection)
break;
case Submenu1_rem_loc:
- title = g_strdup ("Control Mode:");
- Submenu_max_entry=1;
- Submenu_Structure[0]=mode_go_to_local;
- Submenu_Structure[1]=mode_exit_normal_submenu;
+ if (GPIB_REMOTE_AND_UNLOCKED) {
+ Submenu_max_entry=1;
+ title = g_strdup ("GPIB Remote:");
+ Submenu_Structure[0]=mode_go_to_local;
+ Submenu_Structure[1]=mode_exit_normal_submenu;
+ } else {
+ Submenu_max_entry=0;
+ title = g_strdup ("GPIB interface already in local mode.");
+ Submenu_Structure[0]=mode_exit_normal_submenu;
+ }
break;
case Submenu1_setup:
@@ -1574,38 +1541,17 @@ static void Submenu_Display(int change_selection)
case Submenu2_rs232_baud:
title = g_strdup ("Baud Rate:");
- Submenu_max_entry=3;
+ Submenu_max_entry=7;
- // FIXME: generate structure from valid baud rate list
Submenu_Structure[0]=mode_1200;
Submenu_Structure[1]=mode_2400;
Submenu_Structure[2]=mode_4800;
Submenu_Structure[3]=mode_9600;
- break;
-
- case Submenu2_rs232_databits:
- title = g_strdup ("Data Bits:");
- Submenu_max_entry=1;
-
- Submenu_Structure[0]=mode_7bits;
- Submenu_Structure[1]=mode_8bits;
- break;
-
- case Submenu2_rs232_parity:
- title = g_strdup ("Parity:");
- Submenu_max_entry=2;
-
- Submenu_Structure[0]=mode_par_none;
- Submenu_Structure[1]=mode_par_even;
- Submenu_Structure[2]=mode_par_odd;
- break;
-
- case Submenu2_rs232_stopbits:
- title = g_strdup ("Stop Bits:");
- Submenu_max_entry=1;
+ Submenu_Structure[4]=mode_19200;
+ Submenu_Structure[5]=mode_38400;
+ Submenu_Structure[6]=mode_57600;
+ Submenu_Structure[7]=mode_115200;
- Submenu_Structure[0]=mode_1bit;
- Submenu_Structure[1]=mode_2bits;
break;
case Submenu2_rs232_hardhand:
@@ -1616,14 +1562,6 @@ static void Submenu_Display(int change_selection)
Submenu_Structure[1]=mode_hand_off;
break;
- case Submenu2_rs232_echo:
- title = g_strdup ("Echo:");
- Submenu_max_entry=1;
-
- Submenu_Structure[0]=mode_echo_on;
- Submenu_Structure[1]=mode_echo_off;
- break;
-
case Submenu2_gpib_address:
title = g_strdup ("GPIB Address:");
Submenu_Numeric_Parameter=Show_gpib_address+channel;
@@ -1661,281 +1599,271 @@ static void Submenu_Display(int change_selection)
LCD_write(3,0,Press_Change_Message);
if (Submenu_max_entry>0) {
- char mode_name[Submenu_maximum_entries][LCD_col_width+1];
+
+ 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:
- strcpy(mode_name[i],"Internal");
+ mode_name = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = g_strdup("Go To Local");
break;
case mode_inv_no:
- strcpy(mode_name[i],"NO (normal)");
+ mode_name = 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 = 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 = 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 = 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 = 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 = 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 = g_strdup("GPIB address");
break;
case mode_rs232_settings:
- strcpy(mode_name[i],"RS232 setup");
+ mode_name = g_strdup("RS232 setup");
break;
case mode_model_info:
- strcpy(mode_name[i],"Model info");
+ mode_name = g_strdup("Model info");
break;
case mode_network:
- strcpy(mode_name[i],"Network info");
+ mode_name = g_strdup("Network info");
break;
case mode_password:
- strcpy(mode_name[i],"Pwd~default");
+ mode_name = g_strdup("Pwd~default");
break;
case mode_selfcal:
- strcpy(mode_name[i],"Self Cal");
+ mode_name = g_strdup("Self Cal");
break;
case mode_exit_normal_submenu:
- strcpy(mode_name[i],"Exit");
+ mode_name = g_strdup("Exit");
break;
case mode_load:
- strcpy(mode_name[i],"Load Settings");
+ mode_name = g_strdup("Load Settings");
break;
case mode_save:
- strcpy(mode_name[i],"Save Settings");
+ mode_name = g_strdup("Save Settings");
break;
case mode_load_0:
- strcpy(mode_name[i],"Storage 0");
+ case mode_save_0:
+ mode_name = g_strdup("Storage 0");
break;
case mode_load_1:
- strcpy(mode_name[i],"Storage 1");
+ case mode_save_1:
+ mode_name = g_strdup("Storage 1");
break;
case mode_load_2:
- strcpy(mode_name[i],"Storage 2");
+ case mode_save_2:
+ mode_name = 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 = g_strdup("Storage 3");
break;
case mode_change_rs232:
- strcpy(mode_name[i],"Change values");
+ mode_name = g_strdup("Change values");
break;
case mode_default_rs232:
- strcpy(mode_name[i],"Default");
+ mode_name = g_strdup("Default");
break;
case mode_exit_rs232:
- strcpy(mode_name[i],"Exit");
+ mode_name = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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);
+ 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);
+ 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]) {
@@ -1944,9 +1872,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);
+ 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);
+ 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]) {
@@ -1954,101 +1882,79 @@ static void Submenu_Display(int change_selection)
}
break;
case mode_1200:
- strcpy(mode_name[i],"1200 baud");
+ mode_name = 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 = 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 = 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 = g_strdup("9600 baud");
if (globals.Flash.baud==9600) {
current_operating_mode=i;
}
break;
- case mode_7bits:
- strcpy(mode_name[i],"7 bits");
- if (globals.Flash.databits==7) {
- current_operating_mode=i;
- }
- break;
- case mode_8bits:
- strcpy(mode_name[i],"8 bits");
- if (globals.Flash.databits==8) {
- current_operating_mode=i;
- }
- break;
- case mode_par_none:
- strcpy(mode_name[i],"None");
- if (globals.Flash.parity==rs232_parity_none) {
- current_operating_mode=i;
- }
- break;
- case mode_par_even:
- strcpy(mode_name[i],"Even");
- if (globals.Flash.parity==rs232_parity_even) {
+ case mode_19200:
+ mode_name = g_strdup("19200 baud");
+ if (globals.Flash.baud==19200) {
current_operating_mode=i;
}
break;
- case mode_par_odd:
- strcpy(mode_name[i],"Odd");
- if (globals.Flash.parity==rs232_parity_odd) {
+ case mode_38400:
+ mode_name = g_strdup("38400 baud");
+ if (globals.Flash.baud==38400) {
current_operating_mode=i;
}
break;
- case mode_1bit:
- strcpy(mode_name[i],"1 bit");
- if (globals.Flash.stopbits==1) {
+ case mode_57600:
+ mode_name = g_strdup("57600 baud");
+ if (globals.Flash.baud==57600) {
current_operating_mode=i;
}
break;
- case mode_2bits:
- strcpy(mode_name[i],"2 bits");
- if (globals.Flash.stopbits==2) {
+ case mode_115200:
+ mode_name = 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 = g_strdup("Hardware");
if (globals.Flash.hardhand) {
current_operating_mode=i;
}
break;
case mode_hand_off:
- strcpy(mode_name[i],"None");
+ mode_name = g_strdup("None");
if (!globals.Flash.hardhand) {
current_operating_mode=i;
}
break;
- case mode_echo_on:
- strcpy(mode_name[i],"On");
- if (globals.Flash.echo) {
- current_operating_mode=i;
- }
- break;
- case mode_echo_off:
- strcpy(mode_name[i],"Off");
- if (!globals.Flash.echo) {
- current_operating_mode=i;
- }
+ 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. In this case, the arrow pointer points at the
- current operating mode. If change_selection=YES, the submenu is being redrawn to scroll the mode list. In this case,
- the arrow pointer points at the current selection. */
+ /* If change_selection==NO, the submenu is being drawn from scratch.
+ this case, the arrow pointer points at the current operating mode.
+ If change_selection=YES, the submenu is being redrawn to scroll
+ the mode list. In this case, the arrow pointer points at the current
+ selection. */
if (change_selection==NO && current_operating_mode<4) {
base_entry=0;
@@ -2056,21 +1962,14 @@ static void Submenu_Display(int change_selection)
} else if (change_selection==NO) {
base_entry=current_operating_mode-3;
Submenu_Selected_Item=current_operating_mode;
- } else if (change_selection=YES && Submenu_Selected_Item<4) {
+ } else if (change_selection==YES && Submenu_Selected_Item<4) {
base_entry=0;
- } else if (change_selection=YES && Submenu_Selected_Item>=4) {
+ } else if (change_selection==YES && Submenu_Selected_Item>=4) {
base_entry=Submenu_Selected_Item-3;
}
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, g_ptr_array_index (gparray, i));
}
LCD_write(Submenu_Selected_Item-base_entry,25,"~");
@@ -2084,6 +1983,8 @@ static void Submenu_Display(int change_selection)
LCD_write(3,39,"\x3");
}
+ g_ptr_array_foreach (gparray, (GFunc) g_free, NULL);
+ g_ptr_array_free (gparray, TRUE);
}
}
@@ -2139,12 +2040,14 @@ static int Submenu_Mult_Value(float mult_by)
new_value=zero_equiv_timing;
}
}
- if (fabs(new_value) < zero_equiv_timing)
+
+ if (fabs(new_value) < zero_equiv_timing) {
if (new_value<0.0) {
new_value=-smallest_allowed_number;
} else {
new_value=smallest_allowed_number;
}
+ }
if (error_num=Set_Delay(0,0,0,channel,new_value)) {
Submenu_Value=new_value;
@@ -2160,12 +2063,14 @@ static int Submenu_Mult_Value(float mult_by)
new_value=zero_equiv_timing;
}
}
- if (fabs(new_value) < zero_equiv_timing)
+
+ if (fabs(new_value) < zero_equiv_timing) {
if (new_value<0.0) {
new_value=-smallest_allowed_number;
} else {
new_value=smallest_allowed_number;
}
+ }
if (error_num=Set_Pw(0,0,0,channel,new_value,0)) {
Submenu_Value=new_value;
@@ -2180,12 +2085,15 @@ static int Submenu_Mult_Value(float mult_by)
new_value=globals.Flash.ampl_zero_equiv[channel];
}
}
- if (fabs(new_value) < globals.Flash.ampl_zero_equiv[channel])
+
+ if (fabs(new_value) < globals.Flash.ampl_zero_equiv[channel]) {
if (new_value<0.0) {
new_value=-smallest_allowed_number;
} else {
new_value=smallest_allowed_number;
}
+ }
+
if (error_num=Set_Amplitude(0,0,0,0,0,0,channel,new_value,0)) {
Submenu_Value=new_value;
}
@@ -2248,12 +2156,15 @@ static int Submenu_Mult_Value(float mult_by)
new_value=globals.Flash.ampl_zero_equiv[channel];
}
}
- if (fabs(new_value) < globals.Flash.ampl_zero_equiv[channel])
+
+ if (fabs(new_value) < globals.Flash.ampl_zero_equiv[channel]) {
if (new_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;
}
@@ -2289,7 +2200,8 @@ static void Submenu_Service_Encoder(int encoder_change)
reset_encoder=YES;
/* quit if RWLS mode */
- if (globals.control_mode==RWLS_ctrl) {
+ update_remote_mode ();
+ if (GPIB_REMOTE_AND_LOCKED) {
return;
}
@@ -2656,12 +2568,14 @@ static void Submenu_Service_Encoder(int encoder_change)
if (globals.Flash.min_ampl[channel]==globals.Flash.max_ampl[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 (globals.Flash.ampl_min_max_only[channel]) { /* not used for two-state amplitudes */
return;
@@ -2762,12 +2676,12 @@ static void Nonstd_menu_default_rs232(void)
Menu_Clear_Buttons();
LCD_clear(); /*0123456789012345678901234567890123456789*/
- LCD_write(0,0,"The RS232 settings are now: 1200 baud, ");
- LCD_write(1,0,"8 data bits, no parity, 1 stop bit,");
- LCD_write(2,0,"hardware handshaking on, and echo on.");
+ LCD_write(0,0,"The RS232 settings are now: 1200 baud,");
+ LCD_write(1,0,"auto data bits / parity, 1 stop bit,");
+ LCD_write(2,0,"hardware handshaking on, echo on.");
LCD_write(3,0,Press_Change_Message);
- IO_Setup_RS232(1200, rs232_parity_none, 1, 8, 1, 1, TRUE);
+ IO_Setup_RS232(1200, 1, TRUE);
Menu_Clear_Buttons();
@@ -2898,6 +2812,11 @@ void Menu_Check_Buttons(void)
int lower_encoder_val;
int encoder_change;
+ // abort if not running on the target board with the I2C bus
+ if (!globals.HWDetect.beaglebone) {
+ return;
+ }
+
/* get keypad state */
Read_Keypad(&button_port_val,&upper_encoder_val,&lower_encoder_val);
@@ -2908,18 +2827,15 @@ void Menu_Check_Buttons(void)
encoder_change = encoder_change - 0x100;
}
+ update_remote_mode();
+
if (!(button_port_val & Change_Button)) { /* ----- CHANGE BUTTON --------- */
- if ( globals.control_mode==LOCS_ctrl || globals.control_mode==LWLS_ctrl ||
- (
- ( globals.control_mode==REMS_ctrl
- || globals.control_mode==RS232_ctrl
- || globals.control_mode==WEB_ctrl
- || globals.control_mode==TELNET_ctrl)
- && globals.MenuStatus.Selected_Submenu==Submenu1_rem_loc
- )
- ) {
+ if (GPIB_REMOTE_AND_LOCKED) {
+ // front panel is locked out
+ Show_Main_Menu();
+ } else {
if ((globals.MenuStatus.Type_Of_Menu==Main_Menu_On && globals.MenuStatus.Error_Screen==YES) || globals.MenuStatus.Nonstd_Display==YES) {
- Menu_Update_Display();
+ Show_Main_Menu();
} else if (globals.MenuStatus.Type_Of_Menu==Submenu_On && globals.MenuStatus.Error_Screen==YES) {
Submenu_Display(NO);
} else if (globals.MenuStatus.Type_Of_Menu==Main_Menu_On && globals.MenuStatus.Error_Screen==NO) {
@@ -2939,29 +2855,28 @@ void Menu_Check_Buttons(void)
Submenu_Move_Pointer();
}
} else if (!(button_port_val & Mult10_Button)) { /* ----- X10 BUTTON ------------ */
- if (globals.MenuStatus.Type_Of_Menu==Submenu_On && (globals.control_mode==LOCS_ctrl || globals.control_mode==LWLS_ctrl)) {
+ if (globals.MenuStatus.Type_Of_Menu==Submenu_On && !GPIB_REMOTE_AND_LOCKED) {
if (globals.MenuStatus.Error_Screen==YES) {
Submenu_Display(NO);
}
queue_error_and_display_on_LCD(Submenu_Mult_Value(10.0));
}
} else if (!(button_port_val & Div10_Button)) { /* ----- /10 BUTTON ------------ */
- if (globals.MenuStatus.Type_Of_Menu==Submenu_On && (globals.control_mode==LOCS_ctrl || globals.control_mode==LWLS_ctrl)) {
+ if (globals.MenuStatus.Type_Of_Menu==Submenu_On && !GPIB_REMOTE_AND_LOCKED) {
if (globals.MenuStatus.Error_Screen==YES) {
Submenu_Display(NO);
}
queue_error_and_display_on_LCD(Submenu_Mult_Value(0.1));
}
} else if (!(button_port_val & Plus_Minus_Button)) { /* ----- +/- BUTTON ------------ */
- if (globals.MenuStatus.Type_Of_Menu==Submenu_On && (globals.control_mode==LOCS_ctrl || globals.control_mode==LWLS_ctrl)) {
+ if (globals.MenuStatus.Type_Of_Menu==Submenu_On && !GPIB_REMOTE_AND_LOCKED) {
if (globals.MenuStatus.Error_Screen==YES) {
Submenu_Display(NO);
}
queue_error_and_display_on_LCD(Submenu_Mult_Value(-1.0));
}
} else if (!(button_port_val & Extra_Fine_Button)) { /* ----- EXTRA FINE BUTTON ----- */
- if (globals.MenuStatus.Type_Of_Menu==Submenu_On && globals.MenuStatus.Nonstd_Display==NO && globals.MenuStatus.Error_Screen==NO &&
- (globals.control_mode==LOCS_ctrl || globals.control_mode==LWLS_ctrl)) {
+ if (globals.MenuStatus.Type_Of_Menu==Submenu_On && globals.MenuStatus.Nonstd_Display==NO && globals.MenuStatus.Error_Screen==NO && !GPIB_REMOTE_AND_LOCKED) {
if (Submenu_extra_fine==YES) {
g_usleep (250e3);
Submenu_extra_fine=NO;
@@ -2990,14 +2905,14 @@ static int Submenu_Implement_Changes(void)
{
int error_num;
int call_new_submenu;
- int channel,eprom_loc;
+ int channel;
call_new_submenu=NO;
/* this routine changes the pulse generator parameters, as chosen by the submenu settings */
if (Submenu_max_entry==0) {
- Menu_Update_Display();
+ Show_Main_Menu();
return OK;
}
@@ -3116,7 +3031,7 @@ static int Submenu_Implement_Changes(void)
}
break;
case mode_go_to_local:
- Main_return_to_local();
+ GPIB_go_to_local();
break;
case mode_inv_no:
if (error_num=Set_Pol(channel,pol_norm)) {
@@ -3254,8 +3169,8 @@ static int Submenu_Implement_Changes(void)
Submenu_Display(NO);
break;
case mode_default_rs232:
+ call_new_submenu=YES;
Nonstd_menu_default_rs232();
- globals.MenuStatus.Selected_Submenu=Submenu1_setup;
break;
case mode_model_info:
call_new_submenu=YES;
@@ -3266,11 +3181,7 @@ static int Submenu_Implement_Changes(void)
Nonstd_menu_network();
break;
case mode_password:
- strcpy(globals.Flash.password,"default");
- // FIXME - save password to /etc/shadow here
-
- eprom_loc = (char *) &(globals.Flash.password) - (char *) &(globals.Flash.flash_start);
- writeUserBlock(&globals.Flash, eprom_loc, strlen(globals.Flash.password)+1);
+ change_password (NULL, "default");
break;
case mode_selfcal:
if (error_num=self_cal()) {
@@ -3286,99 +3197,72 @@ static int Submenu_Implement_Changes(void)
globals.MenuStatus.Selected_Submenu=Submenu1_setup;
break;
case mode_1200:
- // FIXME: check that serial menus actually work
- IO_Setup_RS232(1200, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_databits;
+ IO_Setup_RS232(1200, globals.Flash.hardhand, FALSE);
+ globals.MenuStatus.Selected_Submenu=Submenu2_rs232_hardhand;
call_new_submenu=YES;
Submenu_Display(NO);
break;
case mode_2400:
- IO_Setup_RS232(2400, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_databits;
+ IO_Setup_RS232(2400, globals.Flash.hardhand, FALSE);
+ globals.MenuStatus.Selected_Submenu=Submenu2_rs232_hardhand;
call_new_submenu=YES;
Submenu_Display(NO);
break;
case mode_4800:
- IO_Setup_RS232(4800, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_databits;
+ IO_Setup_RS232(4800, globals.Flash.hardhand, FALSE);
+ globals.MenuStatus.Selected_Submenu=Submenu2_rs232_hardhand;
call_new_submenu=YES;
Submenu_Display(NO);
break;
case mode_9600:
- IO_Setup_RS232(9600, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_databits;
- call_new_submenu=YES;
- Submenu_Display(NO);
- break;
- case mode_7bits:
- IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, 7, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_parity;
- call_new_submenu=YES;
- Submenu_Display(NO);
- break;
- case mode_8bits:
- IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, 8, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_parity;
- call_new_submenu=YES;
- Submenu_Display(NO);
- break;
- case mode_par_none:
- IO_Setup_RS232(globals.Flash.baud, rs232_parity_none, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_stopbits;
+ IO_Setup_RS232(9600, globals.Flash.hardhand, FALSE);
+ globals.MenuStatus.Selected_Submenu=Submenu2_rs232_hardhand;
call_new_submenu=YES;
Submenu_Display(NO);
break;
- case mode_par_odd:
- IO_Setup_RS232(globals.Flash.baud, rs232_parity_odd, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_stopbits;
+ case mode_19200:
+ IO_Setup_RS232(19200, globals.Flash.hardhand, FALSE);
+ globals.MenuStatus.Selected_Submenu=Submenu2_rs232_hardhand;
call_new_submenu=YES;
Submenu_Display(NO);
break;
- case mode_par_even:
- IO_Setup_RS232(globals.Flash.baud, rs232_parity_even, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_stopbits;
+ case mode_38400:
+ IO_Setup_RS232(38400, globals.Flash.hardhand, FALSE);
+ globals.MenuStatus.Selected_Submenu=Submenu2_rs232_hardhand;
call_new_submenu=YES;
Submenu_Display(NO);
break;
- case mode_1bit:
- IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, 1, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
+ case mode_57600:
+ IO_Setup_RS232(57600, globals.Flash.hardhand, FALSE);
globals.MenuStatus.Selected_Submenu=Submenu2_rs232_hardhand;
call_new_submenu=YES;
Submenu_Display(NO);
break;
- case mode_2bits:
- IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, 2, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo, FALSE);
+ case mode_115200:
+ IO_Setup_RS232(115200, globals.Flash.hardhand, FALSE);
globals.MenuStatus.Selected_Submenu=Submenu2_rs232_hardhand;
call_new_submenu=YES;
Submenu_Display(NO);
break;
+
case mode_hand_hard:
- IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, 1, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_echo;
+ IO_Setup_RS232(globals.Flash.baud, 1, FALSE);
+ globals.MenuStatus.Selected_Submenu=Submenu1_setup;
call_new_submenu=YES;
Submenu_Display(NO);
break;
case mode_hand_off:
- IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, 0, globals.Flash.echo, FALSE);
- globals.MenuStatus.Selected_Submenu=Submenu2_rs232_echo;
+ IO_Setup_RS232(globals.Flash.baud, 0, FALSE);
+ globals.MenuStatus.Selected_Submenu=Submenu1_setup;
call_new_submenu=YES;
Submenu_Display(NO);
break;
- case mode_echo_on:
- IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, 1, TRUE);
- globals.MenuStatus.Selected_Submenu=Submenu1_setup;
- break;
- case mode_echo_off:
- IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, 0, TRUE);
- globals.MenuStatus.Selected_Submenu=Submenu1_setup;
- break;
}
Main_update_shift_registers(); /* update values in pulse generator circuit */
if (call_new_submenu==NO) {
- globals.Changes.update_whole_main_menu=YES;
- Menu_Update_Display();
+ Show_Main_Menu();
}
/* re-run error_check to update min/max values based on actual settings, not proposed settings */