def __init__(self, function): super().__init__() self.callback = function loop = asyncio.get_event_loop() serialosc = monome.SerialOsc() serialosc.device_added_event.add_handler(self.serialosc_device_added) loop.run_until_complete(serialosc.connect()) loop.run_forever()
async def main(): loop = asyncio.get_running_loop() hello_app = HelloApp() def serialosc_device_added(id, type, port): print('connecting to {} ({})'.format(id, type)) asyncio.ensure_future(hello_app.grid.connect('127.0.0.1', port)) serialosc = monome.SerialOsc() serialosc.device_added_event.add_handler(serialosc_device_added) await serialosc.connect() await loop.create_future()
async def main(): loop = asyncio.get_running_loop() app = ExampleArcApp() def serialosc_device_added(id, type, port): if 'arc' not in type: print(f'ignoring {id} ({type}) as device does not appear to be an arc') return print(f'connecting to {id} ({type})') asyncio.ensure_future(app.arc.connect('127.0.0.1', port)) serialosc = monome.SerialOsc() serialosc.device_added_event.add_handler(serialosc_device_added) await serialosc.connect() await loop.create_future()
async def main(): loop = asyncio.get_running_loop() life_app = Life() def serialosc_device_added(id, type, port): print('connecting to {} ({})'.format(id, type)) asyncio.ensure_future(life_app.grid.connect('127.0.0.1', port)) serialosc = monome.SerialOsc() serialosc.device_added_event.add_handler(serialosc_device_added) await serialosc.connect() try: await loop.create_future() except asyncio.CancelledError: life_app.quit()
async def main(): loop = asyncio.get_running_loop() pages = monome.SumGridPageManager(2) life1 = Life() life1.set_grid(pages.pages[0]) life2 = Life() life2.set_grid(pages.pages[1]) def serialosc_device_added(id, type, port): print('connecting to {} ({})'.format(id, type)) asyncio.ensure_future(pages.grid.connect('127.0.0.1', port)) serialosc = monome.SerialOsc() serialosc.device_added_event.add_handler(serialosc_device_added) await serialosc.connect() await loop.create_future()
async def main(): loop = asyncio.get_running_loop() section1 = monome.GridSection((8, 8), (0, 0)) section2 = monome.GridSection((8, 8), (8, 0)) splitter = monome.GridSplitter([section1, section2]) life1 = Life() life1.set_grid(section1) life2 = Life() life2.set_grid(section2) def serialosc_device_added(id, type, port): print('connecting to {} ({})'.format(id, type)) asyncio.ensure_future(splitter.grid.connect('127.0.0.1', port)) serialosc = monome.SerialOsc() serialosc.device_added_event.add_handler(serialosc_device_added) await serialosc.connect() await loop.create_future()
# update grid buffer.render(self.grid) def on_grid_key(self, x, y, s): # toggle steps if s == 1 and y < 6: self.step[y][x] ^= 1 self.draw() # cut elif y == 7: # cut if s == 1: self.cutting = True self.next_position = x if __name__ == '__main__': loop = asyncio.get_event_loop() grid_studies = GridStudies() def serialosc_device_added(id, type, port): print('connecting to {} ({})'.format(id, type)) asyncio.ensure_future(grid_studies.grid.connect('127.0.0.1', port)) serialosc = monome.SerialOsc() serialosc.device_added_event.add_handler(serialosc_device_added) loop.run_until_complete(serialosc.connect()) loop.run_forever()