From 816c9d566373f2fee187fcfbd4438d375e112163 Mon Sep 17 00:00:00 2001 From: jc4419 <60656643+jc4419@users.noreply.github.com> Date: Mon, 31 May 2021 21:49:50 +0400 Subject: [PATCH] Fixed some syntax errors in the js code for the webpage. Also added mouse click support for the arrow keys. Added some commented code that can be uncommented for connecting the esp32 to a wifi router instead of AP mode. --- Command/index.html | 84 +++++++++++++++++++++---------- Command/main/main.ino | 112 +++++++++++++++++++++++++++++++----------- 2 files changed, 143 insertions(+), 53 deletions(-) diff --git a/Command/index.html b/Command/index.html index a5421ed..b242ae1 100644 --- a/Command/index.html +++ b/Command/index.html @@ -9,7 +9,7 @@ box-sizing: border-box; } -.section-container { +.section_container { float: left; width: 50%; padding: 10px; @@ -32,11 +32,11 @@ li { :is(h1, h2, h3, h4, h5, h6, label, strong, meter) { font-family: Arial, Helvetica, sans-serif; } -.movement-control { +.movement_control { text-align: center; } -.sensor-data { +.sensor_data { text-align: center; } @@ -157,22 +157,57 @@ function down_unpressed(){ send_data(); } +var timer = null; + +function up_mouseDown() { + timer = setInterval(up_pressed, 100); +} +function up_mouseUp() { + clearInterval(timer); + up_unpressed(); +} + +function down_mouseDown() { + timer = setInterval(down_pressed, 100); +} +function down_mouseUp() { + clearInterval(timer); + down_unpressed(); +} + +function right_mouseDown() { + timer = setInterval(right_pressed, 100); +} +function right_mouseUp() { + clearInterval(timer); + right_unpressed(); +} + +function left_mouseDown() { + timer = setInterval(left_pressed, 100); +} +function left_mouseUp() { + clearInterval(timer); + left_unpressed(); +} + + document.onkeydown = function(e) { switch (e.keyCode) { case 37: - document.getElementById("left-arrow").className = "button pressed"; + document.getElementById("left_arrow").className = "button pressed"; left_pressed(); break; case 38: - document.getElementById("up-arrow").className = "button pressed"; + document.getElementById("up_arrow").className = "button pressed"; up_pressed(); break; case 39: - document.getElementById("right-arrow").className = "button pressed"; + document.getElementById("right_arrow").className = "button pressed"; right_pressed(); break; case 40: - document.getElementById("down-arrow").className = "button pressed"; + document.getElementById("down_arrow").className = "button pressed"; down_pressed(); break; } @@ -180,19 +215,19 @@ document.onkeydown = function(e) { document.onkeyup = function(e) { switch (e.keyCode) { case 37: - document.getElementById("left-arrow").className = "button"; + document.getElementById("left_arrow").className = "button"; left_unpressed(); break; case 38: - document.getElementById("up-arrow").className = "button"; + document.getElementById("up_arrow").className = "button"; up_unpressed(); break; case 39: - document.getElementById("right-arrow").className = "button"; + document.getElementById("right_arrow").className = "button"; right_unpressed(); break; case 40: - document.getElementById("down-arrow").className = "button"; + document.getElementById("down_arrow").className = "button"; down_unpressed(); break; } @@ -206,39 +241,39 @@ document.onkeyup = function(e) {