time.time() only give me second.
Is it possible to get millisecond from anywhere?
Thanks a lot
time.time() only give me second.
Is it possible to get millisecond from anywhere?
Thanks a lot
Hi,
I had the same problem, I used a little C++ code compiled as a Python module to get more precise time. But I don't know how accurate it is; if Python does not return more precise time it *may* not be enough accurate to return valid data (Has anyone more informations?)
Code available in this file : https://air.mosomuso.com/pubhg/pyext...p;style=gitweb
Regards,
Christophe Berger
hello ,
You can find more info here
miso module provide a nice tick count function :
Cyke64Code:import miso,e32 print miso.tick_count() e32.ao_sleep(1) print miso.tick_count() e32.ao_sleep(1) print miso.tick_count()
pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !
Find my pys60 extension modules on cyke64.googlepages.com
hello again ,
I have tried this snippet with miso.tick_count() and found that precision is only 1/64 secon a E61 (3rd edition)
Try it yourself :
Cyke64Code:import miso,e32 b=miso.tick_count() e=miso.tick_count() print e-b print miso.tick_count() print miso.tick_count() print miso.tick_count() e32.ao_sleep(1) print miso.tick_count() e32.ao_sleep(1) print miso.tick_count() b1=miso.tick_count() e32.ao_sleep(1) e1=miso.tick_count() e32.ao_sleep(1) e2=miso.tick_count() print e1-b1 print e2-e1
pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !
Find my pys60 extension modules on cyke64.googlepages.com
hello ,
I try your phone_time() function with the same snippet it seems more precise than miso (1/64 sec) !
Code:import gps_location,e32 def format_time(time): return int("%2d%2d%6d"%(time[4],time[5],time[6])) b=format_time(gps_location.phone_time()) e=format_time(gps_location.phone_time()) print e-b print gps_location.phone_time()[6] print gps_location.phone_time()[6] print format_time(gps_location.phone_time()) e32.ao_sleep(1) print format_time(gps_location.phone_time()) e32.ao_sleep(1) print format_time(gps_location.phone_time()) b1=format_time(gps_location.phone_time()) e32.ao_sleep(1) e1=format_time(gps_location.phone_time()) e32.ao_sleep(1) e2=format_time(gps_location.phone_time()) print e1-b1 print e2-e1
pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !
Find my pys60 extension modules on cyke64.googlepages.com
Is this really the only way to get more granularity - to use C++ code?
What was wrong with aaaaapo's suggestion of using time.clock()? It's as accurate as you can get from the hardware. On my device it seems to provide accuracy to the nearest millisecond.
I use code like this in AyIX:
Code:import time # Run this once when your program starts CLOCK_OFFSET = int(round(time.time())) - int(round(time.clock())) # Call this to return UNIX timestamp to nearest millisecond def getTime(): return time.clock() + CLOCK_OFFSET