diff options
Diffstat (limited to 'device-functions.c')
-rw-r--r-- | device-functions.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/device-functions.c b/device-functions.c index f79017c..ac4a9b4 100644 --- a/device-functions.c +++ b/device-functions.c @@ -316,22 +316,37 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w } // Are attenuators used? + int atten_ctl = 0; + if (attenuator_count(channel) == 1) { // deal with attenuator range - haven't done for CH2 yet if (atten_range == 0) { - set_shiftreg_bits(SR_2, XTR_POS + 1, ONE_BIT, BIT_HIGH); + atten_ctl = BIT_HIGH; } else { - set_shiftreg_bits(SR_2, XTR_POS + 1, ONE_BIT, BIT_LOW); + atten_ctl = BIT_LOW; } + + set_shiftreg_bits(SR_2, XTR_POS + 1, ONE_BIT, atten_ctl); + } 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); + atten_ctl = 0xff; } else { - int atten_ctl = ~((1 << (atten_range+1)) - 1); - I2C_Write(PCF8574+Octal_Relay_Driver, atten_ctl); + atten_ctl = ~((1 << (atten_range+1)) - 1); + } + + I2C_Write(PCF8574+Octal_Relay_Driver, atten_ctl); + } + + if ( (globals.Registers.last_relay_driver_settings[3] != atten_ctl)) { + + globals.Registers.last_relay_driver_settings[3] = atten_ctl; + + if (globals.ChannelState[channel].output_state==output_on) { + globals.Flags.force_output_fully_off=YES; } } |