Radar code for detecting objects with ultrasonics - Follow Up Deployment
Browse files- index.html +278 -261
index.html
CHANGED
|
@@ -3,314 +3,331 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
<style>
|
| 10 |
-
.
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
overflow: hidden;
|
| 15 |
-
transition: all 0.3s ease;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
.
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
-
.
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
|
| 28 |
-
.
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
-
.
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
}
|
| 37 |
|
| 38 |
-
.
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
|
| 42 |
-
.
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
| 52 |
}
|
| 53 |
|
| 54 |
-
.
|
| 55 |
-
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
.history-btn {
|
| 59 |
-
transition: all 0.3s ease;
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
.history-panel {
|
| 63 |
-
transition: all 0.3s ease;
|
| 64 |
-
transform: translateX(100%);
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
.history-panel.active {
|
| 68 |
-
transform: translateX(0);
|
| 69 |
}
|
| 70 |
</style>
|
| 71 |
</head>
|
| 72 |
-
<body class="bg-
|
| 73 |
-
<div class="
|
| 74 |
-
<
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
</div>
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
<i class="fas fa-backspace"></i>
|
| 86 |
-
</button>
|
| 87 |
-
<button class="btn-operator btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendOperator('/')">/</button>
|
| 88 |
-
|
| 89 |
-
<button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendNumber('7')">7</button>
|
| 90 |
-
<button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendNumber('8')">8</button>
|
| 91 |
-
<button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendNumber('9')">9</button>
|
| 92 |
-
<button class="btn-operator btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendOperator('*')">×</button>
|
| 93 |
|
| 94 |
-
<
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
<
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
-
<
|
| 105 |
-
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
</div>
|
| 108 |
-
|
| 109 |
-
<!-- History Button -->
|
| 110 |
-
<button id="history-btn" class="history-btn absolute -left-14 top-4 bg-slate-700 text-white p-2 rounded-full hover:bg-slate-600" onclick="toggleHistory()">
|
| 111 |
-
<i class="fas fa-history"></i>
|
| 112 |
-
</button>
|
| 113 |
</div>
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
</div>
|
| 123 |
-
<ul id="history-list" class="text-slate-300 space-y-2"></ul>
|
| 124 |
</div>
|
| 125 |
</div>
|
| 126 |
|
| 127 |
<script>
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
// DOM elements
|
| 136 |
-
const currentOperandElement = document.getElementById('current-operand');
|
| 137 |
-
const previousOperandElement = document.getElementById('previous-operand');
|
| 138 |
-
const historyList = document.getElementById('history-list');
|
| 139 |
-
const historyPanel = document.getElementById('history-panel');
|
| 140 |
-
const historyBtn = document.getElementById('history-btn');
|
| 141 |
-
|
| 142 |
-
// Update display
|
| 143 |
-
function updateDisplay() {
|
| 144 |
-
currentOperandElement.innerText = currentOperand;
|
| 145 |
-
if (operation != null) {
|
| 146 |
-
previousOperandElement.innerText = `${previousOperand} ${operation}`;
|
| 147 |
-
} else {
|
| 148 |
-
previousOperandElement.innerText = previousOperand;
|
| 149 |
-
}
|
| 150 |
-
}
|
| 151 |
-
|
| 152 |
-
// Append number
|
| 153 |
-
function appendNumber(number) {
|
| 154 |
-
if (currentOperand === '0' || resetScreen) {
|
| 155 |
-
currentOperand = '';
|
| 156 |
-
resetScreen = false;
|
| 157 |
-
}
|
| 158 |
-
|
| 159 |
-
// Prevent multiple leading zeros
|
| 160 |
-
if (number === '0' && currentOperand === '0') return;
|
| 161 |
-
|
| 162 |
-
currentOperand += number;
|
| 163 |
-
updateDisplay();
|
| 164 |
-
}
|
| 165 |
-
|
| 166 |
-
// Append decimal
|
| 167 |
-
function appendDecimal() {
|
| 168 |
-
if (resetScreen) {
|
| 169 |
-
currentOperand = '0';
|
| 170 |
-
resetScreen = false;
|
| 171 |
-
}
|
| 172 |
-
|
| 173 |
-
if (currentOperand.includes('.')) return;
|
| 174 |
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
currentOperand += '.';
|
| 180 |
-
updateDisplay();
|
| 181 |
-
}
|
| 182 |
-
|
| 183 |
-
// Append operator
|
| 184 |
-
function appendOperator(operator) {
|
| 185 |
-
if (currentOperand === '' && previousOperand === '') return;
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
| 191 |
}
|
| 192 |
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
}
|
| 229 |
|
| 230 |
-
//
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
}
|
| 236 |
-
localStorage.setItem('calculatorHistory', JSON.stringify(calculationHistory));
|
| 237 |
-
updateHistory();
|
| 238 |
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
}
|
| 245 |
-
|
| 246 |
-
// Clear all
|
| 247 |
-
function clearAll() {
|
| 248 |
-
currentOperand = '0';
|
| 249 |
-
previousOperand = '';
|
| 250 |
-
operation = undefined;
|
| 251 |
-
updateDisplay();
|
| 252 |
-
}
|
| 253 |
-
|
| 254 |
-
// Delete last character
|
| 255 |
-
function deleteLastChar() {
|
| 256 |
-
if (currentOperand.length === 1 || (currentOperand.length === 2 && currentOperand.startsWith('-'))) {
|
| 257 |
-
currentOperand = '0';
|
| 258 |
-
} else {
|
| 259 |
-
currentOperand = currentOperand.slice(0, -1);
|
| 260 |
-
}
|
| 261 |
-
updateDisplay();
|
| 262 |
-
}
|
| 263 |
-
|
| 264 |
-
// Update history display
|
| 265 |
-
function updateHistory() {
|
| 266 |
-
historyList.innerHTML = '';
|
| 267 |
-
calculationHistory.forEach(item => {
|
| 268 |
-
const li = document.createElement('li');
|
| 269 |
-
li.className = 'py-2 px-3 bg-slate-700 rounded-lg hover:bg-slate-600 cursor-pointer';
|
| 270 |
-
li.textContent = item;
|
| 271 |
-
li.onclick = () => {
|
| 272 |
-
// When clicking a history item, use it as the current operand
|
| 273 |
-
const parts = item.split(' = ');
|
| 274 |
-
if (parts.length === 2) {
|
| 275 |
-
currentOperand = parts[1];
|
| 276 |
-
updateDisplay();
|
| 277 |
-
}
|
| 278 |
-
};
|
| 279 |
-
historyList.appendChild(li);
|
| 280 |
-
});
|
| 281 |
-
}
|
| 282 |
-
|
| 283 |
-
// Clear history
|
| 284 |
-
function clearHistory() {
|
| 285 |
-
calculationHistory = [];
|
| 286 |
-
localStorage.setItem('calculatorHistory', JSON.stringify(calculationHistory));
|
| 287 |
-
updateHistory();
|
| 288 |
-
}
|
| 289 |
-
|
| 290 |
-
// Toggle history panel
|
| 291 |
-
function toggleHistory() {
|
| 292 |
-
historyPanel.classList.toggle('active');
|
| 293 |
-
historyBtn.classList.toggle('bg-slate-600');
|
| 294 |
-
}
|
| 295 |
-
|
| 296 |
-
// Keyboard support
|
| 297 |
-
document.addEventListener('keydown', (e) => {
|
| 298 |
-
if (e.key >= '0' && e.key <= '9') appendNumber(e.key);
|
| 299 |
-
else if (e.key === '.') appendDecimal();
|
| 300 |
-
else if (e.key === '+' || e.key === '-' || e.key === '*' || e.key === '/') {
|
| 301 |
-
appendOperator(e.key);
|
| 302 |
-
}
|
| 303 |
-
else if (e.key === 'Enter' || e.key === '=') {
|
| 304 |
-
e.preventDefault();
|
| 305 |
-
calculate();
|
| 306 |
-
}
|
| 307 |
-
else if (e.key === 'Escape') clearAll();
|
| 308 |
-
else if (e.key === 'Backspace') deleteLastChar();
|
| 309 |
});
|
| 310 |
-
|
| 311 |
-
// Initialize
|
| 312 |
-
updateDisplay();
|
| 313 |
-
updateHistory();
|
| 314 |
</script>
|
| 315 |
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Aragoorn/2-3" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 316 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Ultrasonic Radar Detection System</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
<style>
|
| 10 |
+
.radar {
|
| 11 |
+
position: relative;
|
| 12 |
+
width: 300px;
|
| 13 |
+
height: 300px;
|
| 14 |
+
border-radius: 50%;
|
| 15 |
+
background: linear-gradient(to bottom, #0a2e38 0%, #1b1b2f 100%);
|
| 16 |
+
box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
|
| 17 |
overflow: hidden;
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
+
.radar::before {
|
| 21 |
+
content: '';
|
| 22 |
+
position: absolute;
|
| 23 |
+
top: 50%;
|
| 24 |
+
left: 50%;
|
| 25 |
+
transform: translate(-50%, -50%);
|
| 26 |
+
width: 10px;
|
| 27 |
+
height: 10px;
|
| 28 |
+
background: #00ff00;
|
| 29 |
+
border-radius: 50%;
|
| 30 |
+
z-index: 10;
|
| 31 |
}
|
| 32 |
|
| 33 |
+
.radar::after {
|
| 34 |
+
content: '';
|
| 35 |
+
position: absolute;
|
| 36 |
+
top: 50%;
|
| 37 |
+
left: 50%;
|
| 38 |
+
transform: translate(-50%, -50%);
|
| 39 |
+
width: 5px;
|
| 40 |
+
height: 5px;
|
| 41 |
+
background: #00ff00;
|
| 42 |
+
border-radius: 50%;
|
| 43 |
+
box-shadow: 0 0 5px #00ff00;
|
| 44 |
+
z-index: 10;
|
| 45 |
}
|
| 46 |
|
| 47 |
+
.radar-scan {
|
| 48 |
+
position: absolute;
|
| 49 |
+
top: 50%;
|
| 50 |
+
left: 50%;
|
| 51 |
+
transform: translate(-50%, -50%);
|
| 52 |
+
width: 100%;
|
| 53 |
+
height: 100%;
|
| 54 |
+
border-radius: 50%;
|
| 55 |
+
background: linear-gradient(45deg, transparent 49%, rgba(0, 255, 0, 0.2) 50%, transparent 51%);
|
| 56 |
+
animation: rotate 4s linear infinite;
|
| 57 |
}
|
| 58 |
|
| 59 |
+
.radar-circle {
|
| 60 |
+
position: absolute;
|
| 61 |
+
top: 50%;
|
| 62 |
+
left: 50%;
|
| 63 |
+
transform: translate(-50%, -50%);
|
| 64 |
+
border: 1px solid rgba(0, 255, 0, 0.3);
|
| 65 |
+
border-radius: 50%;
|
| 66 |
}
|
| 67 |
|
| 68 |
+
.radar-line {
|
| 69 |
+
position: absolute;
|
| 70 |
+
top: 50%;
|
| 71 |
+
left: 50%;
|
| 72 |
+
transform-origin: left center;
|
| 73 |
+
width: 50%;
|
| 74 |
+
height: 1px;
|
| 75 |
+
background: rgba(0, 255, 0, 0.5);
|
| 76 |
}
|
| 77 |
|
| 78 |
+
.object {
|
| 79 |
+
position: absolute;
|
| 80 |
+
width: 8px;
|
| 81 |
+
height: 8px;
|
| 82 |
+
background: #00ff00;
|
| 83 |
+
border-radius: 50%;
|
| 84 |
+
transform: translate(-50%, -50%);
|
| 85 |
+
box-shadow: 0 0 10px #00ff00;
|
| 86 |
+
z-index: 5;
|
| 87 |
}
|
| 88 |
|
| 89 |
+
@keyframes rotate {
|
| 90 |
+
0% { transform: translate(-50%, -50%) rotate(0deg); }
|
| 91 |
+
100% { transform: translate(-50%, -50%) rotate(360deg); }
|
| 92 |
}
|
| 93 |
|
| 94 |
+
@keyframes pulse {
|
| 95 |
+
0% { opacity: 0.3; }
|
| 96 |
+
50% { opacity: 1; }
|
| 97 |
+
100% { opacity: 0.3; }
|
| 98 |
}
|
| 99 |
|
| 100 |
+
.distance-indicator {
|
| 101 |
+
animation: pulse 2s infinite;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
}
|
| 103 |
</style>
|
| 104 |
</head>
|
| 105 |
+
<body class="bg-gray-900 text-gray-100 min-h-screen flex flex-col items-center justify-center p-4">
|
| 106 |
+
<div class="max-w-4xl w-full">
|
| 107 |
+
<h1 class="text-3xl font-bold text-center mb-6 text-cyan-400">
|
| 108 |
+
<i class="fas fa-radar mr-2"></i> Ultrasonic Radar Detection System
|
| 109 |
+
</h1>
|
| 110 |
+
|
| 111 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
| 112 |
+
<div class="flex flex-col items-center">
|
| 113 |
+
<div class="radar mb-6">
|
| 114 |
+
<div class="radar-circle" style="width: 80%; height: 80%;"></div>
|
| 115 |
+
<div class="radar-circle" style="width: 60%; height: 60%;"></div>
|
| 116 |
+
<div class="radar-circle" style="width: 40%; height: 40%;"></div>
|
| 117 |
+
<div class="radar-circle" style="width: 20%; height: 20%;"></div>
|
| 118 |
+
|
| 119 |
+
<div class="radar-line" style="transform: translate(-50%, -50%) rotate(0deg);"></div>
|
| 120 |
+
<div class="radar-line" style="transform: translate(-50%, -50%) rotate(90deg);"></div>
|
| 121 |
+
<div class="radar-line" style="transform: translate(-50%, -50%) rotate(45deg);"></div>
|
| 122 |
+
<div class="radar-line" style="transform: translate(-50%, -50%) rotate(135deg);"></div>
|
| 123 |
+
|
| 124 |
+
<div class="radar-scan"></div>
|
| 125 |
+
|
| 126 |
+
<!-- Objects will be added here by JavaScript -->
|
| 127 |
+
</div>
|
| 128 |
+
|
| 129 |
+
<div class="flex space-x-4 mb-6">
|
| 130 |
+
<button id="startBtn" class="px-6 py-2 bg-green-600 hover:bg-green-700 rounded-lg font-medium transition">
|
| 131 |
+
<i class="fas fa-play mr-2"></i> Start
|
| 132 |
+
</button>
|
| 133 |
+
<button id="stopBtn" class="px-6 py-2 bg-red-600 hover:bg-red-700 rounded-lg font-medium transition">
|
| 134 |
+
<i class="fas fa-stop mr-2"></i> Stop
|
| 135 |
+
</button>
|
| 136 |
+
</div>
|
| 137 |
</div>
|
| 138 |
|
| 139 |
+
<div class="bg-gray-800 rounded-xl p-6 shadow-lg">
|
| 140 |
+
<h2 class="text-xl font-semibold mb-4 text-cyan-300">
|
| 141 |
+
<i class="fas fa-info-circle mr-2"></i> Detection Information
|
| 142 |
+
</h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
+
<div class="grid grid-cols-2 gap-4 mb-6">
|
| 145 |
+
<div class="bg-gray-700 p-4 rounded-lg">
|
| 146 |
+
<h3 class="text-sm font-medium text-gray-400">Objects Detected</h3>
|
| 147 |
+
<p id="objectCount" class="text-2xl font-bold text-green-400">0</p>
|
| 148 |
+
</div>
|
| 149 |
+
|
| 150 |
+
<div class="bg-gray-700 p-4 rounded-lg">
|
| 151 |
+
<h3 class="text-sm font-medium text-gray-400">Max Distance</h3>
|
| 152 |
+
<p class="text-2xl font-bold text-cyan-400">400 cm</p>
|
| 153 |
+
</div>
|
| 154 |
+
</div>
|
| 155 |
|
| 156 |
+
<div class="mb-6">
|
| 157 |
+
<h3 class="text-lg font-medium mb-2 text-gray-300">
|
| 158 |
+
<i class="fas fa-ruler mr-2"></i> Distance Indicators
|
| 159 |
+
</h3>
|
| 160 |
+
<div class="flex items-center justify-between mb-1">
|
| 161 |
+
<span class="text-xs">0 cm</span>
|
| 162 |
+
<span class="text-xs">100 cm</span>
|
| 163 |
+
<span class="text-xs">200 cm</span>
|
| 164 |
+
<span class="text-xs">300 cm</span>
|
| 165 |
+
<span class="text-xs">400 cm</span>
|
| 166 |
+
</div>
|
| 167 |
+
<div class="w-full bg-gray-700 h-4 rounded-full overflow-hidden">
|
| 168 |
+
<div id="distanceBar" class="h-full bg-gradient-to-r from-green-500 via-yellow-500 to-red-500" style="width: 0%"></div>
|
| 169 |
+
</div>
|
| 170 |
+
</div>
|
| 171 |
|
| 172 |
+
<div>
|
| 173 |
+
<h3 class="text-lg font-medium mb-2 text-gray-300">
|
| 174 |
+
<i class="fas fa-bell mr-2"></i> Detection Log
|
| 175 |
+
</h3>
|
| 176 |
+
<div id="detectionLog" class="bg-gray-700 p-3 rounded-lg h-40 overflow-y-auto text-sm">
|
| 177 |
+
<div class="text-gray-400 italic">No objects detected yet...</div>
|
| 178 |
+
</div>
|
| 179 |
+
</div>
|
| 180 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
</div>
|
| 182 |
|
| 183 |
+
<div class="mt-8 bg-gray-800 rounded-xl p-6">
|
| 184 |
+
<h2 class="text-xl font-semibold mb-4 text-cyan-300">
|
| 185 |
+
<i class="fas fa-cogs mr-2"></i> System Configuration
|
| 186 |
+
</h2>
|
| 187 |
+
|
| 188 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
| 189 |
+
<div>
|
| 190 |
+
<label class="block text-sm font-medium mb-1">Scan Speed</label>
|
| 191 |
+
<select class="w-full bg-gray-700 border border-gray-600 rounded-md px-3 py-2">
|
| 192 |
+
<option>Slow</option>
|
| 193 |
+
<option selected>Normal</option>
|
| 194 |
+
<option>Fast</option>
|
| 195 |
+
</select>
|
| 196 |
+
</div>
|
| 197 |
+
|
| 198 |
+
<div>
|
| 199 |
+
<label class="block text-sm font-medium mb-1">Sensitivity</label>
|
| 200 |
+
<input type="range" min="1" max="10" value="7" class="w-full">
|
| 201 |
+
</div>
|
| 202 |
+
|
| 203 |
+
<div>
|
| 204 |
+
<label class="block text-sm font-medium mb-1">Detection Range</label>
|
| 205 |
+
<div class="flex items-center space-x-2">
|
| 206 |
+
<input type="number" value="400" class="w-20 bg-gray-700 border border-gray-600 rounded-md px-3 py-2">
|
| 207 |
+
<span class="text-sm">cm</span>
|
| 208 |
+
</div>
|
| 209 |
+
</div>
|
| 210 |
</div>
|
|
|
|
| 211 |
</div>
|
| 212 |
</div>
|
| 213 |
|
| 214 |
<script>
|
| 215 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 216 |
+
const radar = document.querySelector('.radar');
|
| 217 |
+
const startBtn = document.getElementById('startBtn');
|
| 218 |
+
const stopBtn = document.getElementById('stopBtn');
|
| 219 |
+
const objectCount = document.getElementById('objectCount');
|
| 220 |
+
const distanceBar = document.getElementById('distanceBar');
|
| 221 |
+
const detectionLog = document.getElementById('detectionLog');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
+
let scanInterval;
|
| 224 |
+
let objectInterval;
|
| 225 |
+
let isScanning = false;
|
| 226 |
+
let objects = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
+
// Create radar circles and lines
|
| 229 |
+
for (let i = 0; i < 4; i++) {
|
| 230 |
+
const angle = i * 22.5;
|
| 231 |
+
const line = document.createElement('div');
|
| 232 |
+
line.className = 'radar-line';
|
| 233 |
+
line.style.transform = `translate(-50%, -50%) rotate(${angle}deg)`;
|
| 234 |
+
radar.appendChild(line);
|
| 235 |
}
|
| 236 |
|
| 237 |
+
// Start scanning
|
| 238 |
+
startBtn.addEventListener('click', function() {
|
| 239 |
+
if (isScanning) return;
|
| 240 |
+
|
| 241 |
+
isScanning = true;
|
| 242 |
+
detectionLog.innerHTML = '';
|
| 243 |
+
updateLog('System started. Scanning for objects...', 'system');
|
| 244 |
+
|
| 245 |
+
// Simulate radar scanning
|
| 246 |
+
scanInterval = setInterval(() => {
|
| 247 |
+
// This is just for visualization - in a real system, this would come from sensor data
|
| 248 |
+
}, 100);
|
| 249 |
+
|
| 250 |
+
// Simulate object detection
|
| 251 |
+
objectInterval = setInterval(() => {
|
| 252 |
+
// Clear previous objects
|
| 253 |
+
document.querySelectorAll('.object').forEach(obj => obj.remove());
|
| 254 |
+
objects = [];
|
| 255 |
+
|
| 256 |
+
// Generate random objects (1-5 objects)
|
| 257 |
+
const numObjects = Math.floor(Math.random() * 5) + 1;
|
| 258 |
+
objectCount.textContent = numObjects;
|
| 259 |
+
|
| 260 |
+
for (let i = 0; i < numObjects; i++) {
|
| 261 |
+
const distance = Math.random() * 0.9 + 0.1; // 10%-100% of radar
|
| 262 |
+
const angle = Math.random() * 360;
|
| 263 |
+
|
| 264 |
+
const x = 50 + Math.cos(angle * Math.PI / 180) * distance * 50;
|
| 265 |
+
const y = 50 + Math.sin(angle * Math.PI / 180) * distance * 50;
|
| 266 |
+
|
| 267 |
+
const object = document.createElement('div');
|
| 268 |
+
object.className = 'object';
|
| 269 |
+
object.style.left = `${x}%`;
|
| 270 |
+
object.style.top = `${y}%`;
|
| 271 |
+
|
| 272 |
+
// Add distance indicator
|
| 273 |
+
const indicator = document.createElement('div');
|
| 274 |
+
indicator.className = 'distance-indicator absolute w-2 h-2 bg-green-500 rounded-full';
|
| 275 |
+
indicator.style.left = `${x}%`;
|
| 276 |
+
indicator.style.top = `${y}%`;
|
| 277 |
+
indicator.style.transform = 'translate(-50%, -50%)';
|
| 278 |
+
|
| 279 |
+
radar.appendChild(object);
|
| 280 |
+
objects.push({distance, angle});
|
| 281 |
+
|
| 282 |
+
// Update distance bar
|
| 283 |
+
const realDistance = Math.round(distance * 400);
|
| 284 |
+
distanceBar.style.width = `${distance * 100}%`;
|
| 285 |
+
|
| 286 |
+
// Add to log
|
| 287 |
+
updateLog(`Object detected at ${realDistance} cm, ${Math.round(angle)}°`, 'detection');
|
| 288 |
+
}
|
| 289 |
+
}, 2000);
|
| 290 |
+
});
|
| 291 |
|
| 292 |
+
// Stop scanning
|
| 293 |
+
stopBtn.addEventListener('click', function() {
|
| 294 |
+
if (!isScanning) return;
|
| 295 |
+
|
| 296 |
+
isScanning = false;
|
| 297 |
+
clearInterval(scanInterval);
|
| 298 |
+
clearInterval(objectInterval);
|
| 299 |
+
|
| 300 |
+
// Clear objects
|
| 301 |
+
document.querySelectorAll('.object').forEach(obj => obj.remove());
|
| 302 |
+
objectCount.textContent = '0';
|
| 303 |
+
distanceBar.style.width = '0%';
|
| 304 |
+
|
| 305 |
+
updateLog('System stopped.', 'system');
|
| 306 |
+
});
|
|
|
|
| 307 |
|
| 308 |
+
// Update detection log
|
| 309 |
+
function updateLog(message, type) {
|
| 310 |
+
const now = new Date();
|
| 311 |
+
const timeString = now.toLocaleTimeString();
|
| 312 |
+
|
| 313 |
+
const logEntry = document.createElement('div');
|
| 314 |
+
logEntry.className = `mb-1 ${type === 'system' ? 'text-cyan-400' : 'text-green-400'}`;
|
| 315 |
+
logEntry.innerHTML = `<span class="text-gray-500 text-xs">[${timeString}]</span> ${message}`;
|
| 316 |
+
|
| 317 |
+
detectionLog.prepend(logEntry);
|
| 318 |
+
|
| 319 |
+
// Limit log entries
|
| 320 |
+
if (detectionLog.children.length > 10) {
|
| 321 |
+
detectionLog.removeChild(detectionLog.lastChild);
|
| 322 |
+
}
|
| 323 |
}
|
|
|
|
|
|
|
| 324 |
|
| 325 |
+
// Simulate initial system status
|
| 326 |
+
setTimeout(() => {
|
| 327 |
+
updateLog('Ultrasonic radar system initialized.', 'system');
|
| 328 |
+
updateLog('Ready to start scanning.', 'system');
|
| 329 |
+
}, 500);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
</script>
|
| 332 |
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Aragoorn/2-3" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 333 |
</html>
|