From 272c3604bab1715c47b9eca8cbac172071015c0d Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 1 Jan 2000 01:03:05 +0900 Subject: Only ignore polarity when shown to user. Use polarity when considering calibration ranges. --- device-functions.c | 26 ++++++++++++++++++++------ menus.c | 4 ++-- parser.c | 6 +++++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/device-functions.c b/device-functions.c index 81bf1d9..56a6205 100644 --- a/device-functions.c +++ b/device-functions.c @@ -260,11 +260,6 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w int entry; int actual_pol; - // for CH2 of AVR-D3-B-MS1 - if (globals.Flash.ignore_ampl_polarity[channel]) { - new_ampl = fabs(new_ampl); - } - if (!globals.Flash.voltage_enabled[channel] && !globals.Flash.current_enabled[channel]) { return Unrecognized; } @@ -274,6 +269,17 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w return InvalidChannel; } + + /* if coupled polarities, as in -ESF units, update CH2 based on CH1 */ + if ((channel==1) && (globals.Flash.ignore_ampl_polarity[1])) { + // flip CH2 polarity if necessary + if ((globals.ChannelState[0].amplitude * new_ampl) < 0.0) { + new_ampl *= -1.0; + } + } + + g_print_debug ("ch %d, ampl %e\n\r",channel,new_ampl); + /* keep "-0" in negative area, to avoid using zeroed positive data */ if ( new_ampl<=smallest_allowed_number && new_ampl>=-smallest_allowed_number @@ -443,7 +449,7 @@ 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("ampl range %d, word %d\n",relay_range,word_out); + g_print_debug("chan %d, ampl range %d, word %d, pol %d\n",channel,relay_range,word_out,actual_pol); globals.Changes.update_amp=YES; @@ -468,6 +474,14 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w Set_Delay(0,0,0,channel,globals.ChannelState[channel].delay); Set_rise_time(0,0,0,channel,globals.ChannelState[channel].rise_time); + /* if coupled polarities, as in -ESF units, update CH2 based on CH1 */ + if ((channel==0) && (globals.Flash.ignore_ampl_polarity[1])) { + // flip CH2 polarity if necessary + if ((globals.ChannelState[0].amplitude * globals.ChannelState[1].amplitude) < 0.0) { + Set_Amplitude(0,0,0,0,0,0,0,1,globals.ChannelState[1].amplitude,1); + } + } + return OK; } diff --git a/menus.c b/menus.c index d205812..f717508 100644 --- a/menus.c +++ b/menus.c @@ -1102,12 +1102,12 @@ static void Display_Number_on_LCD(int Is_Item_Visible,int LCD_row,int LCD_col,ch break; case Show_amplitude: - Submenu_Value=globals.ChannelState[channel].amplitude; - if (globals.Flash.ignore_ampl_polarity[channel]) { show_plus_sign=NO; + Submenu_Value=fabs(globals.ChannelState[channel].amplitude); } else { show_plus_sign=YES; + Submenu_Value=globals.ChannelState[channel].amplitude; } if (globals.Flash.voltage_enabled[channel]) { diff --git a/parser.c b/parser.c index 5c66167..ec8b563 100644 --- a/parser.c +++ b/parser.c @@ -1774,7 +1774,11 @@ static int Go_ampl_26(gchar** response, int channel, char *parameter,char *units } else if (globals.ChannelState[channel].amp_mode==amp_mode_amplify) { return query_string(response, "AMP"); } else { - return query_float(response, globals.ChannelState[channel].amplitude); + if (globals.Flash.ignore_ampl_polarity[channel]) { + return query_float(response, fabs(globals.ChannelState[channel].amplitude)); + } else { + return query_float(response, globals.ChannelState[channel].amplitude); + } } break; -- cgit