Digits on an LCD


Closed Thread
Results 1 to 9 of 9
  1. #1
    malc-c's Avatar
    malc-c Guest

    Default Digits on an LCD

    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
    Code:
    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**
    Code:
    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

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Try
    DEC2
    That should show the leading zero.
    Dave
    Always wear safety glasses while programming.

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    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 ?

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Code:
    LCDOut $FE,$D4,#starthours DIG 1,#starthours DIG 0,":",#startmin DIG 1,#startmin DIG 0
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Malcom,

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

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Works a treat - thanks Bruce

  8. #8
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Rewind a week and check the comment I posted when you last mentioned the above on the DS1307 thread...

  9. #9
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    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

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts