Shop OBEX P1 Docs P2 Docs Learn Events
StampWorks Experiment #33 - Question? — Parallax Forums

StampWorks Experiment #33 - Question?

MichelBMichelB Posts: 154
edited 2009-12-25 18:22 in BASIC Stamp
Hi all, yes I know, today is holiday, but I'll try.
In this experiment (code attached)
Button 0 -> +/- minutes
Button 1 -> +/- hours
Button 2 -> +/- day
Button 2 -> roll back
How to do to set date (day in the month, 1 - 31), month and year?
Thank you in advance for help.

Comments

  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2009-12-25 15:58
    This code sets the DS1307 using 12 or 24 hour mode accepting input from DEBUGIN...
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-25 15:59
    The experiment obviously ignores the day of the month, month, and year. If you want to add a calendar function, use the existing code as a model. Setting day of the month, month, and year is not very different from setting minutes and hours.
  • MichelBMichelB Posts: 154
    edited 2009-12-25 17:16
    Hi Mike, the code attached in my post is the original. In variables list we can see date, month and year and in Reset_Clock: date = $01 for "1st", month = $01 for "January" and year = $05 for "2005". I think (nearly sure) that to set date, month and year one must press two (2) buttons in the same time but which ones? Maybe with your great experience you can "decode" which ones.

    P.S.: Behind the Scenes, ... This is especially true when an application needs to handle time, day and date. StampWorks Page 194.






    Post Edited (MichelB) : 12/25/2009 5:28:36 PM GMT
  • hover1hover1 Posts: 1,929
    edited 2009-12-25 18:22
    MichelB said...
    ·I think (nearly sure) that to set date, month and year one must press two (2) buttons in the same time but which ones? Maybe with your great experience you can "decode" which ones.


    It looks like Button 0 and Button 1.
    Reset_Clock:
      GOSUB Get_Buttons                             ' scan buttons
      [color=red]idx = btns & %0011[/color]                            ' isolate hrs & mins
      IF (idx = %11) THEN                           ' if both pressed, reset
        secs = $00
        mins = $00
        hrs = $06                                   ' 6:00 AM
        day = $07                                   ' Saturday
        date = $01                                  ' 1st
        month = $01                                 ' January
        year = $05                                  ' 2005
        control = 0                                 ' disable SQW output
        GOSUB Set_Clock                             ' block write clock regs
      ENDIF
    

    Jim
Sign In or Register to comment.