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

First Light

Created by nick. Last edited by nick, 4 years and 80 days ago. Viewed 2,212 times. #6
[diff] [history] [edit] [rdf]
labels
attachments
off.png (1368)
on.png (1423)
This is hopefully where things start to get interesting. This is a script which, when loaded, turns on all the LEDs. (More correctly, it illuminates an eight-by-eight block of LEDs, regardless of monome size.)

The main body of the script looks like this:

lightBlock = Block(8, 8)
lightBlock.fill(LampState.ON)
renderer.render(lightBlock)

When this runs, the LEDs will come on. In fact, they'll stay on even when other scripts are loaded, so this script is slightly antisocial; we'll deal with cleaning up script actions later.

We'll look at the statements in order:

lightBlock = Block(8, 8)

This creates an object called lightBlock which is a shado Block: a rectangular matrix of lamp settings. To light up the monome's LEDs, we need to set these lamps to an "on" state:

lightBlock.fill(LampState.ON)

This isn't quite enough to actually light the LEDs. To do that, we need to render the Block out to the monome itself.

renderer.render(lightBlock)

Before these statements will work we need to do some book-keeping. Names like Block, LampState and renderer need to be imported into the script so that the Python system knows where to find them. The import statements look like this:

from net.loadbang.shado import Block
from net.loadbang.shado.types import LampState
from config import renderer

The first two statements (those mentioning net.loadbang.shado) refer to components inside the shado package. The third statement is actually referring to another file of Python statements (called config.py), which does some local configuration such as establishing communication settings for the monome.

Before the script runs:

off

After the script runs:

on

Full Script

'''
When launched, this script turns on all LEDs.
'''

from net.loadbang.shado import Block from net.loadbang.shado.types import LampState from config import renderer

lightBlock = Block(8, 8) lightBlock.fill(LampState.ON) renderer.render(lightBlock)

no comments | post comment



< May 2013 >
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
262728293031

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