diff options
-rw-r--r-- | device-functions.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/device-functions.c b/device-functions.c index fb6ea45..f79017c 100644 --- a/device-functions.c +++ b/device-functions.c @@ -319,13 +319,20 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w 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!) - // use I2C driver in future? if (atten_range == 0) { set_shiftreg_bits(SR_2, XTR_POS + 1, ONE_BIT, BIT_HIGH); } else { set_shiftreg_bits(SR_2, XTR_POS + 1, ONE_BIT, BIT_LOW); } + } else if (attenuator_count(channel) > 1) { + + // octal relay driver is inverted + if ((atten_range < 0) || (atten_range >= max_attens)) { + I2C_Write(PCF8574+Octal_Relay_Driver,0xff); + } else { + int atten_ctl = ~((1 << (atten_range+1)) - 1); + I2C_Write(PCF8574+Octal_Relay_Driver, atten_ctl); + } } } else { |