PDA

View Full Version : LCD and "count": need to clear LCD?



Mugel
- 22nd October 2006, 21:23
Hi You all!

had a VERY small program using "count" and "LCDout" . Problem occurs at the display:
Every time the value displayed on the LCD goes down from two digits to one or from three to two it keeps the first number which isnīt cleared.
Going up works fine because it overwrites every digit, but going down keeps some old ones.
So I put in the "Clear Display" command into the loop but that makes the whole display flashing...otherwise the frequency counter works fine for me.

How can I clear the numbers of my value on the display without flashing the whole thing?

'
' DEFINITIONS
'
Cnt VAR Word ' Cnt is a word variable
'
' START OF MAIN PROGRAM
'
CMCON = 7 ' RA0-RA3 are digital I/O
TRISA = 0 ' PORT A is output
TRISB = 1 ' PORT B0 is input others output

PAUSE 500 ' Wait 0.5 second to initialize LCD
Cnt = 0 ' Clear Cnt to zero
LCDOUT $FE,1 ' Clear LCD
LCDOUT $FE,2
RPT:
cnt = 0
LCDOUT $FE,1 ' here is my problem!! makes everything flashing!'

LCDOUT $FE,2

Count PORTB.0,1000,CNT
LCDOUT "Freq.= ",$FE,$C0,DEC Cnt ' Display count
PAUSE 1000

Goto RPT




END

sayzer
- 22nd October 2006, 21:34
If I understood what you wanted to do, this should be it.




RPT:
Count PORTB.0,1000,CNT
LCDOUT $fe,1, "Freq.= ", DEC Cnt ' Display count
Goto RPT




Also, no need for PAUSE 1000 because your Count command itself creates 1000ms delay for LCD.


--------------------

paul borgmeier
- 22nd October 2006, 22:55
Try somethinbg like this:

LCDOUT "Freq.= ",$FE,$C0,DEC Cnt ' Display count
If Cnt < 100 then LCDOUT " " ' if Cnt is less than 100 then print a blank
If Cnt < 10 then LCDOUT " " ' if Cnt is less than 10 then print a blank
PAUSE 1000

Acetronics2
- 23rd October 2006, 09:20
Hi You all!

How can I clear the numbers of my value on the display without flashing the whole thing?

END

Hi,

Just print blank characters ( or new characters) UPON the existing you want to clear ...

see manual page 94, middle ...

LCDOUT $FE, $80 ( or $C0 ) + 6 ( or 7 i.e. ! ) , "___" ( 3 blanks or 888 i.e. )

$FE,$80 + 6 sets the cursor position ... to the 6th position, line 1
$FE,$C0 + 8 ................................... to the 8th position, line 2
...
...

Alain

sayzer
- 23rd October 2006, 09:55
Nice example Alain.

Also, DEC modifier can be useful, too. Like DEC3 CNT or DEC4 CNT etc...