Announcement

Collapse
No announcement yet.

LINK/ANTILINK (Selector)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • LINK/ANTILINK (Selector)

    I apologize if this is simple to do but I'm having a little trouble with it. Basically, I want a selector to choose between 4 fan settings (Off, Low, Med, High). I tried doing this with variables and logic, but I'm having a few issues.

    I have 3 button images and 3 digital outputs corresponding to the 3 speeds. The button images set to trigger output works fine. Trying to have the button images change variables can work, but if I do it this way, the button images do not reflect the status changes in the outputs. Also, I can't seem to get more than one THEN statement to fire per each function. For example:

    If(fan_var == 1){
    fan_low = on;
    fan_med = off;
    fan_high = off;
    }

    This won't work for me. It will only trigger the first statement. I have to set it up like:

    if(fan_var == 1){
    fan_low = on;
    }
    if(fan_var == 1){
    fan_med = off;
    }
    if(fan_var == 1){
    fan_high = off;
    }

    Doing it this way, the button images won't change with the outputs. I have tried doing it with just boolean logic based on the outputs, like:

    if(fan_low == true){
    fan_med = false;
    }

    if(fan_low == true){
    fan_high = false;
    }

    The button images seem to work this way, but the issue here is that it doesn't like it when the state changes because the next setting will be true before the previous setting is turned off.

    Anyway, sorry if this is confusing. Basically, I'm looking for a break-before-make selector where the button images (primary/secondary) will reflect the changes made to their respective digital outputs. Like:

    //if off, turn others off, then turn on
    if(fan_low.downclick == true && fan_low.output == false){
    fan_med.output = false;
    fan_med.display_button = secondary;
    fan_high.output = false
    fan_high.display_button = secondary;
    fan_low.output = true;
    fan_low.display_button = primary;
    }

    //if on, turn off
    if(fan_low.downclick == true && fan_low.output == true){
    fan_low.output = false;
    fan_low.display_button = secondary;
    }

    Thanks for any help or insight you guys can bring.

  • #2
    I've had similar problems with multiple then statements. You're looking for 'radio button' type of operation. It can be done currently, but it's not as pretty as it could be. I'll look for what I have (related) tomorrow, when I have more time. I remember not using boolean variables, I used numeric ones, and I think I set variables in the loop and not in the 'then' statement. Like I said, I'll check tomorrow. I'm sure the multiple then statement thing will get sorted out, I just wanted to confirm you're on the right track with your thinking. I think I reported this as a bug, but I'll check that thread.
    It's been a while...

    Comment


    • #3
      I got a little closer by doing it like this:

      fanlow_button.downclick: fan_var = 1
      fanlow_button.upclick: fanlow_output = ON

      fanmed_button.downclick: fan_var = 2
      fanmed_button.upclick: fanmed_output = ON

      fanhigh_button.downclick: fan_var = 3
      fanhigh_button.upclick: fanhigh_output = ON

      if(fan_var != 1){
      fanlow_output = OFF
      }

      if(fan_var != 2){
      fanmed_output = OFF
      }

      if(fan_var != 3){
      fanhigh_output = OFF
      }

      The downclick on each button will change the fan_var which will then turn off whichever output was on before the upclick turns the output on. The only issue here is that the button image will still not match the output. I think the primary/secondary is only tied to the downclick side of the button image. If I have the downclick trigger the output, then using a function to trigger the output will cause the image to change but then I won't be able to OFF the other outputs.

      Thanks again for your help.

      Comment

      Working...
      X