summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--menus.c42
-rw-r--r--string_utils.c7
-rw-r--r--string_utils.h2
3 files changed, 27 insertions, 24 deletions
diff --git a/menus.c b/menus.c
index 7cd12b8..f4467ee 100644
--- a/menus.c
+++ b/menus.c
@@ -394,7 +394,7 @@ void Show_Main_Menu(void)
}
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_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);
}
@@ -446,7 +446,7 @@ void Show_Main_Menu(void)
}
menu_string = g_string_append (menu_string, ": DC");
}
- Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,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);
}
}
@@ -472,7 +472,7 @@ void Show_Main_Menu(void)
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-globals.Flash.ChanKey_rise_time,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);
}
}
@@ -509,7 +509,7 @@ void Show_Main_Menu(void)
}
menu_string = g_string_append (menu_string, ":AMPLFY");
}
- Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,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);
}
}
@@ -528,7 +528,7 @@ void Show_Main_Menu(void)
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-1,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);
}
}
@@ -549,7 +549,7 @@ void Show_Main_Menu(void)
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-globals.Flash.ChanKey_current_limit,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);
}
}
@@ -572,7 +572,7 @@ void Show_Main_Menu(void)
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-globals.Flash.ChanKey_slew,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);
}
}
@@ -617,7 +617,7 @@ void Show_Main_Menu(void)
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-globals.Flash.ChanKey_Burst_Time,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);
}
}
@@ -650,7 +650,7 @@ void Show_Main_Menu(void)
}
menu_string = g_string_append (menu_string, ":EXT");
}
- Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,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);
}
}
@@ -669,7 +669,7 @@ void Show_Main_Menu(void)
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_monitor+chan,sig_dig-globals.Flash.ChanKey_Curr_Mon_value,LCD_col_width-1);
+ 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;
}
@@ -698,7 +698,7 @@ void Show_Main_Menu(void)
g_string_append_printf (menu_string, "%d\xf4 ", globals.Flash.zout_min[chan]);
}
- Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,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);
}
}
@@ -718,7 +718,7 @@ void Show_Main_Menu(void)
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-globals.Flash.ChanKey_load_type,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);
}
}
@@ -746,7 +746,7 @@ void Show_Main_Menu(void)
menu_string = g_string_append (menu_string, "OFF");
}
- Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,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);
}
@@ -823,7 +823,7 @@ void Show_Main_Menu(void)
menu_string = g_string_append (menu_string, "YES");
}
- Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,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);
}
}
@@ -848,7 +848,7 @@ void Show_Main_Menu(void)
menu_string = g_string_append (menu_string, "ECL");
}
- Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,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);
}
}
@@ -880,7 +880,7 @@ void Show_Main_Menu(void)
menu_string = g_string_append (menu_string, "ASY,HI");
}
- Display_Number_on_LCD(Menu_Is_Item_Visible(LCD_entry), LCD_row,LCD_col,menu_string->str,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);
}
}
@@ -1189,7 +1189,7 @@ 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 {
LCD_string = g_strdup(start_string);
}
@@ -1871,9 +1871,9 @@ static void Submenu_Display(int change_selection)
break;
case mode_amp_min:
if (globals.Flash.voltage_enabled[channel]) {
- String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","V",&tmp_str,YES);
+ String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","V",&tmp_str,YES,LCD_col_width);
} else {
- String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","A",&tmp_str,YES);
+ String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","A",&tmp_str,YES,LCD_col_width);
}
strcpy (mode_name[i], tmp_str); // FIXME
@@ -1884,9 +1884,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",&tmp_str,YES);
+ String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","V",&tmp_str,YES,LCD_col_width);
} else {
- String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","A",&tmp_str,YES);
+ String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","A",&tmp_str,YES,LCD_col_width);
}
strcpy (mode_name[i], tmp_str); // FIXME
diff --git a/string_utils.c b/string_utils.c
index 502e2a7..33e830e 100644
--- a/string_utils.c
+++ b/string_utils.c
@@ -38,7 +38,7 @@ gboolean String_is_it_numeric(char *parameter)
void String_Parameter_To_Text(float Float_To_Convert, int significant_digits,
- char *start_string,char *units,gchar **LCD_string,int show_plus_sign)
+ char *start_string,char *units,gchar **LCD_string,int show_plus_sign, int width_of_column)
{
gchar *floating_val = NULL;
gchar *unit_mult = NULL; /* units multiplier, eg. M, k, u */
@@ -118,10 +118,13 @@ void String_Parameter_To_Text(float Float_To_Convert, int significant_digits,
/* put in the new decimal point */
out_gstr = g_string_append_c (out_gstr, '.');
+ int space_left = width_of_column - strlen(out_gstr->str) - strlen (unit_mult) - strlen (units);
+
/* copy the rest of the digits */
- for (i=shift_decimal_by+1+decimal_location; digits_so_far<significant_digits; ++i) {
+ for (i=shift_decimal_by+1+decimal_location; (digits_so_far<significant_digits) && (space_left>0); ++i) {
out_gstr = g_string_append_c (out_gstr, floating_val[i]);
++digits_so_far;
+ space_left = width_of_column - strlen(out_gstr->str) - strlen (unit_mult) - strlen (units);
/* leave space for minus sign, decimal point, and extra digit on the end too */
}
diff --git a/string_utils.h b/string_utils.h
index bd01a1c..e52fc3d 100644
--- a/string_utils.h
+++ b/string_utils.h
@@ -6,6 +6,6 @@
void Float_To_Text(int decimal_digits,float number_in, gchar** text_out);
gboolean String_is_it_numeric(char *parameter);
void String_Parameter_To_Text(float Float_To_Convert, int significant_digits,
- char *start_string,char *units,gchar **LCD_string,int show_plus_sign);
+ char *start_string,char *units,gchar **LCD_string,int show_plus_sign, int width_of_column);
#endif