diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-09-05 15:27:54 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-09-05 15:27:54 -0400 |
commit | 7055df2fedee4a1b5fc0303fadfe315b5ffeffa4 (patch) | |
tree | 182ec16ebde5970314bebd9b000d6266878857bd | |
parent | ce20f1608a89a695ee5df57d42e2f0eda6979de2 (diff) |
scope reductions
-rw-r--r-- | menus.c | 23 | ||||
-rw-r--r-- | string_utils.c | 11 |
2 files changed, 16 insertions, 18 deletions
@@ -1083,7 +1083,6 @@ 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) { gchar *units = NULL; - int show_plus_sign; int channel; char LCD_string[LCD_cols+1]; @@ -1092,6 +1091,8 @@ static void Display_Number_on_LCD(int Is_Item_Visible,int LCD_row,int LCD_col,ch channel=Show_What%100; if (Show_What!=Show_No_Number) { + int show_plus_sign; + switch (Show_What-channel) { case Show_frequency: Submenu_Value=globals.ChannelState[channel].frequency; @@ -1242,14 +1243,8 @@ static void Display_Number_on_LCD(int Is_Item_Visible,int LCD_row,int LCD_col,ch static void Submenu_Display(int redraw) { gchar *title = NULL; - char mode_name[Submenu_maximum_entries][LCD_col_width+1]; int i; - int j; int channel; - int current_operating_mode; - int add_spaces; - - current_operating_mode=0; // FIXME - check for redundant clearing if ( (globals.MenuStatus.Type_Of_Menu != Submenu_On) || @@ -1664,6 +1659,9 @@ static void Submenu_Display(int redraw) LCD_write(3,0,Press_Change_Message); if (Submenu_max_entry>0) { + char mode_name[Submenu_maximum_entries][LCD_col_width+1]; + int current_operating_mode = 0; + LCD_write(0,19,"Mode:"); for (i=0; i<=Submenu_max_entry; ++i) { @@ -2063,7 +2061,10 @@ static void Submenu_Display(int redraw) } 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]," "); } @@ -2819,9 +2820,6 @@ static void Read_Keypad(int *button_port_val, int *upper_encoder_val, int *lower int new_button_state; - int chan; - int outputs_turned_off; - /* read the button data */ new_button_state = I2C_Read(PCF8574A+Button_Press_Port); @@ -2869,8 +2867,9 @@ static void Read_Keypad(int *button_port_val, int *upper_encoder_val, int *lower || !(*button_port_val & Overload_Input) ) { /* disable all outputs immediately */ - outputs_turned_off = 0; + int outputs_turned_off = 0; if (globals.Flash.on_off_used) { + int chan; for (chan=0; chan<(globals.Flash.ChanKey_output_state?globals.Flash.channels:1); ++chan) { if (globals.ChannelState[chan].output_state == output_on) { ++outputs_turned_off; @@ -2898,7 +2897,6 @@ static void Read_Keypad(int *button_port_val, int *upper_encoder_val, int *lower GSourceFunc Menu_Check_Buttons(void) { - int error_num; int button_port_val; int upper_encoder_val; int lower_encoder_val; @@ -2931,6 +2929,7 @@ GSourceFunc Menu_Check_Buttons(void) } else if (globals.MenuStatus.Type_Of_Menu==Main_Menu_On && globals.MenuStatus.Error_Screen==NO) { Submenu_Display(NO); } else if (globals.MenuStatus.Type_Of_Menu==Submenu_On && globals.MenuStatus.Error_Screen==NO) { + int error_num; if (error_num=Submenu_Implement_Changes()) { queue_error_and_display_on_LCD(error_num); } diff --git a/string_utils.c b/string_utils.c index 651a3c7..bf17e50 100644 --- a/string_utils.c +++ b/string_utils.c @@ -45,12 +45,6 @@ void String_Parameter_To_Text(float Float_To_Convert, int significant_digits, gchar *floating_val = NULL; gchar *unit_mult = NULL; /* units multiplier, eg. M, k, u */ - int i; /* just a counter */ - int shift_decimal_by; /* if the exponent isn't a multiple of 3, the decimal point will be moved */ - int decimal_location; /* where the decimal is in the number string */ - - int exponent_val; /* the exponent, in integer form */ - /* Copy the floating point value to a string. Do not multiply to accomodate units; the roundoff */ /* is annoying. (e.g. 1.000 -> 0.999) */ /* Move the decimal with string manipulations instead. */ @@ -65,6 +59,11 @@ void String_Parameter_To_Text(float Float_To_Convert, int significant_digits, strcat(LCD_string,out_val); g_free (out_val); } else { + int i; + int shift_decimal_by; /* if the exponent isn't a multiple of 3, the decimal point will be moved */ + int decimal_location; /* where the decimal is in the number string */ + int exponent_val; /* the exponent, in integer form */ + GString *out_gstr = g_string_new (""); Float_To_Text(remote_digits_after_decimal,Float_To_Convert,&floating_val); |