Convert delays from float to int (ticks_us)

pull/25/head
slush0 8 years ago committed by Pavol Rusnak
parent f27d5ad725
commit cc71fb0a02
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -18,13 +18,13 @@ class EventLoop:
self.call_at(0, callback, *args) self.call_at(0, callback, *args)
def call_later(self, delay, callback, *args): def call_later(self, delay, callback, *args):
self.call_at(utime.ticks_us() + delay * 1000000, callback, *args) self.call_at(utime.ticks_us() + delay, callback, *args)
def call_at(self, time, callback, *args): def call_at(self, time, callback, *args):
# Including self.cnt is a workaround per heapq docs # Including self.cnt is a workaround per heapq docs
if __debug__: if __debug__:
log.debug("Scheduling %s", (time, self.cnt, callback, args)) log.debug("Scheduling %s", (int(time), self.cnt, callback, args))
uheapq.heappush(self.q, (time, self.cnt, callback, args)) uheapq.heappush(self.q, (int(time), self.cnt, callback, args))
self.cnt += 1 self.cnt += 1
def wait(self, delay): def wait(self, delay):
@ -32,8 +32,8 @@ class EventLoop:
# with IO scheduling # with IO scheduling
if __debug__: if __debug__:
log.debug("Sleeping for: %s", delay) log.debug("Sleeping for: %s", delay)
self.last_sleep = delay / 1000000. self.last_sleep = delay
utime.sleep(delay / 1000000.) utime.sleep_us(delay)
def run_forever(self): def run_forever(self):
while True: while True:

Loading…
Cancel
Save