Re: Future version 1.27 of the "World Map" #future


On 20220511 02:29:40, David J Taylor via wrote:
On 11/05/2022 09:37, jdow wrote:
time_t timeGetTime(); That has millisecond resolution - if running with mm
timer set to 1 ms. Then there is the precision (100ns) timer with motherboard
dependent actual resolution. I use timeGetTime() most of the time. One must
handle it's roll over, of course. With time64_to work with on 64 bit builds
that's not much of a problem. It is always a relative time to when the computer
boots. But that offset can be backed out if critical.


For getting the UTC I use the precise function where it is available, which
should be Windows-8 ans later.


function NowUTCprecise: TDateTime;

  function FTtoDateTime (const ft: TFileTime): TDateTime;
    TFT = record case integer of
            0: (ft: TFileTime);
            1: (i64: int64);
    ft64: TFT;
    dt: TDateTime;
    offset: TDateTime;
    ft64.ft := ft;
    dt := ft64.i64;
    dt := dt / (1E7 * 86400);
    offset := EncodeDate (1601, 1, 1);
    Result := dt + offset;

  ft: TFileTime;
  FPreciseFT (ft);
  Result := FTtoDateTime (ft);

In the initialisation use the best available:

  FKernel32 := LoadLibrary ('kernel32.dll');
  if FKernel32 <> 0 then
    FPreciseFT := GetProcAddress (FKernel32, 'GetSystemTimePreciseAsFileTime');
    if @FPreciseFT = nil then
      FPreciseFT := GetProcAddress (FKernel32, 'GetSystemTimeAsFileTime');

Using NTP with a PPS source gives much better than 1 millisecond keeping:

A Raspberry Pi with a GPS/PPS hat can make an ideal local NTP server, for example:

(hit by the chip shortage).

David GM8ARV
SatSignal Software - Quality software for you
Email: david-taylor@...
Twitter: @gm8arv

The performance counter has been available for a very long time. GetSystemTimePreciseAsFileTime() is an added function that means you do not have to invent your own. Remember that this only reads the time when you call the function. This may be several ms from when the data came in on an io port buffer. There are no free lunches, unfortunately.


Join to automatically receive all group messages.