Skip to content

Commit

Permalink
file organization, page layout change, and other stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
EdzmLeGoat committed Jan 8, 2025
1 parent 1555d92 commit 8d9d41b
Show file tree
Hide file tree
Showing 48 changed files with 231 additions and 145 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
10 changes: 0 additions & 10 deletions src/main/deploy/autoscore/choice.js

This file was deleted.

31 changes: 31 additions & 0 deletions src/main/deploy/autoscore/coralLevel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const levelOne = document.getElementById("L1");
const levelTwo = document.getElementById("L2");
const levelThree = document.getElementById("L3");
const levelFour = document.getElementById("L4");

const levelList = [levelOne, levelTwo, levelThree, levelFour];

const coralText = document.getElementById("coralText");
levelList.map(level => {
level.onmouseenter = () => {
if(!coralSelected) {
document.getElementById("coral").src = `coralLevelImages/coral${level.id}.png`;
}
}
level.onmouseleave = () => {
if(!coralSelected) {
document.getElementById("coral").src = `coralLevelImages/coralNone.png`;
}
}
level.onclick = () => {
coralSelected = true;
document.getElementById("coral").src = `coralLevelImages/coral${level.id}.png`;
coralLevel = parseInt(level.id.slice(1));
coralText.innerText = `Coral Level: ${coralLevel}`;
if(areaSelected) {
confirmReefButton.innerText = `Score at Level ${level.id} and Area ${reefArea}`;
}
}
});


File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
43 changes: 25 additions & 18 deletions src/main/deploy/autoscore/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,60 @@
</head>
<body>
<div class="choiceContainer" style="display: none">
<div class="Level" id="processorChoice">Processor</div>
<div class="Level" id="reefChoice">Reef</div>
<div class="Button" id="processorChoice">Processor</div>
<div class="Button" id="reefChoice">Reef</div>
</div>
<div class="reefContainer" style="display: none">
<div class="levelContainer">
<div class="Level" id="L1">
<div class="Button" id="L1">
Level 1 Score
</div>
<div class="Level" id="L2">
<div class="Button" id="L2">
Level 2 Score
</div>
<div class="Level" id="L3">
<div class="Button" id="L3">
Level 3 Score
</div>
<div class="Level" id="L4">
<div class="Button" id="L4">
Level 4 Score
</div>
</div>
<div class="imageContainer">
<img src="coralNone.png" alt="" width="256px" height="512px" id="coral">
<img src="coralLevelImages/coralNone.png" alt="" width="256px" height="512px" id="coral">
</div>
<div class="locationContainer" style="display: none">
<div class="imageContainer">
<img src="locationSelectorImages/locationSelectorNone.png" alt="" width="473px" height="411px" id="locationSelect">
<h1>Click on the area you want to go to.</h1>
</div>
</div>
<div class="confirmChoice">
<h1 class="reefText" id="coralText">Coral Level: None</h1>
<h1 class="reefText" id="areaText">Reef Area: None</h1>
<div class="Button" id="confirmText">
Choose Robot Alignment
</div>
</div>
</div>
<div class="processorContainer" style="display: none">
<div class="buttonContainer">
<div class="Level" id="button">
<div class="Button" id="button">
Processor Score
</div>
</div>
<div class="imageContainer">
<img src="processorEmpty.png" alt="" width="512px" height="512px" id="processor">
</div>
</div>
<div class="locationContainer" style="display: none">
<div class="imageContainer">
<img src="locationSelectorNone.png" alt="" width="473px" height="411px" id="locationSelect">
<h1>Click on the area you want to go to.</h1>
<img src="processorImages/processorEmpty.png" alt="" width="1164px" height="837px" id="processor">
</div>
</div>
<div class="screenChangeContainer" style="display: none">
<h1 id="msgDisplayer"></h1>
</div>
<script src="robotCommunication.js"></script>
<script src="reefCommunication.js"></script>
<script src="processorCommunication.js"></script>
<script src="menuControl.js"></script>
<script src="choice.js"></script>
<script src="processor.js"></script>
<script src="reefPlacement.js"></script>
<script src="reefLevel.js"></script>
<script src="coralLevel.js"></script>

</body>
</html>
39 changes: 38 additions & 1 deletion src/main/deploy/autoscore/menuControl.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
const reefContainer = document.querySelector(".reefContainer");
const processorContainer = document.querySelector(".processorContainer");
const confirmReefContainer = document.querySelector(".confirmChoice");
const confirmReefButton = document.getElementById("confirmText");
const locationContainer = document.querySelector(".locationContainer");
const screenChangeContainer = document.querySelector(".screenChangeContainer");
const choiceContainer = document.querySelector(".choiceContainer");

let menu;

let coralLevel = -1;
let reefArea = -1;
let coralSelected = false;
let areaSelected = false;

