Sending Text to LCD(A Data Variable)
DiablodeMorte
Posts: 238
Ok.. First I want to say that I did search the forum for an answer and that I'm not completly new to Basic Stamp's but I am new.
Anyway... Back to my problem.
I have a LCD hooked up to my basic stamp. Now that works fine. I can turn it off. Clear it, Turn it back on, ouput strings manually, and output numbers but What i can't seem to figure out is how to output a DATA variable. I looked at the scrolling text tutorial but it doesn't work for my special LCD. Everthing else does. Anyhow. When i try to send a data variable to the LCD i only get the first Letter and when i try to declare something like:
The stamp editor gets mad and says that i can only have 1 char in the ("")
Oh, and the idea behind the project is taht the basic stamp reads a string from the serial port(figured that out) and then outputs the string it gets to the lcd screen(like a text message)
Thanks in advance,
DiablodeMorte
Anyway... Back to my problem.
I have a LCD hooked up to my basic stamp. Now that works fine. I can turn it off. Clear it, Turn it back on, ouput strings manually, and output numbers but What i can't seem to figure out is how to output a DATA variable. I looked at the scrolling text tutorial but it doesn't work for my special LCD. Everthing else does. Anyhow. When i try to send a data variable to the LCD i only get the first Letter and when i try to declare something like:
teststring var word teststring = "foo"
The stamp editor gets mad and says that i can only have 1 char in the ("")
Oh, and the idea behind the project is taht the basic stamp reads a string from the serial port(figured that out) and then outputs the string it gets to the lcd screen(like a text message)
Thanks in advance,
DiablodeMorte
Comments
·· The easiest way to handle this is to read the data one character at a time from the serial port, and send each character to the LCD as it comes in.· 1 variable used, and simpler code.· Now, the other way is to use an array, but I don't know how long the string is you need to handle, so it's hard to say what the best approach is.· Just out of curiosity, which model BASIC Stamp do you have?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Regards,
DiablodeMorte
You can't assign strings to variables -- as you've seen you can only hold a single character.· What you can do is point to a string stored in a DATA statement and go from there.· I tend to use z-strings so that I can embed carriage returns; like this:
Msg1···· ·DATA···"BASIC Stamp", 0
Now I need a pointer to the string and a variable to hold the character being "printed" on the LCD:
eePntr··· VAR··· Word
char····· VAR··· Byte
When I want to "print" to the LCD I assign the point to the string I want printed, and then call the subroutine:
Main:
· eePntr = Msg1
· GOSUB Print_To_LCD
... and here's the subroutine:
Print_To_LCD:
· DO
··· READ eePntr, char
··· IF (char = 0) THEN EXIT
··· GOSUB LCD_Write·············· ' <-- adjust for your Stamp model
··· eePntr = eePntr + 1
· LOOP
· RETURN
You should be able to adapt this strategy to your program.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
·· Well, you specified that you wanted to take characters received from the serial port and send them to the LCD.· Do you have code for receiving characters from the serial port?· Do you have code for writing to the LCD?· The best thing for you to do at this point is work on each individual task, then merge them.· An example of writing to the LCD is listed above.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Ok.. Now i need some more help. Your code works fine but I need help. I need to get the variable(msg_data) from:
and Put it INTO the contents of the
Msg1 DATA variable. How would I do this?
Woops.. Perhaps I didn't make my self clear. I do have the code to recieve the data and the code to output to the LCD screen..
Oh, and the code that you gave me Jon Williams worked. Thank you very much.
As for My brand: I have no idea :P (It's annoying how lcd's don't have labels)
Post Edited (DiablodeMorte) : 7/6/2005 7:47:59 PM GMT
You should do this with care and reluctance, though. The on-module EEPROM has about a million write cycles -- after that, locations stop working. While a million sounds like a lot, if you write to the same location every 10 mSec, you can wear it out in a few hours (10,000 seconds, I believe)
Now, most useage of the EEPROM is for writing your program to it. If you update your program once a minute, it will take 114 years to wear it out.
Just be aware, and only write to the EEPROM on a seldom basis. Now if you NEED to write to the EEPROM more often than that, you CAN get an external SPI interfaced EEPROM (like the 24L640 (?)) and use that. If you use it up, plug in a new one.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com