button command mixt up


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default button command mixt up

    Hello,
    same program as I posted before, Decided to add the button command. used it many times before and with success. But this time it keep changing. It keep flipping through the menu as if the button was pressed. I tried pulling up and down but no difference, thats whats odd.
    Code:
    GetModeOfOperation:
    
    	Lookup Op_Mode, [55,65],Operation_Mode
    	
    	Select Case Operation_Mode
    	Case 55 								
    		lcdout $FE,1,  " Charger Mode "
    	Case 65 								
    		lcdout $FE,1,  " Recycle Mode"
    	End Select
    	
    		lcdout $FE,$C0, "Next or Select"
    		pause 200
    		
    		if Selection=1 then return
    		
    		 BUTTON Next1,1,100,10,B0,0,Button_pressed  
    		Button_pressed:  'if Next1=1 then Op_Mode = Op_Mode + 1
    		Op_Mode = Op_Mode + 1
    		
    		if Op_Mode > 1 then Op_Mode = 0
    		Goto GetModeOfOperation
    
    Return

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: button command mixt up

    Hi,

    You wrote :

    IF button NOT pressed Opmode = opmode +1 ( using goto Button_pressed )

    IF button pressed Opmode = opmode +1 ( NOT jumping )

    so, it's quite a normal behaviour ...

    just TRY

    Code:
     
       B0 = 0
       BUTTON Next1,1,100,10,B0,1,Button_pressed
      
    GOTO Button_not_pressed
    
    Button_pressed:   'if Next1=1 then Op_Mode = Op_Mode + 1
    		Op_Mode = Op_Mode + 1
    		
    		if Op_Mode > 1 then Op_Mode = 0
    
    Button_not-pressed:
     
    Goto GetModeOfOperation
    It's not written in the smartest way (!) ... but will help you to understand what's going on. It also effectively uses the debounce tempo ... ( if condition is NOT true, there's NO debounce time ( obvious, but not told in the manual ...)

    remember B0 has to be ( most of time ) reset just before BUTTON command ...


    BTW ... using the auto-repeat mode just to toggle the " mode " value looks a bit overkill ( dangerous ? )... as you already are in a loop ...
    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: button command mixt up

    Hi,

    I tried you code, not much difference except for the extra empty function Button_not-pressed:
    I tried these four config, but every time the menu cycles constanly between the options...

    BUTTON Next1,1,100,10,B0,1,Button_pressed
    BUTTON Next1,1,100,10,B0,0,Button_pressed

    BUTTON Next1,0,100,10,B0,1,Button_pressed
    BUTTON Next1,0,100,10,B0,0,Button_pressed

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