Results 1 to 3 of 3
  1. #1
    25+ Posting Member
    Join Date
    Jan 2009
    Location
    Belgium
    Posts
    61
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Use more then 1 varaible

    Hi i've been using phidget cards and real studio for some time but
    now that it was time for a expansion I thought let me use the Opencockpit card.
    And I can use some help. I want to manage some leds. The leds on or of depend on
    more than 1 function.

    Var 2, Link FSUIPC_IN Offset $3340, Length 4
    var 3, Link FSUIPC_IN offset $092C, length 2
    var 4, link FSUIPC_IN offset $3344, length 4 // need this one also
    {
    L0 = TESTBIT V2,14
    if L0 = 0
    {
    &leds2 = 0
    &leds3 = 0

    }
    else

    L1 = TESTBIT V3,0
    if L1 = 1
    {
    &Leds2 = 0
    &leds3 = 0

    }
    else
    {
    &leds2 = 1
    &leds3 = 1
    &Leds4 = 1

    }
    }
    var 5, name Leds2 link iocard_out, output 15
    var 6, name Leds3 link iocard_out, output 13

    I seem to miss something because it's not working. I hope some one can help
    to show how to use more then 1 varaible to manage the led.
    regards and thnx,
    henri

  2. #2
    500+ This must be a daytime job kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    698
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Use more then 1 varaible

    Hi henri,

    It does not work because your program does nothing if Var 2 or Var 3 changes value.
    You have to take an approach like this (call a subrutine if one of the related variables changes, and in that subroutine you set the leds according to the states of these variables):

    Code:
    Var 2, Link FSUIPC_IN Offset $3340, Length 4 
    {
      CALL &CtrlLeds
    }
    
    var 3, Link FSUIPC_IN offset $092C, length 2 
    {
      CALL &CtrlLeds
    }
    
    var 4, link FSUIPC_IN offset $3344, length 4 // need this one also
    {
      CALL &CtrlLeds
    }
    
    
    Var 10 Link SUBRUTINE Name CtrlLeds
    {
      L0 = TESTBIT V2,14
      if L0 = 0
      {
        &leds2 = 0
        &leds3 = 0
      }
      else
      {
        L1 = TESTBIT V3,0
        if L1 = 1
        {
          &Leds2 = 0
          &leds3 = 0
        }
        else
        {
          &leds2 = 1
          &leds3 = 1
    //      &leds4 = 1   not defined ?
        }
      }
    }
    
    var 5, name Leds2 link iocard_out, output 15
    var 6, name Leds3 link iocard_out, output 13
    And I think you have to take Var 4 into account as well (in the subroutine).


    regards,
    Nico

  3. #3
    25+ Posting Member
    Join Date
    Jan 2009
    Location
    Belgium
    Posts
    61
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Use more then 1 varaible

    OK so that's how it works. Great and thanks for pointing the right direction.
    regards,
    Henri