PDA

View Full Version : LCDOUT -- lose the zero ?



Michael
- 10th July 2017, 21:09
Can't figure out how to do this --

mynumber = byte
mynumber = 120


LCDOUT $FE,1,DEC mynumber

also tried --

LCDOUT $FE,1,#mynumber

Problem is that whenever I lower the number below 100 (I have 2 switches set up - and +), the LCD
will read 990 980 etc instead of 99, 98.

It's fine from 100 to 255.

Also, if I start mynumber with a value of say 90, if I remember right, it's ok UNTIL I move it past 100. Then when I try and lower it, it goes back to adding the zero 990, 980 etc.

I don't use pbp much anymore so I'm sure it's something simple. Thanks kindly for any help.

pedja089
- 10th July 2017, 23:14
Try this LCDOUT $FE,1,#mynumber," "
$FE,1 should clear display. But for some reason your display isn't cleared.

Scampy
- 11th July 2017, 09:10
I use the following code to display a word variable which contains the value between 0 and 100



If maxbright = 100 then
LCDOut $FE,$c0,#maxbright,"%"
endif

If maxbright =0 or maxbright <10 then
LCDOut $FE,$c0,dec1 maxbright,"% "
endif

if maxbright >=10 and maxbright <100 then
LCDOut $FE,$c0,dec2 maxbright,"% "
endif



Just change maxbright for your variable and you should be fine

pedja089
- 11th July 2017, 09:36
I don't have problem with leading zeros, so I just use DEC3 to make it simple.

mpgmike
- 11th July 2017, 14:46
I resorted to a longer method of writing to an LCD. To get numeric values to print, first I create variables for each digit.



Val VAR BYTE
ValA VAR BYTE[3] 'Occupies 3 consecutive addresses

ARRAYWRITE ValA, [#Val]

IF Val < 100 then
ValA[2] = ValA[1]
ValA[1] = ValA[0]
ValA[0] = " "

I then print individual characters to the LCD.

Michael
- 11th July 2017, 15:47
Ok. I get it now. Never really used LCDOUT or an LCD for that matter. Wasn't clearing the display, thinking I could just manipulate line 2 leaving line 1 intact. Silly me. --- thanks