Clock setting
Chris Hall (132) 3558 posts |
The real time clock (which is defined in GMT) can be read directly using OS_Word 14,3. I can obtain a GMT time and date from a GPS module. Switching on can sometimes corrupt the real time clock on the Witty Pi. I therefore know the GMT/UTC time (from the GPS signal) and want to correct the Witty Pi RTC from its 01-Jan-2100 default to the correct value. I calculate the correct 5-byte value. The only call [Edit: in the PRMs] to update the RTC is OS_Word 15,8 which requires me to use OS_ConvertStandardDateAndTime to get the time and date into text format. Although ‘use DST automatically’ is ticked in !Alarm the OS_ConvertStandardDateAndTime call (which actually uses Territory_ConvertStandardDataAndTime) still gives me a GMT date and time so the clock ends up an hour slow. What should it do please? Also can I write a 5 byte UTC GMT RTC value to the RTC using OS_Word please? |
Jeffrey Lee (213) 6048 posts |
RISC OS 5 introduced OS_Word 15, 5 for setting the clock using a 5-byte time. The wiki doesn’t state the time zone, but presumably it’s UTC, which would make the call the converse of OS_Word 14, 3. |
Chris Hall (132) 3558 posts |
Many thanks. Except that it doesn’t work. Setting the time, using OS_Word 15,5, to 18:25 GMT results in OS_Word 14,3 followed by OS_ConvertStandardDateAndTime incorrectly reporting the time as 18:25 rather than 19:25, as DST is set to be automatic. After the next CTRL-Break RISC OS reports the correct time (using the same method, OS_Word 14,3 followed by OS_ConvertStandardDateAndTime), so the RTC was set correctly but just reported wrong. What seems to be happening is that if RISC OS starts up with the RTC set to 01-Jan-2100 [that is what the Witty Pi defaults to in an untidy power on] and DST is automatic (note the RTC always stores date and time in GMT/UTC format) and date is then set to a Summer date it goes wrong. OS_Word 15,5 is [then] used to set the GMT date to (say) 5th April 2017 at 10:00 [it does this correctly] and then OS_Word 14,3 followed by OS_ConvertStandardDateAndTime reads it back as 10:00 rather than the correct local time of 11:00. On next CTRL-Break OS_Word 14,3 followed by OS_ConvertStandardDateAndTime reads it back correctly as 11:00 local time. If RISC OS starts up with the RTC set to a Summer time date and you do the same date/time setting, again to a Summer time, then it all works correctly. |