From 82db18314efe170471f1675d40fbf1416fbb95e8 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 1 Jan 2000 00:53:59 +0900 Subject: +/- button not working as expected first press after turn-on, fixed. Better debugging messages. --- device-functions.c | 9 +++++++-- globals.h | 2 +- menus.c | 13 ++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/device-functions.c b/device-functions.c index 333d9cb..d9f4664 100644 --- a/device-functions.c +++ b/device-functions.c @@ -252,7 +252,7 @@ static int attenuator_count (int channel) int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int word_override,int range_override,int aux_override, - int switch_range_only,int channel,float new_ampl,int called_from_set_pw) + int switch_range_only,int channel,float requested_ampl,int called_from_set_pw) { int word_out, word_out_aux; /* what is sent to the DAC */ int relay_range,atten_range,old_range,old_actual_pol; /* selects relay range */ @@ -261,6 +261,10 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w int entry; int actual_pol; + float new_ampl; + + new_ampl = requested_ampl; + if (!globals.Flash.voltage_enabled[channel] && !globals.Flash.current_enabled[channel]) { return Unrecognized; } @@ -447,7 +451,8 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w globals.Flags.force_output_fully_off=YES; } - g_print_debug("chan %d, ampl %e, range %d, word %d\n", channel, new_ampl, relay_range, word_out); + g_print_debug("%ld - chan %d, requested ampl %e, set ampl %e, polarity %d, range %d, word %d\n", + sec_timer(), channel, requested_ampl, new_ampl, actual_pol, relay_range, word_out); globals.Changes.update_amp=YES; diff --git a/globals.h b/globals.h index 5cd456b..ca46c20 100644 --- a/globals.h +++ b/globals.h @@ -10,7 +10,7 @@ #define DEBUG_ON - uncomment this to have debug messages #ifdef DEBUG_ON -#define g_print_debug(...) g_print(__VA_ARGS__) +#define g_print_debug(...) g_print("%ld - ", sec_timer()); g_print(__VA_ARGS__) #else #define g_print_debug(...) {} #endif diff --git a/menus.c b/menus.c index 840211e..a92d471 100644 --- a/menus.c +++ b/menus.c @@ -2168,7 +2168,18 @@ static int Submenu_Mult_Value(float mult_by) channel=Submenu_Numeric_Parameter%100; - new_value = Submenu_Value * mult_by; + if (fabs(Submenu_Value) < smallest_allowed_number) { + printf ("small\n"); + if (Submenu_Value < 0.0) { + new_value = -smallest_allowed_number * mult_by; + } else { + new_value = smallest_allowed_number * mult_by; + } + } else { + new_value = Submenu_Value * mult_by; + } + + g_print_debug("chan %d, Submenu_Value %e, mult_by %e, new_value %e\n", channel, Submenu_Value, mult_by, new_value); switch (Submenu_Numeric_Parameter-channel) { case Show_frequency: -- cgit