Sending serial messages to LCD
Archiver
Posts: 46,084
Hi everybody,
This is my first time using the group so be gentle with me!
I need to send messages to a serial display from scott edwards - no
problem I hear you say! In total there are about 20 different
messages that need to be called depending on the status of the I/O
pins. At the moment I have to re-write the SEROUT command for every
message, which is messy and time consuming. Is it possible to store
the messages, e.g. 'cover open' in a string and have a GOSUB to the
sending routine. In theory this would save on program space and my
fingers, it would also make it easier to select different languages
from a menu.
Any suggestions?
Thanks
Jon
This is my first time using the group so be gentle with me!
I need to send messages to a serial display from scott edwards - no
problem I hear you say! In total there are about 20 different
messages that need to be called depending on the status of the I/O
pins. At the moment I have to re-write the SEROUT command for every
message, which is messy and time consuming. Is it possible to store
the messages, e.g. 'cover open' in a string and have a GOSUB to the
sending routine. In theory this would save on program space and my
fingers, it would also make it easier to select different languages
from a menu.
Any suggestions?
Thanks
Jon
Comments
jon_millard@p... writes:
> I need to send messages to a serial display from scott edwards - no
> problem I hear you say! In total there are about 20 different
> messages that need to be called depending on the status of the I/O
> pins. At the moment I have to re-write the SEROUT command for every
> message, which is messy and time consuming. Is it possible to store
> the messages, e.g. 'cover open' in a string and have a GOSUB to the
> sending routine. In theory this would save on program space and my
> fingers, it would also make it easier to select different languages
> from a menu.
>
> Any suggestions?
You can store your strings in DATA statements, terminating each with a zero.
Then, create a subroutine that takes the address of the string (its label)
and reads each character from the EE until a zero is found. I use this
technique all the time.
addr VAR Word
char VAR Byte
Msg1 DATA "Cover open", 0
Msg2 DATA "The BASIC Stamp rules!", 0
Start:
addr = Msg2
GOSUB PrintIt
END
PrintIt:
READ addr, char
IF char = 0 THEN PrintItDone
SEROUT Spin, Sbaud, [noparse][[/noparse]char]
addr = addr + 1
GOTO PrintIt
PrintItDone:
RETURN