There are several ways, but the easiest is to add some blank spaces after "km/h" so your code instead looks like
LCDOUT $FE,$8D, DEC speed, "km/h "
There are several ways, but the easiest is to add some blank spaces after "km/h" so your code instead looks like
LCDOUT $FE,$8D, DEC speed, "km/h "
Charles Linquist
But that would result in the display moving about.
Better to conditionally add space BEFORE the value to be display eg
If speed < 10 then LCDOUT " " ' 1 space
If speed < 100 then LCDOUT " " ' 1 space
LCDUT DEC speed,"km/h"
IF the speed is 100 or greater then no spaces are prefixed
If the speed is 10-99 then one space will be prefixed
If the speed is below 10 then both conditions will be met and two spaces prefixed resulting the display remaining in a static position on the screen
Keith
www.diyha.co.uk
www.kat5.tv
First of all, I wonder about this line: LCDOUT $FE,$8D, DEC speed, "km/h "
--- > $8D ??? I think you meant $80 (beginning of first line)
Then, if it's the case you can use:
If speed < 100 then X= 1
If speed < 10 then X = 2
LCDOUT $FE,$8D + X, DEC speed, "km/h"
Cleaver!
Whilst that would keep the "km/h" in the same position on the screen it WONT clear text that is previously written which is why you need to print spaces.
With the above code you would get the following
9 would give "9km/h"
49 would give "49km/h"
103 would give "103km/h"
but when the speed drops you would get the following problem due to not clearing the leading digits
87 would give "187km/h" (the "1" not being cleared)
5 would give "185km/h" (both the "1" and the "8" not being cleared)
Last edited by keithdoxey; - 29th July 2007 at 11:29. Reason: keyboard is getting knackered and some letters were missing!!!!
Keith
www.diyha.co.uk
www.kat5.tv
Actually GrandPa your option won't work.
Your logic is good, but you haven't completely thought it thru... (you still had $8D instead of $80 by the way - but forgetting that)...
Suppose you're dropping in speed... 101, 100, 99 <<< and there's the problem...
The last display was 100, you now shift over by one character postition and you display '99' over the top of the '00' part of 100. You haven't erased the '1' so your display goes...
101, 100, 199, 198 etc etc...
Keith hit it in one... but if you don't want a waving km/h display those first... and then just concentrate on the numbers. You can have leading or trailing blanks then (depending if you want left or right numeric justification).
OK... Keith got there first... *smiles*
That makes a change
Normally I type a reply and post it to find that 3 or 4 other people have replied whilst I was typing.
The problem was even worse on one forum when I didnt have access during the day. By the time I got to read the messages there was no point in replying until I had read all messages as invariably someone eles had already said what I was going to!
$80 would indeed be the start of the first line but $8D would be character position 14 on the first line. With a 20 character display this would give space for xxxkm/h to be right justified on the display which is what I suspect sirvo is trying to achieve.Originally Posted by grandpa
Keith
www.diyha.co.uk
www.kat5.tv
Man I learn alot reading this forum!
Where is the above mentioned "$8D" command documented? I had no idea you could do that? I knew you could shift right or left but did not know you could "jump" to a position...
Thanks to everyone for the education!
Bill12780
Hi Bill,
It isnt specifically mentioned in the PBP manual as it depends on the LCD driver chip in your display but for any HD44780 or compatable controller it will work.
Download the datasheet for an HD44780 and look for the section on setting the registers.
DDRAM is the command to look at.
With bit 7 set you are setting where the data sent to the display is written.
%1xxxxxxx
$80 which is %10000000 is the first display position on Line1
$C0 which is %11000000 is the first position on line 2
increasign either of those values will move you along the line so that you can write at any position. This means you dont have to rewrite the entire display if all that is changing is a single character.
Keith
www.diyha.co.uk
www.kat5.tv
Although Keith answered your question quite well, this information is documented on page 94 of the PicBasic Pro manual under the LCDOUT command section (pg 94 of the online version here http://www.melabs.com/downloads/pbpm304.pdf )
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Bookmarks