From 5116292db1fb4003980fa0a4d828eeb8bbf561bb Mon Sep 17 00:00:00 2001 From: root Date: Thu, 1 Jan 1970 09:08:20 +0900 Subject: add attenuator_count function --- device-functions.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/device-functions.c b/device-functions.c index aed298d..fb6ea45 100644 --- a/device-functions.c +++ b/device-functions.c @@ -178,6 +178,19 @@ void set_dac(int dac, int word) } +static int attenuator_count (int channel) +{ + int i; + i = 0; + + while ((i < max_attens) && (globals.Flash.attenuators[channel][i] > 0.0)) { + ++i; + } + + return i; +} + + int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int word_override,int range_override, int switch_range_only,int channel,float new_ampl,int called_from_set_pw) { @@ -303,7 +316,7 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w } // Are attenuators used? - if (globals.Flash.attenuators[channel][0] > 0.0) { + if (attenuator_count(channel) == 1) { // deal with attenuator range - haven't done for CH2 yet // only implement one attenuator so far (range 0), out of possible max_attens (8!) -- cgit