|
|
@ -38,12 +38,27 @@ class Calibrator {
|
|
|
|
|
|
|
|
|
|
|
|
void activate() {
|
|
|
|
void activate() {
|
|
|
|
this.active = true;
|
|
|
|
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() {
|
|
|
|
void deactivate() {
|
|
|
|
projector.clear();
|
|
|
|
// Create a command which will restore the screen to what it
|
|
|
|
projector.set(projector.width, 0, this.drawnScreen);
|
|
|
|
// 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;
|
|
|
|
this.active = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|