diff options
-rw-r--r-- | device-functions.c | 26 | ||||
-rw-r--r-- | menus.c | 4 | ||||
-rw-r--r-- | 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; } @@ -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]) { @@ -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; |