Group - ungroup of commands


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Group - ungroup of commands

    LE : Solution (not so elegant, but working) :
    Code:
    Main:
    ;reading buttons on row 1
    PortA.0 = 0
    TrisA.1 = 1
    pause 10
    if porta.2 = 0 then
      portb.1 = 1
    while porta.2=0 :  wend
      portb.1 = 0 
    endif
    
    if porta.3 = 0 then
      portb.2 = 1
    while porta.3=0 :  wend
      portb.2 = 0
    endif
                    
    if porta.4 = 0 then
      portb.3 = 1
    while porta.4=0 : wend
      portb.3 = 0
    endif
    
    PortA.0 = 1
    TrisA.1 = 0
    
    
    ;reading buttons on line 2    
    Portb.0 = 0
    TrisA.1 = 1
    pause 10
    if porta.2 = 0 then
      portb.4 = 1
    while porta.2=0 :  wend
      portb.4 = 0 
    endif
    
    if porta.3 = 0 then
      portb.5 = 1
    while porta.3=0 :  wend
      portb.5 = 0
    endif
                    
    if porta.4 = 0 then
      portb.6 = 1
    while porta.4=0 : wend
      portb.6 = 0
    endif
    
    Portb.0 = 1
    TrisA.1 = 0
        
    Goto main

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Group - ungroup of commands

    Hi,
    It's possible to refresh this status ? I guess not ..
    Of course there is, same way as you got the status in the first place, here with a little twist:
    Code:
    Main:
    GOSUB GetStatus    ' Get inital state
    
    Select Case status_1
    
    Case 12
      PortB.1 = 1
      WHILE status_1 = 12
      GOSUB GetPortStatus    ' <--- Now we'll update status_1 so we know when the button is released.
      WEND
      PortB.1 = 0 
    
    '.... And so on
    '.... and so on
    '.... and so on
    
    Goto Main
    
    GetPortStatus:
       status_1 = PortA & %00011100
    RETURN
    /Henrik.

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Group - ungroup of commands

    Wow ! Nice ! Thanks !
    How far am I from this technique ...

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Group - ungroup of commands

    Just stick with it.
    Make sure you always try to really think what's going on, think what the program is actually doing and what the cause of that is.

    Like, OK, when the value of this or that variable is 12 I'm going to loop around here untill the value is no longer 12 - that's fine. What makes the variable change value? Well nothing because I'm not evaluating anything within the loop. Duh, I need to make sure the value CAN change by reading the port and evaulate the result WITHIN the loop, not outside of it....

    /Henrik.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts