PDA

View Full Version : Simple PC Menu System with Serin2



Tom Gonser
- 2nd April 2005, 23:31
I have a serial configuration screen I want to build where a person can enter a # and have that number be acted upon by my program. The problem is I can't figure out how to get the PIC to know what number I am pushing..

Here is the routine:

settings:
LCDout $fe, 1
LCDout $fe, 2
LCDout $fe, L1, "You must use PC to"
LCDout $fe, L2, "view menu and make"
LCDout $fe, L3, "changes there."
LCDout $fe, L4, "Use 9600b to connect"
serout2 AGPSout, PC96,[27,91,50,74] ' clear screen vt-100
while Set_Item <> 9
serout2 AGPSout, PC96,[27,91,50,59,51,72] ' 50 = 2 th row, 3rd column
serout2 AGPSout, PC96,["Enter 'A' and a value to change passthrough mode."]
serout2 AGPSout, PC96,[27,91,52,59,51,72] ' 52=4 th row, 3rd column
serout2 AGPSout, PC96,[" A - 1 = Passthru turned on"]
serout2 AGPSout, PC96,[27,91,53,59,51,72] ' 5 th row, 3rd column
serout2 AGPSout, PC96,[" A - 2 = Passthru turned off"]
serout2 AGPSout, PC96,[27,91,54,59,51,72] ' 5 th row, 3rd column
serout2 AGPSout, PC96,[" A - 7 = Nothing"]
serout2 AGPSout, PC96,[27,91,55,59,51,72] ' 5 th row, 3rd column
serout2 AGPSout, PC96,[" A - 9 = Exit System"]
Serin2 AGPSin, PC96,[HEX Set_item]
Set_item = Set_item - $30
If Set_item = 1 then
LCDout $fe, 1
LCDout $fe, 2
LCDout $fe, L1, "selected 1"
serout2 AGPSout, PC96,[27,91,57,59,57,72] ' 5 th row, 3rd column
serout2 AGPSout, PC96,["TracID Passthrough is ON"]
passthru = 1
PAUSE 1000
endif
if Set_item = 2 then
LCDout $fe, 1
LCDout $fe, 2
LCDout $fe, L1, "selected 2"
serout2 AGPSout, PC96,[27,91,57,59,57,72] ' 5 th row, 3rd column
serout2 AGPSout, PC96,["TracID Passthrough is OFF"]
passthru = 0
PAUSE 1000
endif

if Set_item = 9 then
LCDout $fe, 1
LCDout $fe, 2
LCDout $fe, L1, "Exiting Setup"
serout2 AGPSout, PC96,[27,91,50,74] ' clear screen vt-100
serout2 AGPSout, PC96,[27,91,49,59,57,72] ' 5 th row, 3rd column
serout2 AGPSout, PC96,["Exiting Setup"]
pause 1000
bmenu =1
endif
wend

Set_item = 0
return


It USED to work when I had the routine wait for an "A" before it accepted a number value, but now that I removed the WAIT ("A"), var, and am going direclty for looking at what the user types, it is not matching anything. And I don't want to have to type an "A" before the number I want - I just want them to enter a number...

If FIGURED that if I captured HEX value of the key, and subtracted $30 from it, I'd get a number.. it doesn't seem to work that way

Anyone have a better way to do this?

Tom

mister_e
- 2nd April 2005, 23:43
Read carefully the PBP manual under the SERIN2 statement. You'll discover DEC modifier. That will do the job for you. Play with DEC2

Tom Gonser
- 3rd April 2005, 08:27
PERFECT!! DEC1 is what I was looking for. Thanks. Amazing how it can be right there on the page.. and not be seen..

Tom