xxxxxxxxxx
78
// runs page for establishing serial connection
function runSerialPage() {
textSize(20);
text("Press Space Bar to select Serial Port", width / 2 - 100, height / 2 - 10);
}
// runs controlling page
function runControllingPage() {
// renders video
image(flippedVideo, video_x, video_y, videoWidth, videoHeight);
// draws points
push();
translate(width, 0);
scale(-1, 1);
drawKeypoints();
pop();
// draws sections on screen
for (let i = video_x; i <= videoWidth; i += videoWidth / 3) {
stroke(255, 0, 0);
line(i, video_y, i, video_y + videoHeight);
}
for (let i = video_y; i <= videoHeight; i += videoHeight / 3) {
stroke(255, 0, 0);
line(video_x + (videoWidth / 3), i, video_x + 2 * (videoWidth / 3), i);
}
}
// device not turned on
function runTorqueyOff() {
stroke(0);
text("Torqu3-y has been turned off!", width / 2 - 100, height / 2 - 10);
}
// returns true if a point is in a specific region
function withinRight(x, y) {
if (x >= 0 && x < videoWidth / 3 && y >=0 && y < videoHeight) {
return true;
}
return false;
}
function withinTopCenter(x, y) {
if (x > videoWidth / 3 && x < 2 * videoWidth / 3 &&
y >=0 && y < videoHeight / 3) {
return true;
}
return false;
}
function withinLeft(x, y) {
if (x > 2 * videoWidth / 3 && x < videoWidth &&
y >=0 && y < videoHeight ) {
return true;
}
return false;
}
function withinMiddleCenter(x, y) {
if (x > videoWidth / 3 && x < 2 * videoWidth / 3 &&
y > videoHeight / 3 && y < 2 * videoHeight / 3) {
return true;
}
return false;
}
function withinBottomCenter(x, y) {
if (x > videoWidth / 3 && x < 2 * videoWidth / 3 &&
y > 2 * videoHeight / 3 && y < videoHeight) {
return true;
}
return false;
}