You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • There's just the header file documentation

    why are jshGetMillisecondsFromTime and jshGetTimeFromMilliseconds hardware dependent?

    On some STM32s they return a value based on the SYSTICK timer, which runs at the clock speed of the device. It means it's nice and quick to get the time as you're basically just reading my_big_64_bit_counter+SYSTICK to get the time.

    On Espruino boards there's some insanity that allows them to 'track' the RTC with SysTick - giving accurate times off an LSE crystal white also being accurate to uS.

    is GetSystemTime supposed to be a RTC or just a us counter form boot? Is it to keep actual time-of-day in the end or to measure elapsed us, ms, or sec between events?

    It's both \o/

    It's meant to be accurate down to a uS or so, while big enough to store the date since 1970. If you do new Date() the time in it comes from this counter.

    To be honest, given ESP8266 isn't going to be very real-time (no 'real' IRQs for GPIO changes(?), and no hardware timer) I'd just run it off the RTC.

    what is the purpose of jshSetSystemTime?

    It actually sets the time you get from jshGetSystemTime - so that new Date() works fine.

    Please could you update the header file with something that makes sense to you? It might help others in the future.

About

Avatar for Gordon @Gordon started