Permalink
Browse files

refactored, added new example, extracted control classes

  • Loading branch information...
1 parent af53a98 commit 8af859f8bfb3342b1db17f63dd6468c72087bea8 @michaelforrest committed Dec 14, 2008
Showing with 3,612 additions and 340 deletions.
  1. +3 −0 README
  2. BIN distribution/MicroKontrol.zip
  3. +13 −50 distribution/src/microkontrol/MicroKontrol.java
  4. +19 −10 distribution/src/microkontrol/MicroKontrolHardware.java
  5. +28 −0 distribution/src/microkontrol/controls/Button.java
  6. +20 −0 distribution/src/microkontrol/controls/Encoder.java
  7. +18 −0 distribution/src/microkontrol/controls/Fader.java
  8. +7 −0 distribution/src/microkontrol/controls/Joystick.java
  9. +4 −1 distribution/src/microkontrol/controls/LCD.java
  10. +5 −0 distribution/src/microkontrol/controls/Pad.java
  11. BIN distribution/web/download/MicroKontrol.zip
  12. +9 −0 distribution/web/examples/MicroKontrolHello/MicroKontrolHello.pde
  13. +11 −0 distribution/web/examples/ReceiveInput/ReceiveInput.pde
  14. +1 −1 distribution/web/index.html
  15. +12 −2 distribution/web/reference/allclasses-frame.html
  16. +12 −2 distribution/web/reference/allclasses-noframe.html
  17. +1 −1 distribution/web/reference/constant-values.html
  18. +1 −1 distribution/web/reference/deprecated-list.html
  19. +1 −1 distribution/web/reference/help-doc.html
  20. +67 −16 distribution/web/reference/index-all.html
  21. +1 −1 distribution/web/reference/index.html
  22. +71 −5 distribution/web/reference/microkontrol/MicroKontrol.Button.html
  23. +33 −5 distribution/web/reference/microkontrol/MicroKontrol.Fader.html
  24. +1 −1 distribution/web/reference/microkontrol/MicroKontrol.Joystick.html
  25. +12 −3 distribution/web/reference/microkontrol/MicroKontrol.Pad.html
  26. +53 −40 distribution/web/reference/microkontrol/MicroKontrol.html
  27. +1 −1 distribution/web/reference/microkontrol/MicroKontrolHardware.ButtonView.html
  28. +1 −1 distribution/web/reference/microkontrol/MicroKontrolHardware.LCDView.html
  29. +3 −3 distribution/web/reference/microkontrol/MicroKontrolHardware.html
  30. +298 −0 distribution/web/reference/microkontrol/controls/Button.html
  31. +276 −0 distribution/web/reference/microkontrol/controls/Encoder.html
  32. +276 −0 distribution/web/reference/microkontrol/controls/Fader.html
  33. +229 −0 distribution/web/reference/microkontrol/controls/Joystick.html
  34. +26 −5 distribution/web/reference/microkontrol/controls/LCD.html
  35. +239 −0 distribution/web/reference/microkontrol/controls/Pad.html
  36. +12 −2 distribution/web/reference/microkontrol/controls/package-frame.html
  37. +21 −1 distribution/web/reference/microkontrol/controls/package-summary.html
  38. +4 −2 distribution/web/reference/microkontrol/controls/package-tree.html
  39. +1 −1 distribution/web/reference/microkontrol/package-frame.html
  40. +1 −1 distribution/web/reference/microkontrol/package-summary.html
  41. +2 −6 distribution/web/reference/microkontrol/package-tree.html
  42. +1 −1 distribution/web/reference/overview-frame.html
  43. +1 −1 distribution/web/reference/overview-summary.html
  44. +5 −5 distribution/web/reference/overview-tree.html
  45. +9 −0 examples/MicroKontrolHello/MicroKontrolHello.pde
  46. +27 −0 examples/ReceiveInput/ReceiveInput.pde
  47. +12 −2 reference/allclasses-frame.html
  48. +12 −2 reference/allclasses-noframe.html
  49. +1 −1 reference/constant-values.html
  50. +1 −1 reference/deprecated-list.html
  51. +1 −1 reference/help-doc.html
  52. +67 −16 reference/index-all.html
  53. +1 −1 reference/index.html
  54. +71 −5 reference/microkontrol/MicroKontrol.Button.html
  55. +33 −5 reference/microkontrol/MicroKontrol.Fader.html
  56. +1 −1 reference/microkontrol/MicroKontrol.Joystick.html
  57. +12 −3 reference/microkontrol/MicroKontrol.Pad.html
  58. +53 −40 reference/microkontrol/MicroKontrol.html
  59. +1 −1 reference/microkontrol/MicroKontrolHardware.ButtonView.html
  60. +1 −1 reference/microkontrol/MicroKontrolHardware.LCDView.html
  61. +3 −3 reference/microkontrol/MicroKontrolHardware.html
  62. +298 −0 reference/microkontrol/controls/Button.html
  63. +276 −0 reference/microkontrol/controls/Encoder.html
  64. +276 −0 reference/microkontrol/controls/Fader.html
  65. +229 −0 reference/microkontrol/controls/Joystick.html
  66. +26 −5 reference/microkontrol/controls/LCD.html
  67. +239 −0 reference/microkontrol/controls/Pad.html
  68. +12 −2 reference/microkontrol/controls/package-frame.html
  69. +21 −1 reference/microkontrol/controls/package-summary.html
  70. +4 −2 reference/microkontrol/controls/package-tree.html
  71. +1 −1 reference/microkontrol/package-frame.html
  72. +1 −1 reference/microkontrol/package-summary.html
  73. +2 −6 reference/microkontrol/package-tree.html
  74. +1 −1 reference/overview-frame.html
  75. +1 −1 reference/overview-summary.html
  76. +5 −5 reference/overview-tree.html
  77. +13 −50 src/microkontrol/MicroKontrol.java
  78. +19 −11 src/microkontrol/MicroKontrolHardware.java
  79. +28 −0 src/microkontrol/controls/Button.java
  80. +20 −0 src/microkontrol/controls/Encoder.java
  81. +18 −0 src/microkontrol/controls/Fader.java
  82. +7 −0 src/microkontrol/controls/Joystick.java
  83. +4 −1 src/microkontrol/controls/LCD.java
  84. +5 −0 src/microkontrol/controls/Pad.java
