async def alert(count=3): current = display.backlight() for i in range(count * 2): if i % 2 == 0: display.backlight(BACKLIGHT_MAX) yield loop.Sleep(20000) else: display.backlight(BACKLIGHT_NORMAL) yield loop.Sleep(80000) display.backlight(current)
def animate_pulse(func, ca, cb, speed=200000, delay=30000): while True: # normalize sin from interval -1:1 to 0:1 y = 0.5 + 0.5 * math.sin(utime.ticks_us() / speed) c = blend(ca, cb, y) func(c) yield loop.Sleep(delay)
def perf_info_debug(): while True: queue_len = len(loop._scheduled_tasks) delay_avg = sum(loop.log_delay_rb) / loop.log_delay_rb_len delay_last = loop.log_delay_rb[loop.log_delay_pos] mem_alloc = gc.mem_alloc() gc.collect() log.debug(__name__, "mem_alloc: %s/%s, delay_avg: %d, delay_last: %d, queue_len: %d", mem_alloc, gc.mem_alloc(), delay_avg, delay_last, queue_len) yield loop.Sleep(1000000)
def __iter__(self): timeout = loop.Sleep(1000 * 1000 * 1) touch = loop.Select(loop.TOUCH) wait = loop.Wait((touch, timeout)) while True: self.render() result = yield wait if touch in wait.finished: event, *pos = result self.touch(event, pos) elif self.zoom_buttons: self.zoom_buttons = None for btn in self.key_buttons: btn.taint()
def __iter__(self): timeout = loop.Sleep(1000 * 1000 * 1) touch = loop.Select(loop.TOUCH) wait = loop.Wait((touch, timeout)) while True: self.render() result = yield wait if touch in wait.finished: event, *pos = result self.touch(event, pos) else: self.pending_button = None self.pending_index = 0 self._update_suggestion() self._update_buttons()
def perf_info(): while True: gc.collect() log.info(__name__, "mem_alloc: %d", gc.mem_alloc()) yield loop.Sleep(1000000)
def _render_loop(self): RENDER_DELAY = const(1000000 // 60) while True: self.render() yield loop.Sleep(RENDER_DELAY)