def betterDelay(ms):
  """ Delay milliseconds with libc usleep() using ctypes and
      some simple error compensation. """
  if (ms >= 0.1):
    # Fix some of the error calculated through testing 
    # different sleep values on the Beaglebone, change 
    # accordingly:
    ms -= 0.1 
  ms = int(ms*1000)
  libc.usleep(ms)

#------------------------------------

#--- Tests: -------------------------
dataset/ETHPy150Open graycatlabs/PyBBIO/tests/sleep_test.py/betterDelay/original