PROPBASIC and DATA statement...
denno
Posts: 223
in Propeller 1
Is it possible to "implant" a constantly changing variable in a DO/LOOP (i.e. a temperature reading from an LM34) into a DATA statement like:
The above DATA statement does "print" on the LCD at the right positions and the right line, but the variable(s), temp_1 and temp_2 spaces are just blank. Bean, any ideas...?
DennO
LCD_data_2 DATA temp_1, posCMD,82,degreeSYM,posCMD,99,temp_2,posCMD,102,degreeSYM,posCMD,115,".",posCMD,135,".",0
The above DATA statement does "print" on the LCD at the right positions and the right line, but the variable(s), temp_1 and temp_2 spaces are just blank. Bean, any ideas...?
DennO
Comments
You can do it like this:
Bean
However, I am trying to "insert" a variable in the middle (2 places actually) of the the following DATA statement...where your "insertion" is at the end of the first LCD_data statement...please note temp_1DEC, temp_2DEC. Is this even possible? I do have another way that does work, but uses 24 SEROUT commands to place (4) variables on 4 different lines of the LCD.
Thanks...DennO
To do multiple values you can either break up the DATA statement into multiple DATA statements, or use offsets.
or
Bean
P.S. Originally I had LCD_data_2[2] and LCD_data_2[12] that was incorrect.
That COMMAND will SEROUT the the LCD_data_2, first, then the LCD_data_2 [2], second, and then the LCD_data_2 [12], and fill in the "11111" and "22222".
That will certainly reduce my coding...space.
In reference to the STACK directive...should one just use STACK 255 and/or is the directive really necessary...?
DennO
After a few trial and errors...aka "UNKNOWN COMMAND",,,I added the extra DATA statements:
LCD_data_2[3] DATA "111"
LCD_data_2[9] DATA "222"
Thanks again..and I am sure, as I move forward in using the PROP...I will have more.
DennO
PropBasic Version 00.01.48 Aug 9, 2018
Finished Compile. 251 Lines Read, 1355 Lines Generated, 0 Warnings, 0 Errors.
Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved
Compiled for i386 Win32 at 08:17:48 on 2009/07/20
Loading Object LCDdisplay_SE
Loading Object LCD_1.spin
LCD_1.spin - Error at (530,13) Expected End of Line, Assembly Conditio
nal, BYTE, WORD, LONG or Assembly Instruction
__LCD_DATA_2[3]_adr LONG 146
____________^
Compiled 665 Lines of Code in 0.017 Seconds
And here is the code that I am trying to run...again thanks for your time...much appreciated...when I uncomment line 101 below, I get the above LCD_1.spin error. When I leave it commented, I get the "UNKNOWN COMMAND"
I made a typo the index needs to be in parens not brackets.
LCD_data_2(3)
You don't need any of those extra DATA lines with the offsets. Those make no sense...
Just do
Again, sorry my bad. I will fix the previous post.
Bean
DennO
You have the comment correct, but the code is not correct.
Bean
There is no need to use STR for 1 digit values. (STR generates a lot of code).
Just do this:
Just be sure to DEC VOLT, "0" if you want to use the value after using WRBYTE to put it in the data string.
That will save a bunch of code...
Bean
I know I can do regular math in a COG, but I am wondering, (first)...why I have to send data as a STR XXXXXXX, X as in the following example: I am quite good at interger math, as that is what is used, as you know in PBASIC. But I find myself, having to do the same with PROPBASIC, to get it to the LCD...
In reading through your 1.48 "rules of the road", I see there is a VAL and a ABS, can't these be used to change a STRING to some decimal value. I know in PBASIC, if I modify something that I want to send to the display, I preface the VAR with DEC(x). I hope I am making since...
As far as the example you gave me, (#2 below), I kept getting ERROR messages, when I was trying to use it for one "digit" to get it into a index DATA statement...instead of using as example the following code...(#1 below)
#1..example Bean, I keep getting an error message with the following code...
#2 example
And, last, are you going to or is there a later "rules of the road" then 1.48? I just think that PROPBASIC is easier to use/learn, along the lines of PBASIC then SPIN...no offence to those that put SPIN language together.
DennO
Print "4 X 2“ will output 4 X 2
Look at an ASCII chart, Print a decimal 13 and you will get a carriage return.
Print a decimal 10 and you will get a line-feed.
Keep in mind, I am writing to a stand alone LCD display, made by Scott Edwards, so one has to tell the display where to print stuff, by a position command...I am not sending stuff to the computer screen....
DenO
Now, the above code will run and place the VAR(s) in the proper locations on the LCD.
But, if I change the code to: to save code space, I get this....ERROR message
And, I am using the INC after a RDLONG command.
So, what am I doing wrong...LOL...DennO
INC adds a value to an integer variable. It's completely different from STR, which converts an integer into a string. There's no general way to replace STR with INC. In the case of a one digit number you might be able to do something like: but that will ONLY work if VOLT is between 0 and 9; other values will fail badly. Also note that this changes VOLT, so if you want to use that value later save it off somewhere. The formatting will also be a bit different from the STR case.
Eric