LXPattern[] patterns;
Effects effects;
MappingTool mappingTool;
-PandaDriver[] pandaBoards;
+GrizzlyOutput[] grizzlies;
PresetManager presetManager;
MidiEngine midiEngine;
// Display configuration mode
boolean mappingMode = false;
boolean debugMode = false;
-DebugUI debugUI;
-boolean uiOn = true;
boolean simulationOn = true;
boolean diagnosticsOn = false;
LXPattern restoreToPattern = null;
logTime("Setup MIDI devices");
// Build output driver
+ grizzlies = new GrizzlyOutput[]{};
try {
- GrizzlyOutput[] grizzlies = buildGrizzlies();
+ grizzlies = buildGrizzlies();
for (LXOutput output : grizzlies) {
lx.addOutput(output);
}
} catch (Exception x) {
x.printStackTrace();
}
+ logTime("Built Grizzly Outputs");
+
+ // Mapping tools
+ mappingTool = new MappingTool(glucose);
- PandaMapping[] pandaMappings = buildPandaList();
- pandaBoards = new PandaDriver[pandaMappings.length];
- int pbi = 0;
- for (PandaMapping pm : pandaMappings) {
- pandaBoards[pbi++] = new PandaDriver(pm.ip, glucose.model, pm);
- }
- mappingTool = new MappingTool(glucose, pandaMappings);
- logTime("Built PandaDriver");
-
// Build overlay UI
- debugUI = new DebugUI(pandaMappings);
- UIContext[] contexts = new UIContext[] {
+ UILayer[] layers = new UILayer[] {
+ // Camera layer
+ new UICameraLayer(lx.ui)
+ .setCenter(TRAILER_WIDTH/2., glucose.model.yMax/2, TRAILER_DEPTH/2.)
+ .setRadius(290).addComponent(new UICubesLayer()),
+
+ // Left controls
uiPatternA = new UIPatternDeck(lx.ui, lx.engine.getDeck(GLucose.LEFT_DECK), "PATTERN A", 4, 4, 140, 324),
new UIBlendMode(4, 332, 140, 86),
new UIEffects(4, 422, 140, 144),
new UITempo(4, 570, 140, 50),
uiSpeed = new UISpeed(4, 624, 140, 50),
+ // Right controls
new UIPatternDeck(lx.ui, lx.engine.getDeck(GLucose.RIGHT_DECK), "PATTERN B", width-144, 4, 140, 324),
uiMidi = new UIMidi(midiEngine, width-144, 332, 140, 158),
- new UIOutput(width-144, 494, 140, 106),
+ new UIOutput(grizzlies, width-144, 494, 140, 106),
+ // Crossfader
uiCrossfader = new UICrossfader(width/2-90, height-90, 180, 86),
+ // Overlays
uiDebugText = new UIDebugText(148, height-138, width-304, 44),
uiMapping = new UIMapping(mappingTool, 4, 4, 140, 324)
};
- uiMapping.setVisible(false);
- lx.ui.addLayer(new UICameraLayer(lx.ui).setCenter(TRAILER_WIDTH/2., glucose.model.yMax/2, TRAILER_DEPTH/2.).setRadius(290).addComponent(new UICubesLayer()));
- for (UIContext context : contexts) {
- lx.ui.addLayer(context);
+ uiMapping.setVisible(false);
+ for (UILayer layer : layers) {
+ lx.ui.addLayer(layer);
}
- logTime("Built overlay UI");
+ logTime("Built UI");
// Load logo image
logo = loadImage("data/logo.png");
+ logTime("Loaded logo image");
println("Total setup: " + (millis() - startMillis) + "ms");
- println("Hit the 'p' key to toggle Panda Board output");
+ println("Hit the 'o' key to toggle live output");
}
/**
background(40);
// Send colors
- color[] sendColors = glucose.getColors();
- if (debugMode) {
- debugUI.maskColors(sendColors);
- }
-
+ color[] sendColors = glucose.getColors();
long gammaStart = System.nanoTime();
// Gamma correction here. Apply a cubic to the brightness
// for better representation of dynamic range
}
long gammaNanos = System.nanoTime() - gammaStart;
- long sendStart = System.nanoTime();
- for (PandaDriver p : pandaBoards) {
- p.send(sendColors);
- }
- long sendNanos = System.nanoTime() - sendStart;
-
+ // Always draw FPS meter
drawFPS();
- if (debugMode) {
- debugUI.draw();
- }
// TODO(mcslee): fix
long drawNanos = System.nanoTime() - drawStart;
long simulationNanos = 0, uiNanos = 0;
if (diagnosticsOn) {
- drawDiagnostics(drawNanos, simulationNanos, uiNanos, gammaNanos, sendNanos);
+ drawDiagnostics(drawNanos, simulationNanos, uiNanos, gammaNanos);
}
}
} else if (displayMode == "B") {
simulationColors = lx.engine.getDeck(GLucose.RIGHT_DECK).getColors();
}
- if (debugMode) {
- debugUI.maskColors(simulationColors);
- }
long simulationStart = System.nanoTime();
if (simulationOn) {
}
}
-void drawDiagnostics(long drawNanos, long simulationNanos, long uiNanos, long gammaNanos, long sendNanos) {
+void drawDiagnostics(long drawNanos, long simulationNanos, long uiNanos, long gammaNanos) {
float ws = 4 / 1000000.;
int thirtyfps = 1000000000 / 30;
int sixtyfps = 1000000000 / 60;
noStroke();
int xp = x;
float hv = 0;
- for (long val : new long[] {lx.timer.drawNanos, simulationNanos, uiNanos, gammaNanos, sendNanos }) {
+ for (long val : new long[] {lx.timer.drawNanos, simulationNanos, uiNanos, gammaNanos, lx.timer.outputNanos }) {
fill(lx.hsb(hv % 360, 100, 80));
rect(xp, y, val * ws, h-1);
hv += 140;
lx.engine.setThreaded(!lx.engine.isThreaded());
}
break;
+ case 'o':
case 'p':
- for (PandaDriver p : pandaBoards) {
- p.toggle();
+ for (LXOutput output : grizzlies) {
+ output.enabled.toggle();
}
break;
case 'q':
simulationOn = !simulationOn;
}
break;
- case 'u':
- if (!midiEngine.isQwertyEnabled()) {
- uiOn = !uiOn;
- }
- break;
- }
-}
-
-/**
- * Top-level mouse event handling
- */
-void mousePressed() {
- if (debugMode) {
- debugUI.mousePressed();
}
}