From 5cb33d9fe5a65b681d1dbe131c9b1c6c0a2156ce Mon Sep 17 00:00:00 2001 From: root Date: Thu, 1 Jan 1970 09:53:54 +0900 Subject: multi-attenuator control using PCB 244A --- device-functions.c | 11 +++++++++-- 1 file 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 { -- cgit