ElectroLund

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by ElectroLund

  1. Thanks, I resolved by splitting those functions into separate sequences.

    So now I have a helper sequence:

    function LampCheck()
    
       while (1)
          
          //--------------------
          
          // check the lamp current pin
          LampCurrent()
    
    
          // check the lamp power pin
          LampPower()
          
          //--------------------
          // now process the results
    
                // GPIO 1                  GPIO 2
          if (lampCurrent[0] == 0 && lampPower[0]) == 0)
          
             ? "Power not available/disconnected"
             v.lampStates.AddValue(-1)
             
          elseif (lampCurrent[0] == 0 && lampPower[0]) > 435)
          
             ? "Power available, lamp not connected"
             v.lampStates.AddValue(-2)
             
          elseif (lampCurrent[0] > 205 && lampCurrent[0] < 270 && lampPower[0]) > 435)
          
             ? "Power available, lamp off"
             v.lampStates.AddValue(0)
             
          elseif (lampCurrent[0] > 270 && lampPower[0]) > 435)
          
             ? "Power available, lamp on (flashing)"
             v.lampStates.AddValue(1)
             
          else
          
             ? "Other combinations wouldn’t be valid"     
             v.lampStates.AddValue(-3)
             
          endif
          
          ? v.lampStates[0]
          
          //--------------------
          // critical delay!
          
          delay(0.3)  // execute 3 times a second
          
       
       endwhile

     

    This needs to run a couple times a second once started, parallel to the calling sequence.  I understand this is a call for (pun) the BeginSeq() command.

    So here's a sample caller sequence:

     

    beginseq(LampCheck)
    
    ? "started sequence"
    Delay(.8)
    ? "delayed 0.8 seconds"
    Delay(1.4)
    ? "delayed 1.4 more seconds"
    
    endseq(LampCheck)

     

    Yet when I start this caller sequence, it is getting stuck in the LampCheck.  The two sequences aren't running concurrently.