More detail: the problem is that I don’t understand the syntax of the Python in Grid Studies. I tried to mesh the code for osc4py3 from the section called 1.3.1.2 Sending OSC Messages like this:
#! /usr/bin/env python3
import asyncio
import monome
# Import needed modules from osc4py3
from osc4py3.as_eventloop import *
from osc4py3 import oscbuildparse
# Start theosc4py3 system.
osc_startup()
# Make client channels to send packets.
osc_udp_client("127.0.0.1", 4560, "SonicPi")
# Build a message with autodetection of data types, and send it.
msg = oscbuildparse.OSCMessage("/flag1", None, ["text", 672, 8.871])
class GridStudies(monome.GridApp):
def __init__(self):
super().__init__()
def on_grid_key(self, x, y, s):
print("key:", x, y, s)
osc_send(msg, "SonicPi")
self.grid.led_level_set(x, y, s*15)
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()
except I now realize there should be a osc_process() somewhere (I think).