Fix calibrator attempting to draw when it's activated (outside of draw() function)

master
jan 7 years ago
parent a711e2e58d
commit 99388a2786

@ -38,12 +38,27 @@ class Calibrator {
void activate() {
this.active = true;
this.drawnScreen = projector.get(0, 0, projector.width, projector.height);
// Tell the projector that we want to save the state of the screen
// next time it draws
ProjectorCommand saveCommand = (ProjectorApplet p) -> {
this.drawnScreen = p.get(0, 0, p.width, p.height);
return true;
};
projector.commandQueue.add(saveCommand);
}
void deactivate() {
projector.clear();
projector.set(projector.width, 0, this.drawnScreen);
// Create a command which will restore the screen to what it
// looked like before we started calibrating
ProjectorCommand restore_command = (ProjectorApplet p) -> {
p.clear();
p.set(0, 0, this.drawnScreen);
return true;
};
// Insert the restore command at the front of the queue
projector.commandQueue.add(0, restore_command);
this.active = false;
}

Loading…
Cancel
Save