Shop OBEX P1 Docs P2 Docs Learn Events
jm_ds1307_demo.spin as alarm clock — Parallax Forums

jm_ds1307_demo.spin as alarm clock

stargazer2050stargazer2050 Posts: 89
edited 2014-03-21 06:58 in Propeller 1
Quickstart board
Jm_ds1307.spin
Ds1307 running on 28 and 29
Fullduplexserial

Tried to capture the hex into a variable
Minute := term.hex(clock[1], 2)

Tried variable as word and as long.

How to do it?????

Comments

  • stargazer2050stargazer2050 Posts: 89
    edited 2014-03-20 10:03
    Jm_Ds1307 uses fullduplexserial

    Could i break that into two units and:

    [code]
    PRI hexToInteger(h) : v
    if h => "0" and h =< "9" v := h - "0"
    elseif h => "A" and h=< "F" v := h - "A" + 10
    elseif h => "a" and h =< "f" v := h = "a" + 10

    PRI twoHextoInteger (h2,h1) : v
    v := hexToInteger(h2) << 4 | hexToInteger(h1)
    [\code]
  • ChrisGaddChrisGadd Posts: 310
    edited 2014-03-20 13:14
    The DS1307 outputs time in binary-coded-decimal (BCD) format, so 12:34:56 is output as $56 seconds, $34 minutes, $12 hours.
    Without seeing the code, I'm guessing all of the parameters are read into an array of clock bytes. So...
      seconds     := clock[0]
      minutes     := clock[1]       
      hours       := clock[2]         
      day_of_week := clock[3]   
      date        := clock[4]          
      month       := clock[5]         
      year        := clock[6]          
    
    If you want to convert that to a hexadecimal value, where $34 minutes = decimal 34 ($22)
    minutes := (clock[1] >> 4 * 10) + (clock[1] & $0F)
    
  • stargazer2050stargazer2050 Posts: 89
    edited 2014-03-20 13:48
    Hi,

    Would like to convert to regular decimal so i can capture it in a variable,

    Then i can use the variables to figure out the alarm setting.
  • stargazer2050stargazer2050 Posts: 89
    edited 2014-03-20 14:44
    I may be asking for ascii

    If the clock speaks 4 digit bcd
    Then is displayed on 7 digit lcd with hex
    And i only speak regular numbers im in a heap of trouble.
    Thats why im askii..ing
  • stargazer2050stargazer2050 Posts: 89
    edited 2014-03-21 03:57
    To Chris, thats it, got it!

    Thankyou!
  • JonnyMacJonnyMac Posts: 9,106
    edited 2014-03-21 05:02
    Maybe you have an old version of my DS1307 object -- the one on my computer has conversion routines to go from BCD to decimal and vice-versa.
    pub bcd2dec(bcd)
    
      return ((bcd >> 4) * 10) + (bcd & $0F)
    
    
    pub dec2bcd(dec)
    
      return ((dec / 10) << 4) | (dec // 10)
    


    Tip: If you're using the Propeller Tool, but the object you're using in Summary view so you can more easily see the public methods in the object.

    Jm_Ds1307 uses fullduplexserial

    No, it doesn't. JM_DS1307 is an object for an RTC that uses an I2C interface. Your application may use serial, the object itself does not.
  • stargazer2050stargazer2050 Posts: 89
    edited 2014-03-21 06:53
    Hi jm

    I chose yer prog because 1. It works 2. It expresses.using fullduplexserial instead of tv or lcd so i could stay consistant.
    Ive downloaded your new one and will upgrade to it!
    Thanks
  • JonnyMacJonnyMac Posts: 9,106
    edited 2014-03-21 06:58
    I'm glad it works for you. That said, let's be accurate so we don't confuse newcomers. The file jm_ds1307 is an object that uses I2C to connect to the DS1307 RTC. The file jm_ds1307_demo.spin uses the jm_ds1307 object and outputs data to a terminal program. Some may think me pedantic on this, but I see a lot of inaccurate statements in the forums vis-a-vis object (library) code versus demo/application code.
Sign In or Register to comment.