Skip to content

Commit

Permalink
map bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaysathvik committed Jan 14, 2024
1 parent 7659641 commit 286bd26
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 188 deletions.

This file was deleted.

Binary file added web/assests/Slice 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed web/assests/compass.png
Binary file not shown.
Binary file removed web/assests/gyroscale.png
Binary file not shown.
3 changes: 2 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ <h4 class="mode-value" id="mode-value"></h4>
</div>
</div>
<div class="battery">
<img src="./assests/Battery.png" alt="battery" />
<img src="./assests/Slice 2.png" alt="battery" />
<div id="battery-value-bar"></div>
<div class="battery-text">
<h4 class="battery-status-text">Battery</h4>
<h4 class="battery-value" id="battery-value"></h4>
Expand Down
55 changes: 44 additions & 11 deletions web/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
async function check_battery() {
const output = await eel.check_battery()();
var output = await eel.check_battery()();
document.getElementById("battery-value").innerHTML = output + "%";
document.getElementById("battery-value2").innerHTML = output + "%";
if (output == 0) {
output = 0;
} else {
output = (2.25 * output) / 100;
console.log(output);
}

if (output < 0.45) {
document.getElementById("battery-value-bar").style.backgroundColor =
"#ff3b30";
} else if (output <= 1.125 && output > 0.45) {
document.getElementById("battery-value-bar").style.backgroundColor =
"#ffcc0a";
}
document.getElementById("battery-value-bar").style.width = output + "vw";
}

async function check_altitude() {
Expand Down Expand Up @@ -44,7 +59,7 @@ async function check_status() {
async function Ground_speed() {
const output = await eel.ground_speed()();
document.getElementById("ground-speed-value").innerHTML =
output.toFixed(2) + " m/s";
output.toFixed(1) + " m/s";
}

async function arm() {
Expand Down Expand Up @@ -159,8 +174,6 @@ async function mission_check() {
async function check_location() {
latitude = await eel.check_location_lat()();
longitude = await eel.check_location_lon()();
console.log(latitude);
console.log(longitude);
document.getElementById("latitude-value2").innerHTML = latitude.toFixed(5);
document.getElementById("longitude-value2").innerHTML = longitude.toFixed(5);
}
Expand Down Expand Up @@ -213,25 +226,45 @@ async function location_coordinates() {
.addEventListener("click", async function () {
await eel.set_status("ACTIVE")();
await eel.set_mode("GUIDED")();
for (let i = 1; i < markers.length; ) {
for (let i = 1; i < markers.length;i++ ) {
var lat = markers[i]._latlng.lat;
var lon = markers[i]._latlng.lng;
console.log(lat);
console.log(lon);
await eel.set_mission(lat, lon, 10)();
// while (true) {
// latitude = await eel.check_location_lat()();
// longitude = await eel.check_location_lon()();
// if (
// latitude.toFixed(4) == lat.toFixed(4) &&
// longitude.toFixed(4) == lon.toFixed(4)
// ) {
// if (i >= 2) {
// markers.splice(i - 1, i);
// }
// i++;
// break;
// }
// }
const coordinateTolerance = 0.0001; // Adjust the tolerance as needed

while (true) {
latitude = await eel.check_location_lat()();
longitude = await eel.check_location_lon()();

if (
latitude.toFixed(4) == lat.toFixed(4) &&
longitude.toFixed(4) == lon.toFixed(4)
Math.abs(latitude - lat) < coordinateTolerance &&
Math.abs(longitude - lon) < coordinateTolerance
) {
if (i >= 2) {
markers.splice(i - 1, i);
}
i++;
// if (i >= 2) {
// markers.splice(i - 3, 1); // Fix for removing only one element
// }
// i++;
break;
}

// Introduce a delay or yield control to prevent blocking the event loop
await new Promise((resolve) => setTimeout(resolve, 100));
}
}
});
Expand Down
16 changes: 13 additions & 3 deletions web/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,30 @@ input {
.battery {
width: 12vw;
height: 10vh;
padding-left: 6vw;
display: flex;
justify-content: center;
align-items: center;
}

.battery img {
max-width: 13vw;
max-height: 13vh;
max-width: 3vw;
max-height: 6vh;
margin-left: -4vw;
}

#battery-value-bar {
position: absolute;
top: 4.5vh;
left: 43.42vw;
background-color: #34c759;
height: 2vh;
border-radius: 4px;
}

.battery-text {
display: flex;
margin-left: -2.5vw;
margin-left: 1vw;
flex-direction: column;
}

Expand Down

0 comments on commit 286bd26

Please sign in to comment.