No announcement yet.

Question on clock.4DG demo

  • Filter
  • Time
  • Show
Clear All
new posts

  • Question on clock.4DG demo


    I've got a quick question on the clock demo. I am used to creating a graphics font by building and animated gif, importing in GC, then indexing into the "video" by selecting the desired frame.

    I see on the demo that the custom digit has a bmp image assigned (ocr53neon20.bmp). How does the bitmap image get properly parsed into the 10 separate digits?

    Also, to change the size of the digits, does the bitmap need to be scaled outside of workshop?
    Best Regards,

  • #2

    I would like to display Days, Months and Years in addition to Hours, Min, Sec. Referring to the Clock demo
    I added the lines:

    Clock.time[DAYS] := readbyte(DAYS); Clock.time[MONTHS] := readbyte(MONTHS); Clock.time[YEARS] := readbyte(YEARS);

    print (Clock.time[DAYS]); print (Clock.time[MONTHS]); print (Clock.time[YEARS]);

    this didn't do anything, I was trying to get the days to change when the clock rolled over to the next day but all I get is zeros.

    Any help would be appreciated,




    • #3

      Where is this clock demo?

      There must be a couple, the one I was looking at doesn't have anything like that in it


      • #4

        Hi Mark,

        This is where I found the example,,

        Filename: I2C-DS1307-ClockChip.4dg

        Anyhow, this example is the least complicated of all, so I wanted to learn how the code works here before I try to tackle my next project.

        I need to be able to read the stored day, month, year. I don't know how to parse the information stored in the BCD data or how to save the information once I change it:

        Thanks again,



        • #5

          The sample code should be easily expanded to get/set the date.

          I'm concerned about some of the things in the few lines of code you have posted.

          eg Clock.time[DAYS]

          There is nothing like this in the original sample.

          Please post your complete modified code so we can have a look.


          • #6

            Hi, and thank you for your reply. I had added a few lines to the example which was a stab in the dark. I dont want to have my solution impact your solution. So please give me your best shot at this and I will go from there.
            Thank you again,


            • #7

              Well, you'd need to add a few new constants, eg

              #constant DAY 3
              #constant DATE 4
              #constant MONTH 5
              #constant YEAR 6

              And then something like

              [HEX2] readbyte(HOURS),":",
              [HEX2] readbyte(MINUTES),":",
              [HEX2] readbyte(SECONDS) ," ",
              [HEX2] readbyte(DATE),"/",
              [HEX2] readbyte(MONTH),"/",
              [HEX2] readbyte(YEAR)


              • #8

                Thanks for your reply, however I tried this already and didnt get very far. It seemed to ignore the additional code. I can assign a value to the constants and print them bit they don't change as time passes.I think we are missing something.
                What's the next step?



                • #9

                  If you don't want to post your code their isn't much I can do, I can't really see how a computer can "seemed to ignore the additional code." It does what it's told to.

                  I don't have a DS1307 handy so I can't cook up something that is guaranteed to work


                  • #10

                    I don't have any code to post. I simply did what you did, and I got zeros. Maybe you could explain how the readbyte(minutes) function works. Somewhere in the example the program has to know where the minutes register is and what's in it, that's what I mean about it not doing anything with the value. I have this code working fine on an arduino, but I am having a hard time converting it to gfx. Would it help for me to post that code and its libraries?
                    Thanks for your time,



                    • #11

                      I'm pretty sure most clock chips return 0s if you haven't set them to anything first.

                      The code should just work, there's nothing difficult or complex to it


                      • #12

                        I agree with you except that in this case we set the register to a value with the statement
                        #constant date 3
                        #constant month 2
                        So the values are not zeros, right ? Or am I missing something.
                        I can print the values as per the example you posted above, but when the day rolls over from 23:59:59, it doesn't advance the date register.


                        • #13

                          Sorry, I don't have one so I can't do much more.

                          Maybe a user that has one can help further


                          • #14

                            Ok, I appreciate you taking the time to try. If I get it working I'll post the code.


                            • #15
                              I know im waking the dead but any help would be much appreciated.

                              I'm trying to right a very basic Clock to display like an analogue clock, I have both the uLCD-24PTU and the uLCD 220ORD with an I2C RTC module (DS1307)

                              There are a lot of references to a clock demo and i have found this...


                              Is there an up to date sample code anywhere this one wont compile?

                              Thanks for any help you can give!