open-source utilities and extras for Max/MSP
[ start | index | login ]

Buttons

Created by nick. Last edited by nick, one year and 191 days ago. Viewed 790 times. #8
[diff] [history] [edit] [rdf]
labels
attachments
m1.png (4254)
This is a simple script which reports button presses on the monome. We print the button positions to the Max window. To do this we need a function with the particular name press:

def press(x, y, how):
    'A button has been pressed: print out the values.'
    print "X=%d, Y=%d, how=%d" % (x, y, how)

Whenever a button is pressed or released, the workbench attempts to call a function called press with three argument values: the X and Y position of the press, and a value to distinguish between a button press and a release. The how value will be 1 for press, 0 for release.

This function has a documentation string, and a single line of code:

print "X=%d, Y=%d, how=%d" % (x, y, how)

This prints the values as a formatted line of text. (For all the gory details, see >>here, but in summary, we are printing out a string with each "%d" replaced with a number.)

The entire script is below. Once it is running, you will notice that the coordinate system of the monome runs from a top-left point of (0, 0). In our eight-by-eight examples the bottom-right is at (7, 7). This script will actually work for a monome of any size: on a two fifty six, the bottom-right button is at (15, 15).

You should see output looking rather like this:

X=0, Y=0, how=1
X=0, Y=0, how=0
X=2, Y=1, how=1
...

We aren't doing anything with the LEDs yet, so no lights will come on. Unlike on many other devices, there is no hardware link between buttons and lights: soon we will start using shado to provide this linkage in software.

Coordinates: (0, 0) (left illustration), (7, 7) (right).

m1

Full Script

'''
A script which prints out button presses to the Max window.
'''

def press(x, y, how): 'A button has been pressed: print out the values.' print "X=%d, Y=%d, how=%d" % (x, y, how)

Please login to post a comment.



< September 2010 >
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
2627282930

XHTML 1.0 validated
CSS validated
RSS 2.0 validated
RSS Feed

Contact: Nick Rothwell

Powered by SnipSnap 1.0b3-uttoxeter

Open Source Java and UI Software for MaxMSP

ff194

The fireflash spanning router for the >>monome.

shado-small

The shado compositing and sprite library for the >>monome.


jython-logo

The Python programming language embedded in MaxMSP/MXJ


groovy-50

The Groovy programming language embedded in MaxMSP


small_powered_by

A Jetty-based embedded web server for MaxMSP, with JSP support


hsqldb

SQL database support, using HSQL or Apache Derby (embedded), or MySQL


nixie

Nixie tubes for Max


buttonsx

Rotating, alignable, colourable, assignable, pattr-aware arrays of text


Legacy Software

snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt