From 3a1d30587ef92c74a80e6e92e6b206d613fa1102 Mon Sep 17 00:00:00 2001 From: "[Valentino Heman Budiarto]" <[hemanvalentino@gmail.com]> Date: Tue, 11 Aug 2026 20:17:38 +0700 Subject: [PATCH] . --- app/page.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 3a54794..36404f0 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -7,12 +7,10 @@ export default function RobotDashboard() { const PI_IP = '172.17.19.107'; const streamUrl = `http://${PI_IP}:8080/stream`; - // Tipe data disederhanakan agar tidak memicu error TS const [controlMode, setControlMode] = useState('gamepad'); const [gamepadStatus, setGamepadStatus] = useState("Menunggu Gamepad..."); const [steering, setSteering] = useState({ x: 0, y: 0 }); - // Menggunakan 'any' untuk menghindari error pengecekan tipe strict pada WebSocket const wsRef = useRef(null); const keysRef = useRef({ up: false, down: false, left: false, right: false }); @@ -71,10 +69,12 @@ export default function RobotDashboard() { if (activeGp) { const rawX = activeGp.axes[0]; - const lt = activeGp.buttons[6].value; - const rt = activeGp.buttons[7].value; - const throttle = rt - lt; + // PERUBAHAN LOGIKA GAS SESUAI PERMINTAANMU + const maju = activeGp.buttons[7].value; // Tombol 7 (RT) untuk maju + const mundur = activeGp.buttons[6].value; // Tombol 6 (LT) untuk mundur + + const throttle = maju - mundur; currentX = Math.abs(rawX) > 0.15 ? Number(rawX.toFixed(2)) : 0; currentY = Number(throttle.toFixed(2)); } @@ -86,7 +86,6 @@ export default function RobotDashboard() { setSteering({ x: currentX, y: currentY }); - // wsRef dipastikan aman dari TS error if (wsRef.current && wsRef.current.readyState === 1) { wsRef.current.send(JSON.stringify({ x: currentX, y: currentY })); }