PDA

View Full Version : Digits on an LCD



malc-c
- 20th April 2010, 13:12
I've been pulling my hair out last night trying to do a very simple thing, but just can't seem to get it to display the info correctly.

I have two variables, one called starthours, the other startmin. The hours start at 0 and can be incremented to 23 by the press of a button, as can the minutes be inremented from 0 to 59.

I want to display the value of these two varibles as 00:00 on an LCD display. However because the vaule of each variable is single digit when less than 10 and is right justified I end up getting 9:7 on the display.

The following works fine for the Hours


If hours>=10 then LCDOut $FE,$D4,$10,dec starthour,":",dec startmin
If hours<10 then LCDOut $FE,$D4+1,"0",dec starthour,":",dec startmin


But trying to get the minutes to display correctly using similar code has been a pain in the A**


If minutes>=10 then LCDOut $FE,$D4+3,$10,dec startmin
If minutes<10 then LCDOut $FE,$D4+4,"0",dec startmin


Can someone please suggest the best way to display starthours:startmin in a 00:00 format, ie 09:03, 08:06, 13:34 etc

mackrackit
- 20th April 2010, 13:18
Try
DEC2
That should show the leading zero.

malc-c
- 20th April 2010, 14:58
Hi Dave,

I tried that, both DEC1 and DEC2, but it worked bacwards, in that it didn't display the 'tens' digits, just the 'units', unless I was using the command incorrectly ?

Bruce
- 20th April 2010, 15:05
LCDOut $FE,$D4,#starthours DIG 1,#starthours DIG 0,":",#startmin DIG 1,#startmin DIG 0

malc-c
- 20th April 2010, 15:13
Bruce, I'll give that a go when I get home.

I hadn't tried that as I thought that when the value was less than 10 I might get strange readings as there wold only be one DIGIT ?

More reading of the manual I figure :rolleyes:

Bruce
- 20th April 2010, 15:21
Hi Malcom,

It definitely works. It will display time like you want with 09:03, 08:06, 13:34, etc.

malc-c
- 20th April 2010, 17:39
Works a treat - thanks Bruce

Melanie
- 20th April 2010, 20:06
Rewind a week and check the comment I posted when you last mentioned the above on the DS1307 thread...

malc-c
- 20th April 2010, 20:44
Rewind a week and check the comment I posted when you last mentioned the above on the DS1307 thread...

Yeah, I looked for that... and as mentioned tried the DIG2, but obviously missed the DIG 1, DIG 2 format...

One day Mel this will click - I promise :)