Shop OBEX P1 Docs P2 Docs Learn Events
ds1307 programming Question — Parallax Forums

ds1307 programming Question

stargazer2050stargazer2050 Posts: 89
edited 2012-06-08 07:40 in Propeller 1
Quickstart bd
Ds1307 clock running well
Obex object/420 1307_rtc_driver
Jm_ds1307_demo.spin


User friendly instructions please

Object 420 sets the clock with time command and reads with date command
1. No instruction to get hour in spin code
2. PST conflict

Jm_1307_demo.spin seems to be looking at clock data with no labeling so what is it?
1. How to set time
2. How to get hours only in 12 or 24 hours in spin code in software

Comments

  • JonnyMacJonnyMac Posts: 9,195
    edited 2012-06-08 07:02
    Jm_1307_demo.spin seems to be looking at clock data with no labeling so what is it?
    1. How to set time
    2. How to get hours only in 12 or 24 hours in spin code in software

    1: In the version of that program on my PC, it's pretty plain:
    pub set_time(sc, mn, hr)
    
    '' Set seconds, minutes, and hours registers
    
      sc := 0 #> hr <# 59
      mn := 0 #> hr <# 59  
      hr := 0 #> hr <# 23
    
      i2c.putpage(DS1307, RTC_SECS, 3, @sc)
    


    2: I have a lot of experience with time-based products and it's always easier to use 24-hour format. If you need to output 12-hour format for the user, that's very easy to do; a case statement can convert your 24-hour hours to 12 -- something like this:
    case hr
        0 :
          hr := 12
          flag := "A"
    
        1..11:
          flag := "A"
    
        12:
          flag := "P"
    
        13..23:
          hr -= 12
          flag := "P"
    


    BTW, that was a quick demo, it's not a full-blown object. At any rate, you should download and read the DS1307 documentation before using my code on another object. The fact that someone else has created an object or demo does not relieve you of your responsibility to understand the component in question.
  • stargazer2050stargazer2050 Posts: 89
    edited 2012-06-08 07:40
    1. Would like the version on your machine if its plainer
    2. I see the pub set_time (in my version its pub settime' but cant get it to call to see what it does
    3. I prefer 24 hour but have to wait for this afternoon to see which variable is the 24 hour one, as its not labeled
    4. BTW ??
    5. Ds1307 documentation? Do you mean the datasheet or your doc? Read the datasheet, cant find your doc.
    6. Are you relieved of explaining what you've posted?
    7. Still would like how to extract just the hour and put it to a variable
Sign In or Register to comment.