Permalink
Browse files

streamlined API, renamend change_all (ruby style) into changeAll (jav…

…a style). Fix bug with default color - wasn't normal mode, updated Version number to 0.2.1
  • Loading branch information...
1 parent a440624 commit 9157f5c2066d838ba67aa924f670f2332aa43e9e rngtng committed Dec 22, 2009
Showing with 19 additions and 17 deletions.
  1. +1 −1 examples/LaunchpadAll/LaunchpadAll.pde
  2. +18 −16 src/com/rngtng/launchpad/Launchpad.java
@@ -20,7 +20,7 @@ void draw() {
byte pos = byte(y*launchpad.width + x);
if(pos > 0) data[pos-1] = 0;
data[pos] = 3;
- launchpad.change_all(data);
+ launchpad.changeAll(data);
delay(100);
}
}
@@ -44,7 +44,7 @@
public static int width = 8;
public static int height = width;
- public final String VERSION = "0.2";
+ public final String VERSION = "0.2.1";
Vector<LaunchpadListener> listeners;
@@ -62,7 +62,7 @@ public Launchpad(PApplet _app) {
* @param outputName name of MIDI output Device
*/
public Launchpad(PApplet _app, String inputName, String outputName) {
- app = _app;
+ this.app = _app;
app.registerDispose(this);
midiBus = new MidiBus(_app, inputName, outputName);
midiBus.addMidiListener(this);
@@ -268,29 +268,30 @@ public void changeGrid(int x, int y, LColor c) {
* [Launchpad::NoValidBrightnessError] when brightness values aren't within the valid range
* [Launchpad::NoOutputAllowedError] when output is not enabled
*/
- public void change_all(LColor[] colors) {
+ public void changeAll(LColor[] colors) {
int param1, param2;
// send normal MIDI message to reset rapid LED change pointer
// in this case, set mapping mode to x-y layout (the default)
output(STATUS_CC, STATUS_NIL, GRIDLAYOUT_XY);
-
+
+ int default_color = new LColor().velocity();
// send colors in slices of 2
for(int i = 0; i < 80; i = i + 2) {
try {
param1 = colors[i].velocity();
} catch (ArrayIndexOutOfBoundsException e) {
- param1 = 0;
+ param1 = default_color;
} catch (NullPointerException e) {
- param1 = 0;
+ param1 = default_color;
}
try {
param2 = colors[i+1].velocity();
} catch (ArrayIndexOutOfBoundsException e) {
- param2 = 0;
+ param2 = default_color;
} catch (NullPointerException e) {
- param2 = 0;
+ param2 = default_color;
}
output(STATUS_MULTI, param1, param2);
}
@@ -307,30 +308,31 @@ public void change_all(LColor[] colors) {
* [Launchpad::NoValidBrightnessError] when brightness values aren't within the valid range
* [Launchpad::NoOutputAllowedError] when output is not enabled
*/
- public void change_all(int[] colors) {
+ public void changeAll(int[] colors) {
int param1, param2;
// send normal MIDI message to reset rapid LED change pointer
// in this case, set mapping mode to x-y layout (the default)
output(STATUS_CC, STATUS_NIL, GRIDLAYOUT_XY);
+ int default_color = new LColor().velocity();
// send colors in slices of 2
for(int i = 0; i < 80; i = i + 2) {
try {
param1 = colors[i];
} catch (ArrayIndexOutOfBoundsException e) {
- param1 = 0;
+ param1 = default_color;
} catch (NullPointerException e) {
- param1 = 0;
+ param1 = default_color;
}
try {
param2 = colors[i+1];
}
catch (ArrayIndexOutOfBoundsException e) {
- param2 = 0;
+ param2 = default_color;
} catch (NullPointerException e) {
- param2 = 0;
+ param2 = default_color;
}
output(STATUS_MULTI, param1, param2);
}
@@ -426,13 +428,13 @@ public void buffering_mode(int display_buffer, int update_buffer) {
*
* @param display_buffer which buffer to use for display, defaults to +0+
* @param update_buffer which buffer to use for updates when <tt>:mode</tt> is set to <tt>:buffering</tt>, defaults to +0+ (see change)
- * @param extra values to control FLASHING and COPY
+ * @param flags values to control FLASHING and COPY
*
* Errors raised:
* [Launchpad::NoOutputAllowedError] when output is not enabled
*/
- public void buffering_mode(int display_buffer, int update_buffer, int extra) {
- int data = display_buffer + 4 * update_buffer + 32 + extra;
+ public void buffering_mode(int display_buffer, int update_buffer, int flags) {
+ int data = display_buffer + 4 * update_buffer + 32 + flags;
output(STATUS_CC, STATUS_NIL, data);
}

0 comments on commit 9157f5c

Please sign in to comment.