summaryrefslogtreecommitdiff
path: root/device-functions.c
diff options
context:
space:
mode:
authorroot <root@avtech.domain.avtechpulse.com>1970-01-01 09:36:06 +0900
committerroot <root@avtech.domain.avtechpulse.com>1970-01-01 09:36:06 +0900
commita26a57876a1c33b426e7ec080a29ea962a6d7924 (patch)
tree4475f9d91a8544f29e8782b00218dcc6a9a4fe86 /device-functions.c
parent5cb33d9fe5a65b681d1dbe131c9b1c6c0a2156ce (diff)
turn output off when switching attenuator ranges
Diffstat (limited to 'device-functions.c')
-rw-r--r--device-functions.c25
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;
}
}