Initialisation depot
This commit is contained in:
72
src/main.cpp
Normal file
72
src/main.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <Arduino.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include <Wire.h>
|
||||
#include "DisplayHelper.h"
|
||||
#include "WiFiManagerHelper.h"
|
||||
#include "main.h"
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
|
||||
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||
#define SCREEN_ADDRESS 0x3C // If not work please scan the bus
|
||||
#define OLED_SDA 14 // D6
|
||||
#define OLED_SCL 12 // D5
|
||||
|
||||
// Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
Adafruit_SSD1306 *display;
|
||||
|
||||
// Mode for command station operation
|
||||
// Remove conflicting definition, use extern from main.h
|
||||
// Mode currentMode = MODE_OFF;
|
||||
|
||||
// Create web server instance on port 80
|
||||
ESP8266WebServer server(80);
|
||||
|
||||
// HTML content for welcome page
|
||||
const char* welcome_html = R"HTML(
|
||||
<!DOCTYPE html>
|
||||
<html lang=\"en\">
|
||||
<head>
|
||||
<meta charset=\"UTF-8\">
|
||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
||||
<title>Welcome to ESP8266 DCC Command Station</title>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; background: #f4f4f4; color: #333; margin: 0; padding: 0; }
|
||||
.container { max-width: 600px; margin: 40px auto; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); padding: 32px; }
|
||||
h1 { color: #0077cc; }
|
||||
p { font-size: 1.2em; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class=\"container\">
|
||||
<h1>Welcome!</h1>
|
||||
<p>This is your ESP8266 DCC Command Station.</p>
|
||||
<p>Configure WiFi, manage XpressNet, and control your layout from here.</p>
|
||||
<p>For documentation, see <a href=\"/xpressnet.md\">XpressNet Commands</a> and <a href=\"/README.md\">Hardware Setup</a>.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
)HTML";
|
||||
|
||||
void handleWelcome() {
|
||||
server.send(200, "text/html", welcome_html);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(100);
|
||||
Serial.println("[DEBUG] Serial started at 115200 baud");
|
||||
displayInit();
|
||||
Serial.println("[DEBUG] OLED display initialized");
|
||||
setupWiFiManager();
|
||||
server.on("/", handleWelcome);
|
||||
server.begin();
|
||||
Serial.println("[DEBUG] Web server started");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
server.handleClient();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user