diff --git a/nabd/nabd.py b/nabd/nabd.py index e308dddd..3e2f3979 100644 --- a/nabd/nabd.py +++ b/nabd/nabd.py @@ -377,15 +377,11 @@ async def _ears_moved(self): if self.state != 'asleep': self.broadcast_event('ears', {'type':'ears_event', 'left': left, 'right': right}) - async def setup(self): - self.nabio.set_leds(None, None, None, None, None) - await self.nabio.setup_ears(self.ears['left'], self.ears['right']) - def run(self): self.loop = asyncio.get_event_loop() self.nabio.bind_button_event(self.loop, self.button_callback) self.nabio.bind_ears_event(self.loop, self.ears_callback) - setup_task = self.loop.create_task(self.setup()) + setup_task = self.loop.create_task(self.idle_setup()) idle_task = self.loop.create_task(self.idle_worker_loop()) server_task = self.loop.create_task(asyncio.start_server(self.service_loop, 'localhost', Nabd.PORT_NUMBER)) try: diff --git a/nabd/nabio_hw.py b/nabd/nabio_hw.py index b8353cac..0a956e83 100644 --- a/nabd/nabio_hw.py +++ b/nabd/nabio_hw.py @@ -32,12 +32,12 @@ async def detect_ears_positions(self): return await self.ears.detect_positions() def set_leds(self, nose, left, center, right, bottom): - for led in [nose, left, center, right, bottom]: + for (led_ix, led) in [(Leds.LED_NOSE, nose), (Leds.LED_LEFT, left), (Leds.LED_CENTER, center), (Leds.LED_RIGHT, right), (Leds.LED_BOTTOM, bottom)]: if led == None: (r, g, b) = (0, 0, 0) else: (r, g, b) = led - self.leds.set1(led, r, g, b) + self.leds.set1(led_ix, r, g, b) def bind_button_event(self, loop, callback): self.button.on_event(loop, callback)