Aragoorn commited on
Commit
54bf3de
·
verified ·
1 Parent(s): a3b0944

Radar code for detecting objects with ultrasonics - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. 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>Mahnsi Calculator</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
- .calculator {
11
- background: linear-gradient(145deg, #1e293b, #0f172a);
12
- box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
13
- border-radius: 20px;
 
 
 
14
  overflow: hidden;
15
- transition: all 0.3s ease;
16
  }
17
 
18
- .calculator:hover {
19
- transform: translateY(-5px);
20
- box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
 
 
 
 
 
 
 
 
21
  }
22
 
23
- .btn {
24
- transition: all 0.2s ease;
25
- transform: scale(1);
 
 
 
 
 
 
 
 
 
26
  }
27
 
28
- .btn:active {
29
- transform: scale(0.95);
 
 
 
 
 
 
 
 
30
  }
31
 
32
- .display {
33
- min-height: 100px;
34
- word-wrap: break-word;
35
- word-break: break-all;
 
 
 
36
  }
37
 
38
- .btn-operator {
39
- background: linear-gradient(145deg, #3b82f6, #2563eb);
 
 
 
 
 
 
40
  }
41
 
42
- .btn-equals {
43
- background: linear-gradient(145deg, #10b981, #059669);
 
 
 
 
 
 
 
44
  }
45
 
46
- .btn-clear {
47
- background: linear-gradient(145deg, #ef4444, #dc2626);
 
48
  }
49
 
50
- .btn-number {
51
- background: linear-gradient(145deg, #334155, #1e293b);
 
 
52
  }
53
 
54
- .btn:hover {
55
- opacity: 0.9;
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-slate-900 min-h-screen flex items-center justify-center p-4">
73
- <div class="relative">
74
- <div class="calculator w-full max-w-md p-5">
75
- <!-- Display -->
76
- <div class="display bg-slate-800 rounded-xl p-4 mb-4 text-right text-white font-mono">
77
- <div id="previous-operand" class="text-slate-400 text-lg h-6 overflow-x-auto whitespace-nowrap"></div>
78
- <div id="current-operand" class="text-3xl font-semibold mt-2 overflow-x-auto whitespace-nowrap">0</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  </div>
80
 
81
- <!-- Buttons -->
82
- <div class="grid grid-cols-4 gap-3">
83
- <button class="btn-clear col-span-2 btn rounded-xl p-4 text-white font-bold text-lg" onclick="clearAll()">AC</button>
84
- <button class="btn-operator btn rounded-xl p-4 text-white font-bold text-lg" onclick="deleteLastChar()">
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
- <button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendNumber('4')">4</button>
95
- <button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendNumber('5')">5</button>
96
- <button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendNumber('6')">6</button>
97
- <button class="btn-operator btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendOperator('-')">-</button>
 
 
 
 
 
 
 
98
 
99
- <button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendNumber('1')">1</button>
100
- <button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendNumber('2')">2</button>
101
- <button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendNumber('3')">3</button>
102
- <button class="btn-operator btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendOperator('+')">+</button>
 
 
 
 
 
 
 
 
 
 
 
103
 
104
- <button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendNumber('0')">0</button>
105
- <button class="btn-number btn rounded-xl p-4 text-white font-bold text-lg" onclick="appendDecimal()">.</button>
106
- <button class="btn-equals btn rounded-xl p-4 text-white font-bold text-lg col-span-2" onclick="calculate()">=</button>
 
 
 
 
 
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
- <!-- History Panel -->
116
- <div id="history-panel" class="history-panel absolute right-0 top-0 h-full w-64 bg-slate-800 rounded-r-xl p-4 overflow-y-auto">
117
- <div class="flex justify-between items-center mb-4">
118
- <h3 class="text-white font-bold text-lg">History</h3>
119
- <button class="text-slate-400 hover:text-white" onclick="clearHistory()">
120
- <i class="fas fa-trash"></i>
121
- </button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  </div>
123
- <ul id="history-list" class="text-slate-300 space-y-2"></ul>
124
  </div>
125
  </div>
126
 
127
  <script>
128
- // Calculator state
129
- let currentOperand = '0';
130
- let previousOperand = '';
131
- let operation = undefined;
132
- let resetScreen = false;
133
- let calculationHistory = JSON.parse(localStorage.getItem('calculatorHistory')) || [];
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
- if (currentOperand === '') {
176
- currentOperand = '0';
177
- }
178
-
179
- currentOperand += '.';
180
- updateDisplay();
181
- }
182
-
183
- // Append operator
184
- function appendOperator(operator) {
185
- if (currentOperand === '' && previousOperand === '') return;
186
 
187
- if (currentOperand === '' && previousOperand !== '') {
188
- operation = operator;
189
- updateDisplay();
190
- return;
 
 
 
191
  }
192
 
193
- if (previousOperand === '') {
194
- previousOperand = currentOperand;
195
- currentOperand = '';
196
- } else if (!resetScreen) {
197
- calculate();
198
- }
199
-
200
- operation = operator;
201
- resetScreen = true;
202
- updateDisplay();
203
- }
204
-
205
- // Calculate
206
- function calculate() {
207
- if (previousOperand === '' || currentOperand === '' || operation === undefined) return;
208
-
209
- const prev = parseFloat(previousOperand);
210
- const current = parseFloat(currentOperand);
211
- let result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
 
213
- switch (operation) {
214
- case '+':
215
- result = prev + current;
216
- break;
217
- case '-':
218
- result = prev - current;
219
- break;
220
- case '*':
221
- result = prev * current;
222
- break;
223
- case '/':
224
- result = prev / current;
225
- break;
226
- default:
227
- return;
228
- }
229
 
230
- // Add to history
231
- const historyItem = `${previousOperand} ${operation} ${currentOperand} = ${result}`;
232
- calculationHistory.unshift(historyItem);
233
- if (calculationHistory.length > 10) {
234
- calculationHistory.pop();
 
 
 
 
 
 
 
 
 
 
235
  }
236
- localStorage.setItem('calculatorHistory', JSON.stringify(calculationHistory));
237
- updateHistory();
238
 
239
- currentOperand = result.toString();
240
- operation = undefined;
241
- previousOperand = '';
242
- resetScreen = true;
243
- updateDisplay();
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>