Fix calibrator attempting to draw when it's activated (outside of draw() function)
This commit is contained in:
parent
a711e2e58d
commit
99388a2786
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user