View
3 README
@@ -0,0 +1,3 @@
+This is a library for use with Processing (processing.org)
+
+Install by dropping the
Binary file not shown.
@@ -22,7 +22,8 @@
package microkontrol;
-import java.util.*;
+import java.util.Hashtable;
+import java.util.Observable;
import microkontrol.controls.*;
import processing.core.PApplet;
@@ -34,27 +35,32 @@
public class MicroKontrol {
PApplet applet;
+ public final String VERSION = "0.1.0";
- Hashtable<String, Button> buttons = new Hashtable<String, Button>();
+ private MicroKontrolHardware hardware;
public Pad[] pads = new Pad[16];
+ public Hashtable<String, Button> buttons = new Hashtable<String, Button>();
+ public Encoder[] encoders = new Encoder[9];
public Fader[] faders = new Fader[8];
public LCD[] lcds = new LCD[9];
public LCD main;
- public final String VERSION = "0.1.0";
+ public Joystick joystick = new Joystick();
- private MicroKontrolHardware hardware;
public MicroKontrol(PApplet applet) {
this.applet = applet;
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < pads.length; i++)
pads[i] = new Pad();
- for (int i = 0; i < 8; i++)
+ for(int i = 0; i < encoders.length; i++)
+ encoders[i] = new Encoder();
+
+ for (int i = 0; i < faders.length; i++)
faders[i] = new Fader();
- for (int i = 0; i < 9; i++)
+ for (int i = 0; i < lcds.length; i++)
lcds[i] = new LCD();
main = lcds[8];
@@ -80,49 +86,6 @@ void go() {
lcds[i].setText(lcdText[i]);
}
- public class Button extends Observable {
- boolean isOn = false;
-
- void set(boolean on) {
- isOn = on;
- update();
- }
-
- void toggle() {
- PApplet.println("Toggling button");
- isOn = !isOn;
- update();
- }
-
- void update() {
- setChanged();
- notifyObservers();
- }
- }
-
- public class Pad extends Button {
-
- }
-
- public class Joystick {
-
- }
-
- public class Fader extends Observable {
- int value;
- float getProportion() {
- return (float) value / 127.0f;
- }
-
- void set(int value) {
- this.value = value;
- setChanged();
- notifyObservers();
- }
- }
-
-
-
/**
* return the version of the library.
*
@@ -1,11 +1,17 @@
package microkontrol;
-import java.util.*;
-import microkontrol.controls.*;
+import java.util.Hashtable;
+import java.util.Observable;
+import java.util.Observer;
-import processing.core.*;
-import rwmidi.*;
+import microkontrol.controls.*;
+import processing.core.PApplet;
+import rwmidi.MidiInput;
+import rwmidi.MidiOutput;
+import rwmidi.Note;
+import rwmidi.RWMidi;
+import rwmidi.SysexMessage;
public class MicroKontrolHardware {
private static String INPUT_DEVICE_A = findInput("PORT A(.*)KORG INC.");
@@ -55,7 +61,7 @@ void addLCDViews() {
void addPadViews() {
pads = new ButtonView[model.pads.length];
for (int i = 0; i < model.pads.length; i++) {
- MicroKontrol.Button pad = model.pads[i];
+ Button pad = model.pads[i];
// pads have incremental IDs - this maps onto how the hardware works
// (and hence is a view-based id)
pads[i] = new ButtonView(i, pad);
@@ -68,17 +74,17 @@ void addPadViews() {
int ON = 32;
int ONE_SHOT = 64;
int BLINK = 96;
- MicroKontrol.Button pad;
+ Button pad;
private int id;
- ButtonView(int id, MicroKontrol.Button pad) {
+ ButtonView(int id, Button pad) {
this.id = id;
this.pad = pad;
pad.addObserver(this);
}
public void update(Observable o, Object e) {
- int state = pad.isOn ? ON : OFF;
+ int state = pad.isOn() ? ON : OFF;
turn(state);
}
@@ -155,8 +161,11 @@ void receivePedal(byte state) {
boolean on = state == (byte) 127;
}
- void receiveEncoder(byte id, byte change) {
+ void receiveEncoder(byte id, byte changeCode) {
+ int change = (changeCode >= 64) ? -(128 - changeCode) : changeCode;
+ PApplet.println("encoder value " + changeCode + " ->" + change);
+ model.encoders[id].set(change);
}
void receiveFader(byte id, byte value) {
@@ -167,7 +176,7 @@ void receivePad(byte info) {
int id = info & 0x0f;
int conditionBit = 64 & info;
if (conditionBit == 0) return; // off state
- ((MicroKontrol.Pad) model.pads[id]).toggle();
+ ((Pad) model.pads[id]).toggle();
}
/***************************************************************************
@@ -0,0 +1,28 @@
+package microkontrol.controls;
+
+import java.util.Observable;
+
+import processing.core.PApplet;
+
+public class Button extends Observable {
+ boolean isOn = false;
+
+ public void set(boolean on) {
+ isOn = on;
+ update();
+ }
+ public boolean isOn(){
+ return isOn;
+ }
+ public void toggle() {
+ PApplet.println("Toggling button");
+ isOn = !isOn;
+ update();
+ }
+
+ void update() {
+ setChanged();
+ notifyObservers();
+ }
+}
+
@@ -0,0 +1,20 @@
+package microkontrol.controls;
+
+import java.util.Observable;
+
+public class Encoder extends Observable {
+
+ private int change;
+
+ public void set(int change) {
+ this.change = change;
+ setChanged();
+ notifyObservers();
+ }
+
+ public int getChange() {
+ return change;
+ }
+
+
+}
@@ -0,0 +1,18 @@
+package microkontrol.controls;
+
+import java.util.Observable;
+
+public class Fader extends Observable {
+ int value;
+ public float getProportion() {
+ return (float) value / 127.0f;
+ }
+
+ public void set(int value) {
+ this.value = value;
+ setChanged();
+ notifyObservers();
+ }
+}
+
+
@@ -0,0 +1,7 @@
+package microkontrol.controls;
+
+import java.util.Observable;
+
+public class Joystick extends Observable {
+
+}
@@ -27,7 +27,10 @@ public void setColor(String color){
this.colour = color;
update();
}
-
+ public void set(String text, String color){
+ this.text = text;
+ setColor(color);
+ }
public void update() {
setChanged();
notifyObservers();
@@ -0,0 +1,5 @@
+package microkontrol.controls;
+
+public class Pad extends Button {
+
+}
Binary file not shown.
@@ -0,0 +1,9 @@
+import rwmidi.*;
+import microkontrol.*;
+import microkontrol.controls.*;
+MicroKontrol microKontrol;
+void setup(){
+ microKontrol = new MicroKontrol(this);
+ microKontrol.main.setText("Hello!");
+ microKontrol.main.setColor(LCD.GREEN);
+}
@@ -0,0 +1,11 @@
+import rwmidi.*;
+import microkontrol.*;
+import microkontrol.controls.*;
+MicroKontrol microKontrol;
+void setup(){
+ microKontrol = new MicroKontrol(this);
+ microKontrol.main.setText("Move");
+ microKontrol.main.setColor(LCD.RED);
+ microKontrol.lcds[0].setText("faders");
+ microKontrol.lcds[0].setColor(LCD.RED);
+}
@@ -73,7 +73,7 @@ <h2>Installation</h2>
<h2>Examples</h2>
<p>Find a list of examples in the current distribution of MicroKontrol, or have a look at them by following the links below.</p>
<ul>
- <li><a href="examples/Demo/Demo.pde">Demo</a></li>
+ <li><a href="examples/MicroKontrolHello/MicroKontrolHello.pde">MicroKontrolHello</a></li> <li><a href="examples/ReceiveInput/ReceiveInput.pde">ReceiveInput</a></li>
</ul>
</div>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.5.0_16) on Sun Dec 14 15:29:04 GMT 2008 -->
+<!-- Generated by javadoc (build 1.5.0_16) on Sun Dec 14 16:56:47 GMT 2008 -->
<TITLE>
All Classes (Javadocs: MicroKontrol)
</TITLE>
@@ -20,12 +20,22 @@
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
<TR>
-<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="microkontrol/controls/LCD.html" title="class in microkontrol.controls" target="classFrame">LCD</A>
+<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="microkontrol/controls/Button.html" title="class in microkontrol.controls" target="classFrame">Button</A>
+<BR>
+<A HREF="microkontrol/controls/Encoder.html" title="class in microkontrol.controls" target="classFrame">Encoder</A>
+<BR>
+<A HREF="microkontrol/controls/Fader.html" title="class in microkontrol.controls" target="classFrame">Fader</A>
+<BR>
+<A HREF="microkontrol/controls/Joystick.html" title="class in microkontrol.controls" target="classFrame">Joystick</A>
+<BR>
+<A HREF="microkontrol/controls/LCD.html" title="class in microkontrol.controls" target="classFrame">LCD</A>
<BR>
<A HREF="microkontrol/MicroKontrol.html" title="class in microkontrol" target="classFrame">MicroKontrol</A>
<BR>
<A HREF="microkontrol/MicroKontrolHardware.html" title="class in microkontrol" target="classFrame">MicroKontrolHardware</A>
<BR>
+<A HREF="microkontrol/controls/Pad.html" title="class in microkontrol.controls" target="classFrame">Pad</A>
+<BR>
</FONT></TD>
</TR>
</TABLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.5.0_16) on Sun Dec 14 15:29:04 GMT 2008 -->
+<!-- Generated by javadoc (build 1.5.0_16) on Sun Dec 14 16:56:47 GMT 2008 -->
<TITLE>
All Classes (Javadocs: MicroKontrol)
</TITLE>
@@ -20,12 +20,22 @@
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
<TR>
-<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="microkontrol/controls/LCD.html" title="class in microkontrol.controls">LCD</A>
+<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="microkontrol/controls/Button.html" title="class in microkontrol.controls">Button</A>
+<BR>
+<A HREF="microkontrol/controls/Encoder.html" title="class in microkontrol.controls">Encoder</A>
+<BR>
+<A HREF="microkontrol/controls/Fader.html" title="class in microkontrol.controls">Fader</A>
+<BR>
+<A HREF="microkontrol/controls/Joystick.html" title="class in microkontrol.controls">Joystick</A>
+<BR>
+<A HREF="microkontrol/controls/LCD.html" title="class in microkontrol.controls">LCD</A>
<BR>
<A HREF="microkontrol/MicroKontrol.html" title="class in microkontrol">MicroKontrol</A>
<BR>
<A HREF="microkontrol/MicroKontrolHardware.html" title="class in microkontrol">MicroKontrolHardware</A>
<BR>
+<A HREF="microkontrol/controls/Pad.html" title="class in microkontrol.controls">Pad</A>
+<BR>
</FONT></TD>
</TR>
</TABLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.5.0_16) on Sun Dec 14 15:29:04 GMT 2008 -->
+<!-- Generated by javadoc (build 1.5.0_16) on Sun Dec 14 16:56:47 GMT 2008 -->
<TITLE>
Constant Field Values (Javadocs: MicroKontrol)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.5.0_16) on Sun Dec 14 15:29:04 GMT 2008 -->
+<!-- Generated by javadoc (build 1.5.0_16) on Sun Dec 14 16:56:47 GMT 2008 -->
<TITLE>
Deprecated List (Javadocs: MicroKontrol)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.5.0_16) on Sun Dec 14 15:29:04 GMT 2008 -->
+<!-- Generated by javadoc (build 1.5.0_16) on Sun Dec 14 16:56:47 GMT 2008 -->
<TITLE>
API Help (Javadocs: MicroKontrol)
</TITLE>
Oops, something went wrong.

0 comments on commit 8af859f

Please sign in to comment.