diff --git a/radar/index.php b/radar/index.php
index 3167e2f..3a9888a 100644
--- a/radar/index.php
+++ b/radar/index.php
@@ -1,23 +1,126 @@
-
+
-
- ESP32 Radar
+
+ESP32 Radar
+
- Ultrasone afstand
- Laden...
-
+
+ // lijnen
+ for (let a = 0; a <= 180; a += 30) {
+ const rad = a * Math.PI / 180;
+ ctx.beginPath();
+ ctx.moveTo(centerX, centerY);
+ ctx.lineTo(
+ centerX + radius * Math.cos(rad - Math.PI),
+ centerY + radius * Math.sin(rad - Math.PI)
+ );
+ ctx.stroke();
+ }
+}
+
+function drawSweep() {
+ const rad = sweepAngle * Math.PI / 180;
+
+ ctx.strokeStyle = "#00ff00";
+ ctx.lineWidth = 2;
+ ctx.beginPath();
+ ctx.moveTo(centerX, centerY);
+ ctx.lineTo(
+ centerX + radius * Math.cos(rad - Math.PI),
+ centerY + radius * Math.sin(rad - Math.PI)
+ );
+ ctx.stroke();
+
+ sweepAngle++;
+ if (sweepAngle > 180) sweepAngle = 0;
+}
+
+function drawTargets() {
+ ctx.fillStyle = "#00ff00";
+
+ for (const hoek in radarData) {
+ const afstand = radarData[hoek].afstand;
+ if (afstand < 0) continue;
+
+ const rad = hoek * Math.PI / 180;
+ const r = (afstand / 200) * radius;
+
+ const x = centerX + r * Math.cos(rad - Math.PI);
+ const y = centerY + r * Math.sin(rad - Math.PI);
+
+ ctx.beginPath();
+ ctx.arc(x, y, 3, 0, Math.PI * 2);
+ ctx.fill();
+ }
+}
+
+async function fetchData() {
+ try {
+ const res = await fetch("radar.json?_=" + Date.now());
+ radarData = await res.json();
+ } catch (e) {
+ console.log("Geen data");
+ }
+}
+
+function loop() {
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ drawGrid();
+ drawTargets();
+ drawSweep();
+ requestAnimationFrame(loop);
+}
+
+// elke 200ms nieuwe radar data ophalen
+setInterval(fetchData, 200);
+
+fetchData();
+loop();
+
+