Two APCs with deck focus and presets lights work on each
[SugarCubes.git] / _Internals.pde
index d616264b7bbb73f62f0677a8875b09f8356ef0e2..2e3af44def2500ec9c9a811261a70fd052603349 100644 (file)
@@ -39,8 +39,8 @@ final float TRAILER_WIDTH = 240;
 final float TRAILER_DEPTH = 97;
 final float TRAILER_HEIGHT = 33;
 
-final int MaxCubeHeight = 7;
-final int NumBackTowers = 9;
+final int MaxCubeHeight = 5;
+final int NumBackTowers = 11;
 
 int targetFramerate = 60;
 int startMillis, lastMillis;
@@ -51,8 +51,8 @@ HeronLX lx;
 LXPattern[] patterns;
 MappingTool mappingTool;
 PandaDriver[] pandaBoards;
+PresetManager presetManager;
 MidiEngine midiEngine;
-color[] threadColors;
 
 // Display configuration mode
 boolean mappingMode = false;
@@ -61,6 +61,7 @@ DebugUI debugUI;
 boolean uiOn = true;
 LXPattern restoreToPattern = null;
 PImage logo;
+float[] hsb = new float[3];
 
 // Handles to UI objects
 UIContext[] overlays;
@@ -121,7 +122,6 @@ void setup() {
   glucose = new GLucose(this, buildModel());
   lx = glucose.lx;
   lx.enableKeyboardTempo();
-  threadColors = new color[lx.total];
   logTime("Built GLucose engine");
   
   // Set the patterns
@@ -134,8 +134,13 @@ void setup() {
   glucose.lx.addEffects(effects(glucose));
   logTime("Built effects");
 
+  // Preset manager
+  presetManager = new PresetManager();
+  logTime("Loaded presets");
+
   // MIDI devices
   midiEngine = new MidiEngine();
+  presetManager.setMidiEngine(midiEngine);
   logTime("Setup MIDI devices");
 
   // Build output driver
@@ -267,12 +272,9 @@ void draw() {
   // Gamma correction here. Apply a cubic to the brightness
   // for better representation of dynamic range
   for (int i = 0; i < sendColors.length; ++i) {
-    float b = brightness(sendColors[i]) / 100.f;
-    sendColors[i] = color(
-      hue(sendColors[i]),
-      saturation(sendColors[i]),
-      (b*b*b) * 100.
-    );
+    lx.RGBtoHSB(sendColors[i], hsb);
+    float b = hsb[2];
+    sendColors[i] = lx.hsb(360.*hsb[0], 100.*hsb[1], 100.*(b*b*b));
   }
   
   // TODO(mcslee): move into GLucose engine