const changeMenu = (menuVal, screenmsg) => {
menu = menuVal;
reefContainer.style.display = "none";
locationContainer.style.display = "none";
screenChangeContainer.style.display = "none";
processorContainer.style.display = "none";
choiceContainer.style.display = "none";
confirmReefContainer.style.display = "none";
if (menu == "processor") {
processorContainer.style.display = "";
} else if (menu == "reef"){
reefContainer.style.display = "";
} else if (menu == "location pick") {
locationContainer.style.display = "";
confirmReefContainer.style.display = "";
confirmReefButton.innerText = "Choose Robot Alignment";
} else if (menu == "screen change") {
screenChangeContainer.style.display = "";
document.getElementById("msgDisplayer").innerText = screenmsg;
Expand All @@ -28,3 +37,31 @@ const changeMenu = (menuVal, screenmsg) => {
}

changeMenu("choice");

const reefChoice = document.getElementById("reefChoice");
const processorChoice = document.getElementById("processorChoice");

reefChoice.onclick = () => {
changeMenu("reef");
}

processorChoice.onclick = () => {
changeMenu("processor");
}

let reefScoreButtonClickable = true;
confirmReefButton.onclick = async () => {
if(reefScoreButtonClickable) {
reefScoreButtonClickable = false;
confirmReefButton.innerText = "Scoring...";
await scoreReef(reefArea, coralLevel);
confirmReefButton.innerText = "Choose Robot Alignment";
changeMenu("choice");
reefScoreButtonClickable = true;

coralSelected = false;
reefSelected = false;
coralLevel = -1;
document.getElementById("coral").src = `coralLevelImages/coralNone.png`;
}
}
58 changes: 32 additions & 26 deletions src/main/deploy/autoscore/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const processorButton = document.getElementById("button");
const animationIntervals = [];
const animationFPS = 11.25;
const processorImage = document.getElementById("processor");

let processorClickable = true;
processorButton.onmouseenter = () => {
processorImage.style.filter = "brightness(1.25)";
}
Expand All @@ -11,33 +11,39 @@ processorButton.onmouseleave = () => {
processorImage.style.filter = "brightness(1)";
}

processorButton.onclick = () => {
scoreProcessor();
processorImage.style.filter = "brightness(1)";
animationIntervals.map((animation) => {
clearInterval(animation);
})
let frame = 1;
const animationInterval = setInterval(() => {
if(frame == 15) {
console.log("clearing");
changeMenu("choice");
clearInterval(animationInterval);
} else {
if(frame == 14) {
processorImage.src = `processorEmpty.png`;
}
else {
if(frame == 13) {
processorImage.src = `processorr12`;
processorButton.onclick = async () => {
if(processorClickable) {
processorClickable = false;
processorImage.style.filter = "brightness(1)";
animationIntervals.map((animation) => {
clearInterval(animation);
});
let frame = 1;
const animationInterval = setInterval(() => {
if(frame == 15) {
console.log("clearing");
clearInterval(animationInterval);
} else {
if(frame == 14) {
processorImage.src = `processorImages/processorEmpty.png`;
}
else {
processorImage.src = `processorr${frame}.png`;
if(frame == 13) {
processorImage.src = `processorImages/processor12.png`;
}
else {
processorImage.src = `processorImages/processor${frame}.png`;
}
}
frame++;
}
frame++;
}
}, 1000/animationFPS);
console.log(animationInterval);
animationIntervals.push(animationInterval);
}, 1000/animationFPS);
animationIntervals.push(animationInterval);
console.log("calling score processor");
processorButton.innerText = "Scoring...";
await scoreProcessor();
changeMenu("choice");
processorButton.innerText = "Score Processor";
processorClickable = true;
}
}
6 changes: 6 additions & 0 deletions src/main/deploy/autoscore/processorCommunication.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const scoreProcessor = async () => {
console.log("scoring processor");
//communicate with network tables somehow
await new Promise((resolve) => setTimeout(() => resolve(), 3000)); // Simulate asynchronous movement
console.log("await done");
}
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
31 changes: 31 additions & 0 deletions src/main/deploy/autoscore/reefCommunication.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//robot coms part
const moveToReefLocation = async (location) => {
// Call a function to move the robot to the specified reef location
// Replace the following line with your actual implementation
console.log(`Moving robot to ${location}`);
//communicate with network tables somehow
await new Promise((resolve) => setTimeout(() => resolve(), 1500)); // Simulate asynchronous movement
}

const scoreReefLevel = async (level) => {
console.log(`Scoring on level: ${level}`);
//communicate with network tables somehow
await new Promise((resolve) => setTimeout(() => resolve(), 1500)); // Simulate asynchronous movement
}

const scoreReef = async (location, level) => {
await moveToReefLocation(location);
await scoreReefLevel(level);
}

const getAlliance = async () => {
let alliance = "Red"; //temporary
//get alliance from networktables
if(alliance == "Red") {
document.body.style.background = "radial-gradient(circle at 50% 50%, pink, rgb(114, 114, 138))";
} else if(alliance == "Blue") {
document.body.style.background = "radial-gradient(circle at 50% 50%, cornflowerblue, rgb(114, 114, 138))";
}
}

getAlliance();
21 changes: 0 additions & 21 deletions src/main/deploy/autoscore/reefLevel.js

This file was deleted.

Loading

0 comments on commit 8d9d41b

Please sign in to comment.