home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / time / gpstime_1 / !GPS_Time / !RunImage (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1997-08-01  |  2KB  |  96 lines

  1.               Reset Acorn CMOS Clock from GPS Time
  2.               ------------------------------------
  3.            Last modified  1997 Jun 07 [Sat] 1021 utc
  4.               
  5.  1997 J R Miller  g3ruh@amsat.org
  6. error
  7.  "Wimp_Poll",&C1972,b% 
  8.  event%
  9.  event% 
  10. )    
  11.   0:  
  12. check_line: 
  13. timeout
  14. $    
  15.  17:  
  16.  b%!16=0 
  17.  quit% = 
  18.  quit%
  19.  "Wimp_CloseDown"
  20.  "Wimp_Initialise",200,&4B534154,"UTC from GPS v1.01"
  21. "OS_SerialOp",5,6      : 
  22.  4800 baud
  23. "OS_SerialOp",1,0      : 
  24.  Format 8N1
  25. "OS_Byte", 2,2         : 
  26.  Enable serial ip
  27. "OS_Byte",21,1         : 
  28.  Flush ip buffer
  29.  b% &100
  30. 8ip$="" : quit%=0: ip$="": c%=0: line$="": timeout%=
  31. 1SECoffset=2   : 
  32.  This gets added to GPS time
  33. (-2) 
  34.  c%<>13
  35. "OS_SerialOp",4 
  36.  ,c%:  
  37.  c%<>13 
  38.  c%<>10 ip$+=
  39.  c%=13 
  40.  line$=ip$: ip$="": c%=0
  41. check_line
  42.  line$<>"" 
  43.   ID$=
  44. line$,1,6)
  45.  ID$="$GPRMC" 
  46.  ID$="$GPGGA" 
  47. set_time: quit%=
  48.  line$=""
  49. set_time
  50.  Scan for first comma
  51. line$,c%,1): c%+=1: 
  52.  C$=","
  53. line$,c%,2): c%+=2
  54. line$,c%,2): c%+=2
  55. line$,c%,2): c%+=2
  56.  Convert to number and add in offset.  
  57. 8 HR=
  58.  HR$: MI=
  59.  MI$: SE=
  60. 9+time = (HR*60 + MI)*60 + SE + SECoffset
  61.  Convert back to string
  62. <J               HR=
  63. (time/3600):  HR$=
  64. (HR):   
  65. (HR$)=1 
  66.  HR$="0"+HR$
  67. =Jtime-=HR*3600: MI=
  68. (time/60):    MI$=
  69. (MI):   
  70. (MI$)=1 
  71.  MI$="0"+MI$
  72. >Ltime-=MI*60:                       SE$=
  73. (time): 
  74. (SE$)=1 
  75.  SE$="0"+SE$
  76. @T?b%=8: $(b%+1)=HR$+":"+MI$+":"+SE$+
  77. (0): 
  78.  Required format for RTC is "12:34:56"
  79. "OS_Word",15,b%   : 
  80.  Set CMOS time and soft copy
  81.  7                : 
  82.  beep
  83.  Usable messages, e.g.:
  84.    $GPRMC,203409,A,5212.4600,N,00003.5436,E,0.174,296.8,060697,3.8,W*6B
  85.    $GPGGA,203410,5212.4585,N,00003.5379,E,1,08,1.00,7.9,M,47.0,M,,*72
  86. timeout
  87. -timeout%) > 1000 
  88.  quit%=
  89.  Quit program after 10 seconds regardless
  90. error
  91. txt$=
  92. $+" at line "+
  93. b%!0=
  94. $(b%+4)=txt$+
  95. "Wimp_ReportError",b%,17,"Message from !GPS_Time"
  96.