PDA

View Full Version : button command mixt up



lerameur
- 24th February 2011, 04:04
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.


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

Acetronics2
- 25th February 2011, 12:42
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 ... :rolleyes:

just TRY




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 ... :D
Alain

lerameur
- 25th February 2011, 18:01
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