summaryrefslogtreecommitdiff
path: root/device-functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'device-functions.c')
-rw-r--r--device-functions.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/device-functions.c b/device-functions.c
index e5fbeea..2bfd784 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -391,6 +391,8 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w
}
}
+ g_print_debug("ampl range %d, word %d\n",relay_range,word_out);
+
globals.Changes.update_amp=YES;
globals.ChannelState[channel].amplitude=new_ampl;
@@ -883,6 +885,8 @@ int Set_Delay(int check_possible_only,int word_override,int range_override,int c
control_pcb107(globals.Flash.I2C_port_for_CH2_delay,globals.Flash.delay_dac[channel],word_out,relay_range);
}
+ g_print_debug("delay range %d, word %d\n",relay_range,word_out);
+
globals.ChannelState[channel].delay=set_delay;
Set_Update_Chans();
@@ -2477,6 +2481,12 @@ int Set_VI_Del_Cal(int parameter,int channel,int calibration_point_number)
}
+static int linear_interpolation (int x1, int x2, float y1, float y2, float y_need)
+{
+ return (int) ( (y_need - y1) / (y2 - y1) * (float) (x2 - x1) ) + x1;
+}
+
+
int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int *relay_range,int *atten_range,
int *UseNegData,int *entry,int *word_out,int *actual_pol)
{
@@ -2857,8 +2867,7 @@ int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int
inverse_word_out+=1/((float) pwl_vc[index]);
*word_out=(int) (1.0/inverse_word_out);
} else {
- *word_out = (int) ( fraction * (float) (pwl_vc[index] - pwl_vc[index+1]) );
- *word_out+=pwl_vc[index];
+ *word_out = linear_interpolation (pwl_vc[index], pwl_vc[index+1], pwlamp1, pwlamp2, tweaked_use_ampl);
}
}
}