|
Hi,
I was having some problems in a program I'm writing in PbForth and it seems that
it could be related to the way I communicate thru IR. I use the Lego remote
control.
I joined the following code to demonstrate. I use the word 'getHeader' from
Ralph Hempel, which I call repeatedly. I added a few words so the program would
beep and display '0' before the word EKEY and display 999 right after the word
EKEY. Now, it seems that once in a while, the program gets stuck on the word
EKEY until a new character is received. In other words, the display shows 0
instead of 999, until I hit a key again.
I test the program by typing 10 t then I use the remote to send a signal to the
RCX. Most of the time it beeps and displays 999 but sometimes it displays 0
only.
Am I missing something here? Any ideas?
Thanks
Mario
Here's the test program
MARKER test
: SP! ( --- ) BEGIN DEPTH WHILE DROP REPEAT ;
: blip 0 16387 SOUND_PLAY ;
HEX
0 VALUE headerState
: getHeader ( -- f )
EKEY? \ Check for IR character
IF
LCD_CLEAR LCD_REFRESH blip \ Clears display and beeps
3002 0 3001 LCD_NUMBER LCD_REFRESH \ Displays 0 before EKEY
EKEY \ If there is one, get it
3002 3E7 3001 LCD_NUMBER LCD_REFRESH \ Displays 999 after EKEY
headerState 0 =
IF 55 = IF 1 TO headerState
ELSE 0 TO headerState
THEN
ELSE
headerState 1 =
IF FF = IF 2 TO headerState
ELSE 0 TO headerState
THEN
ELSE
headerState 2 =
IF 0 = IF 3 TO headerState
ELSE 0 TO headerState
THEN
THEN THEN THEN
THEN
3 headerState = ;
DECIMAL
: t1 0 DO getHeader DROP LOOP ;
: t 0 DO 30000 t1 LOOP SP! ;
10 t
|
|
Message has 1 Reply:
7 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|