Shop OBEX P1 Docs P2 Docs Learn Events
Using Propeller RTC emulator — Parallax Forums

Using Propeller RTC emulator

LevLev Posts: 182
edited 2012-07-14 21:44 in Propeller 1
I am trying to return current hours, minutes, and seconds from the Propeller_RTC_Emulator to my spin program as separate values. I believe the varaibles are HH, MM, and SS in the RTC emulator. I have been unable to get any value for these variable, other than a zero. Does anyone know how to return these separate values from the RTC emulator? Here is the relevant section of code calling the RTC.

'Main Loop
repeat

Clock.ParseDateStamp(@DateStamp) 'get date and time stamps from RTC emulator
Clock.ParseTimeStamp(@TimeStamp)
' **** need something here?????
mission_time := HH*3600 + MM*60 +SS 'calculate mission time in seconds from RTC emulator

LocLong := (LocLongDeg*60) + LocLongMin 'calculate minutes of longitude
LocLat := (LocLatDeg*60) +LocLatMin 'calculate minutes of latitude

Comments

  • Mike GMike G Posts: 2,702
    edited 2012-07-14 20:39
    The DateSTamp and TimeStamp are in ASCII. you must convert the ASCII string to a number


    This is a bit of a hack. The TryParseTime method takes a pointer to the @TimeStamp and the time part you want to convert to an integer.

    0 = Hour
    1 = Minute
    2 = Second
    PUB TryParseTime(time, idx) | value, ptr
    
      'Move the string pointer to hours, minutes, or seconds
      ptr := time+idx*3
    
      'convert to an integer and multiply by 10
      value := (byte[ptr++] - $30) * 10
    
      'Conver to an integer and and add to the last calculation
      value += byte[ptr] - $30
    
      return value
    
  • kuronekokuroneko Posts: 3,623
    edited 2012-07-14 20:45
    At some point you started the emulator passing it an address. Just grab the values from there, e.g.
    RTCemu.start(@time)
      
      temp := time
      HH   := (temp >> 12) & $0F
      MM   := (temp >>  6) & $3F
      SS   := temp & $3F
    
    or
    RTCemu.start(@time)
      
      vscl := time                  ' unused SPR
      HH   := vscl[15..12]
      MM   := vscl[11..6]
      SS   := vscl[5..0]
    
  • Mike GMike G Posts: 2,702
    edited 2012-07-14 20:54
    I just came across the UnParseTime(TimeAddress) method in Propeller_RTC_Emulator.
  • LevLev Posts: 182
    edited 2012-07-14 21:44
    Thank you a bunch Mike and kuroneko! Your suggestions work well.
Sign In or Register to comment.