First commit
This commit is contained in:
parent
81bcb27e30
commit
e0016201bc
@ -5,3 +5,11 @@
|
||||
+Split sentences into lines(features)
|
||||
+Enable/disable text scrolling (features)
|
||||
+Add a drawing as a binary image (features)
|
||||
+State of panel
|
||||
+Remote panel on/off
|
||||
#Docs for API
|
||||
*Endpoints
|
||||
+10.131.170.4 - the local static IP
|
||||
+/api/text - endpoint for editing text (POST)
|
||||
+/api/led - endpint for on/off panel (POST)
|
||||
+/api/led - endpoint for check on/off panel (GET), return "{"led":"true"}" if panel ON and "{"led":"false"}" if panel OFF
|
||||
|
85
panel.ino
85
panel.ino
@ -8,14 +8,15 @@
|
||||
#define DISPLAYS_ACROSS 1
|
||||
#define DISPLAYS_DOWN 1
|
||||
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
|
||||
bool panel = true;
|
||||
|
||||
const char* ssid = "SKBKIT";
|
||||
const char* password = "skbkit2024";
|
||||
|
||||
WebServer server(80);
|
||||
IPAddress staticIP(10,131,170,4);
|
||||
IPAddress gateway(10,131,170,1);
|
||||
IPAddress subnet(255,255,255,0);
|
||||
IPAddress staticIP(10, 131, 170, 4);
|
||||
IPAddress gateway(10, 131, 170, 1);
|
||||
IPAddress subnet(255, 255, 255, 0);
|
||||
|
||||
String displayText = "Привет из СКБ \"КИТ\"";
|
||||
//String displayText = "Пизда с членом разлучились(";
|
||||
@ -25,7 +26,7 @@ void IRAM_ATTR triggerScan() {
|
||||
dmd.scanDisplayBySPI();
|
||||
}
|
||||
|
||||
void reader(){}
|
||||
void reader() {}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
@ -33,7 +34,7 @@ void setup() {
|
||||
WiFi.begin(ssid, password);
|
||||
//WiFi.config(staticIP, gateway, subnet);
|
||||
|
||||
if(!WiFi.config(staticIP, gateway, subnet)) {
|
||||
if (!WiFi.config(staticIP, gateway, subnet)) {
|
||||
Serial.println("Failed to configure Static IP");
|
||||
} else {
|
||||
Serial.println("Static IP configured!");
|
||||
@ -55,29 +56,55 @@ void setup() {
|
||||
|
||||
// Обрабатываем GET запрос для главной страницы с формой
|
||||
server.on("/", HTTP_GET, []() {
|
||||
panel = true;
|
||||
server.send(200, "text/html",
|
||||
"<!DOCTYPE html>"
|
||||
"<html lang='ru'>"
|
||||
"<head>"
|
||||
"<meta charset='UTF-8'>"
|
||||
"<title>Panel text</title>"
|
||||
"</head>"
|
||||
"<body>"
|
||||
"<h2>Введите текст для отображения на экране:</h2>"
|
||||
"<form action='/api/text' method='post'><input name='text'><input type='submit'></form>"
|
||||
"</body>"
|
||||
"</html>");
|
||||
"<!DOCTYPE html>"
|
||||
"<html lang='ru'>"
|
||||
"<head>"
|
||||
"<meta charset='UTF-8'>"
|
||||
"<title>Panel text</title>"
|
||||
"</head>"
|
||||
"<body>"
|
||||
"<h2>Введите текст для отображения на экране:</h2>"
|
||||
"<form action='/api/text' method='post'><input name='text'><input type='submit'></form>"
|
||||
"</body>"
|
||||
"</html>");
|
||||
});
|
||||
|
||||
server.on("/api/led", HTTP_GET, [](){
|
||||
if(panel){
|
||||
server.send(200, "application/json", "{\"state\": \"true\"}");
|
||||
}else if(!panel){
|
||||
server.send(200, "application/json", "{\"state\": \"false\"}");
|
||||
};
|
||||
});
|
||||
|
||||
server.on("/api/led", HTTP_POST, [](){
|
||||
String panelState = server.arg("plain");
|
||||
Serial.println(panelState);
|
||||
|
||||
if (panelState == "{\"led\": \"on\"}"){
|
||||
Serial.println("Panel on!");
|
||||
panel = true;
|
||||
//scanDisplayBySPI();
|
||||
}else if(panelState == "{\"led\": \"off\"}"){
|
||||
panel = false;
|
||||
Serial.println("Panel off!");
|
||||
SPI.end();
|
||||
}
|
||||
server.send(200, "text/html", "");
|
||||
});
|
||||
|
||||
// Обрабатываем POST запрос для изменения текста
|
||||
server.on("/api/text", HTTP_POST, []() {
|
||||
panel = true;
|
||||
if (server.hasArg("text")) {
|
||||
// Получаем текст с формы без преобразования в HTML-сущности
|
||||
displayText = server.arg("text");
|
||||
}
|
||||
// Отправляем ответ с правильной кодировкой UTF-8
|
||||
server.send(200, "text/html; charset=UTF-8",
|
||||
"<html><body><h2>Text set to:</h2><p>" + displayText + "</p></body></html>");
|
||||
"<html><body><h2>Text set to:</h2><p>" + displayText + "</p></body></html>");
|
||||
});
|
||||
|
||||
server.begin();
|
||||
@ -94,18 +121,18 @@ void setup() {
|
||||
void loop() {
|
||||
server.handleClient(); // Обработка запросов от клиента
|
||||
|
||||
// Очистка экрана и вывод текста
|
||||
dmd.clearScreen(true);
|
||||
dmd.drawMarquee(displayText.c_str(), displayText.length(), (32 * DISPLAYS_ACROSS) - 1, 0);
|
||||
// // Очистка экрана и вывод текста
|
||||
// dmd.clearScreen(true);
|
||||
// dmd.drawMarquee(displayText.c_str(), displayText.length(), (32 * DISPLAYS_ACROSS) - 1, 0);
|
||||
|
||||
long start = millis();
|
||||
long timer = start;
|
||||
boolean ret = false;
|
||||
// long start = millis();
|
||||
// long timer = start;
|
||||
// boolean ret = false;
|
||||
|
||||
while (!ret) {
|
||||
if ((timer + 30) < millis()) {
|
||||
ret = dmd.stepMarquee(-1, 0); // Прокрутка текста
|
||||
timer = millis();
|
||||
}
|
||||
}
|
||||
// while (!ret) {
|
||||
// if ((timer + 30) < millis()) {
|
||||
// ret = dmd.stepMarquee(-1, 0); // Прокрутка текста
|
||||
// timer = millis();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user