summaryrefslogtreecommitdiff
path: root/device-functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'device-functions.c')
-rw-r--r--device-functions.c26
1 files changed, 20 insertions, 6 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;
}