diff options
-rw-r--r-- | device-functions.c | 25 | ||||
-rw-r--r-- | globals.h | 2 |
2 files changed, 21 insertions, 6 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; } } @@ -281,7 +281,7 @@ unsigned long long ms_timer (void); typedef struct { int parallel_DAC_reg[8]; long shift_reg_out[num_out_SRs]; - long last_relay_driver_settings[3]; + long last_relay_driver_settings[4]; int oper_enable_register; /* for stat:enable command */ int ques_enable_register; /* for stat:enable command */ int avrq_reg; |