Move mouse

This commit is contained in:
2026-02-28 15:45:09 +00:00
parent 1d41d336ea
commit 48f0ab881d
4 changed files with 12 additions and 67 deletions

View File

@@ -1,59 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mouse Speedometer</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
<h2>Mouse Speedometer</h2>
<div id="toolBar">
<!-- ON/OFF (Gray OFF/ Orange ON) -->
<i class="fa-solid fa-power-off"></i>
<!-- display DCCID or '-' if Analogique or Marklin -->
<i class="fa-solid fa-train"></i><span id="DCCID">34</span>
<!-- display mode (Analogique or Marklin or DCC) -->
<i class="fa-solid fa-wave-square"></i><span id="Mode">Analogique</span>
<!-- display direction (Forward or Reverse) -->
<i class="fa-solid fa-forward"></i>
<!-- Program CV -->
<i class="fa-solid fa-cogs"></i>
<!-- Accessories switch to accessories page -->
<i class="fa-solid fa-traffic-light"></i>
</div>
<div id="SelectLoco">
<!-- display a view of scale model -->
<img src="img/locos/loco.png" alt="Loco" width="300" height="50" onClick="SelectLoco();" style="cursor:pointer; margin-right:20px;">
</div>
<div id="speedometer">
<!-- Inline SVG for speedometer -->
<svg width="300" height="200" viewBox="0 0 300 200" xmlns="http://www.w3.org/2000/svg">
<image href="img/Speed.png" x="0" y="0" width="300" height="200"/>
<line id="needle" x1="150" y1="120" x2="150" y2="70" stroke="#e74c3c" stroke-width="6" stroke-linecap="round" />
<text id="kmText" x="280" y="160" font-size="20" text-anchor="end" fill="#333">
0
</text>
</svg>
</div>
<div style="text-align:center; margin-top:20px;">
<!-- slider-->
<input type="range" id="speedSlider" min="0" max="128" value="0" oninput="updateSpeedometer(this.value);" style="width:80%;">
</div>
<div id="Functions">
<!-- Display F0 to F7 -->
<div class="function" id="F0">F0</div>
<div class="function" id="F1">F1</div>
<div class="function" id="F2">F2</div>
<div class="function" id="F3">F3</div>
<div class="function" id="F4">F4</div>
<div class="function" id="F5">F5</div>
<div class="function" id="F6">F6</div>
<div class="function" id="F7">F7</div>
</div>
</div>
<script type="text/javascript" src="js/mouse.js"></script>
</body>
</html>

View File

@@ -4,12 +4,12 @@
#include "WebServer.h" #include "WebServer.h"
void handlePage(char *page) { void handlePage(char *page, char *contentType) {
if (LittleFS.exists(page)) { if (LittleFS.exists(page)) {
File file = LittleFS.open(page, "r"); File file = LittleFS.open(page, "r");
if (file) { if (file) {
String html = file.readString(); String html = file.readString();
server.send(200, "text/html", html); server.send(200, contentType, html);
file.close(); file.close();
return; return;
} }

View File

@@ -1,3 +1,5 @@
#include <ESP8266WebServer.h>
extern ESP8266WebServer server; extern ESP8266WebServer server;
void handlePage(char *page); void handlePage(char *page, char *contentType);

View File

@@ -6,6 +6,7 @@
#include "main.h" #include "main.h"
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>
#include <LittleFS.h> #include <LittleFS.h>
#include "WebServer.h"
#define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels
@@ -45,11 +46,12 @@ void setup() {
} else { } else {
Serial.println("[DEBUG] LittleFS mounted"); Serial.println("[DEBUG] LittleFS mounted");
} }
server.on("/", []() { handlePage("/index.html"); }); server.on("/", []() { handlePage("/index.html", "text/html"); });
server.on("/xpressnet.html", []() { handlePage("/xpressnet.html"); }); server.on("/xpressnet.html", []() { handlePage("/xpressnet.html", "text/html"); });
server.on("/mouse.html", []() { handlePage("/mouse.html"); }); server.on("/mouse.html", []() { handlePage("/mouse.html", "text/html"); });
server.on("/js/script.js", []() { handlePage("/js/script.js"); }); server.on("/js/mouse.js", []() { handlePage("/js/mouse.js", "application/javascript"); });
server.on("/css/style.css", []() { handlePage("/css/style.css"); }); server.on("/css/style.css", []() { handlePage("/css/style.css", "text/css"); });
server.on("/img/Speed.png", []() { handlePage("/img/Speed.png", "image/png"); });
server.begin(); server.begin();
Serial.println("[DEBUG] Web server started"); Serial.println("[DEBUG] Web server started");
} }