PDA

View Full Version : Serout question



Tobias
- 2nd June 2009, 00:39
I have a 4x40 LCD from NewHaven. The first line is a header that changes based on a few conditions. The second, third, and fourth row contain time or rpm variables that can be edited by the user.

I have the code working pretty good yet I want to format the variables based on the type of data, meaning time or rpm. With time I want to have X.XXX and rpm X,XXX.

I can parse out the second and thousand rpm values plus the remaining time or RPM. My question is how can I minimize the SEROUTS. Can I write the formatted time/rpm to an Array variable that contains the decimal or comma then SEROUT the array values? Instead of having a bunch of If/Thens that direct the code to a specific SEROUT?

Archangel
- 2nd June 2009, 03:00
I have a 4x40 LCD from NewHaven. The first line is a header that changes based on a few conditions. The second, third, and fourth row contain time or rpm variables that can be edited by the user.

I have the code working pretty good yet I want to format the variables based on the type of data, meaning time or rpm. With time I want to have X.XXX and rpm X,XXX.

I can parse out the second and thousand rpm values plus the remaining time or RPM. My question is how can I minimize the SEROUTS. Can I write the formatted time/rpm to an Array variable that contains the decimal or comma then SEROUT the array values? Instead of having a bunch of If/Thens that direct the code to a specific SEROUT?

serout portb.0,t2400,[$FE,2,"time is",MyVar.0,":",MyVar.1,":",MyVar.2] or something to that effect

Charles_Leo
- 2nd June 2009, 21:13
You can easily store a single character (comma or decimal point) in a byte variable.




IF type = rpm THEN
delimiter = ","
value = rpmvalue
ELSE
delimiter = "."
value = timevalue
ENDIF

DEBUG DEC (value/1000), delimiter, DEC3 value

Tobias
- 3rd June 2009, 00:58
Thanks that makes it alot simpilier.