BS2 PBasic Variable Question - Serial LCD Backpack #117
Just Jeff
Posts: 36
Hello,
I have a PBasic / code question relating to a Peter Anderson #117 LCD serial backpack connected to a BS2 and maybe somebody on here has some experience with this issue.
Trying to pass the contents / results of a variable in PBasic on a BS2 to the LCD and am confused;
Code snippets...
This works!...
SEROUT LCDPin, 84, ["?y2?x11Stop"] 'Works and displays the desired "Stop"
This doesn't....
Var1 VAR WORD
Var1 = Stop
SEROUT LCDPin, 84, ["?y3?x00Var1"] 'Does not work, how can I do this?
Thank you for any assistance!!!
note.... The "?y2?x11.. are commands that clear the display, position the cursor in x & y location etc. and they all work perfectly
I have a PBasic / code question relating to a Peter Anderson #117 LCD serial backpack connected to a BS2 and maybe somebody on here has some experience with this issue.
Trying to pass the contents / results of a variable in PBasic on a BS2 to the LCD and am confused;
Code snippets...
This works!...
SEROUT LCDPin, 84, ["?y2?x11Stop"] 'Works and displays the desired "Stop"
This doesn't....
Var1 VAR WORD
Var1 = Stop
SEROUT LCDPin, 84, ["?y3?x00Var1"] 'Does not work, how can I do this?
Thank you for any assistance!!!
note.... The "?y2?x11.. are commands that clear the display, position the cursor in x & y location etc. and they all work perfectly
Comments
Try this:
SEROUT LCDPin, 84, ["?y3?x00"], DEC Var1 ' this should print your variable as decimal. A word is too small for a string.
Basic Stamps don't have string variables per se, so if you want to print a "text" variable you need to define an array and loop thru it printing one byte at time.
e.g. myList VAR Byte(10) ' Create a 10-byte array. (see pages 87-88 of the manual)
A WORD only holds two bytes so even if this were legal, it wouldn't hold four characters:
Var1 VAR WORD
Var1 = Stop
If you want to print a constant, define it using DATA - remember you only have 26 bytes of variable space.
Martin_H do you by chance have any examples of menus that you have worked out that you wouldn't mind sharing?... Needing some inspiration!
The program CBA Say It Demo.BSE uses the SayIt module to obtain voice commands which are then displayed in the LCD. So it is a voice menu system which might be close enough to be helpful to you. This is a multi bank program for the BS2E and the second program is my compass module program. You can pretty much ignore that, but I included it so you can see the whole program.
CBA Say It Demo.bse
Hm55bCompass.BSE
Hope you find this helpful.
Martin
Thanks!!!!!!