Well with 54 reads over the past few weeks, and no replies, there must be some interest in a menu system! My code has a weak interrupt system I am trying to improve, and NOW I need to add something else -- a sub-menu.. Well, it does not work.
I have two buttons - I want to use button 0 as the interrupt from running to go to the menu system. Keep pushing it and cycle through the menus. Find the one you want, and hit Button 1. This works at a high level now. Problem is one of the menus I need to display some options and use these buttons to select THEM too.. In this case, I don't need an interrupt, just to read 0 or 1 from those pins. The following code displays OK, but the buttons do nothing..
I could use a pointer to a template about how folks use buttons for menus.. This is not working..
LCDsetting:
' make the LCD able to program the unit without the PC
I2Cread DPIN, CPIN, Chip1, wpt_loc, [set_wpt] ' waypoint flag storage 0 or 1
I2Cread DPIN, CPIN, Chip1, Pass_loc, [passthru] ' waypoint flag storage 0 ir 1
I2Cread DPIN, CPIN, Chip1, D_baud_loc, [D_baud] ' store address pointer 84 for 9600, 6 for 38400
I2Cread DPIN, CPIN, Chip1, W_baud_loc, [wptbd] ' store address pointer 84 for 9600, 188 for 4800
I2Cread DPIN, CPIN, Chip1, wpt_loc,[set_wpt] ' waypoint flag storage 0 or 1
LCDout $fe, 1
LCDout $fe, 2
LCDout $fe, L1, " Unit Set-up "
LCDout $fe, L2+2,"Waypoint:"
Select case Set_wpt
Case 0
LCDout $fe, L2+13,"off"
Case else
LCDout $fe, L2+13,"Err"
end select
Select Case Wptbd
Case 188
LCDout $fe, L2+13,"4800"
Case 84
LCDout $fe, L2+13,"9600"
Case else
LCDout $fe, L2+13,"Err"
end select
LCDout $fe, L3+2,"Passthru:"
Select case passthru
Case 0
LCDout $fe, L3+13,"off"
Case 1
LCDout $fe, L3+13,"9600"
Case else
LCDout $fe, L3+13,"Err"
end select
LCDout $fe, L4+2,"Download:"
Select Case D_Baud
Case 84
LCDout $fe, L4+13,"9600"
Case 6
LCDout $fe, L4+13,"38,400"
Case else
LCDout $fe, L4+13,"Err"
end select
' menu changes
tempb = 1 ' start with 1
If PORTB.0 = 0 then 'first button is pressed - select category
tempb=tempb+1
if tempb > 3 then tempb = 1
endif
Select case tempb
case 1 ' gpsbaudrate item
LCDout $fe, L2, "X" ' indicate selected item on lcd
LCDout $fe, L3, " " ' indicate selected item
LCDout $fe, L4, " " ' indicate selected item
Case 2 ' passthru mode item
LCDout $fe, L2, " " ' indicate selected item
LCDout $fe, L3, "X" ' indicate selected item
LCDout $fe, L4, " " ' indicate selected item
Case 3 ' download baudrate item
LCDout $fe, L2, " " ' indicate selected item
LCDout $fe, L3, " " ' indicate selected item
LCDout $fe, L4, "X" ' indicate selected item
end select
while PORTB.0 = 1 ' as long as B0 is not pressed to make us move to another line item above:
If tempb = 1 then
select case wptbd 'translate default baudrate
case 188
tempc = 1
case 84
tempc = 2
case 0
tempc = 3
end select
select case tempc
case 1
LCDout $fe, L2+13, "4800" ' display setting
wptbd=188
Set_wpt=1
passthru=0
Case 2
LCDout $fe, L2+13, "9600" ' display setting
wptbd=84
set_wpt=1
passthru=0
Case 0
LCDout $fe, L2+13, "off" ' display setting
wptbd=84
set_wpt=0
Case else
LCDout $fe, L2+13, "Err" ' display setting
end select
If PORTB.1 = 0 then ' second button is pressed - increment options at this level
tempc=tempc+1
if tempc > 3 then tempc = 1
endif
endif
If tempb = 2 then ' passthru mode
select case passthru 'translate default passthru
case 0
tempc = 1
case 1
tempc = 2
end select
select case tempc
case 1
LCDout $fe, L2+13, "On 9600" ' display setting
wptbd=188
passthru=1
set_wpt=0
Case 2
LCDout $fe, L2+13, "off" ' display setting
passthru=0
end select
If PORTB.1 = 0 then ' second button is pressed - increment options at this level
tempc=tempc+1
if tempc > 2 then tempc = 1
endif
endif
If tempb = 3 then ' download baudrate
select case D_baud 'translate default dnlspeed
case 84
tempc = 1
case 6
tempc = 2
end select
select case tempc
case 1
LCDout $fe, L1+13, "9600" ' display setting
D_Baud=84
Case 2
LCDout $fe, L1+13, "38400" ' display setting
D_Baud=6
end select
If PORTB.1 = 0 then ' second button is pressed - increment options at this level
tempc=tempc+1
if tempc > 2 then tempc = 1
endif
endif
wend
Return
Bookmarks