personas:johnny:proyectos:matrices-led
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
personas:johnny:proyectos:matrices-led [2021/10/16 18:04] – kz | personas:johnny:proyectos:matrices-led [2021/10/16 18:54] (actual) – kz | ||
---|---|---|---|
Línea 10: | Línea 10: | ||
**Code** | **Code** | ||
+ | |||
+ | Este código hace que el esp sirva una página web, donde se escribe un mensaje y se presenta en la pantalla | ||
<code c++> | <code c++> | ||
Línea 405: | Línea 407: | ||
</ | </ | ||
+ | |||
+ | Este otro código es tomado de internet del señor [[https:// | ||
+ | |||
+ | <code c++> | ||
+ | /* | ||
+ | Programa: Wifi controlled LED matrix display | ||
+ | Autor: | ||
+ | Web: www.humbertohiginio.com | ||
+ | Canal de Youtube: https:// | ||
+ | Video Exclusivo para mi canal de Youtube | ||
+ | Todos los Derechos Reservados - 2018 | ||
+ | Código de Dominio Público | ||
+ | |||
+ | Wemos D1 Mini o NodeMCU pines -> Matrix pines | ||
+ | MOSI-D7-GPIO13 | ||
+ | CLK-D5-GPIO14 | ||
+ | GPIO0-D3 | ||
+ | |||
+ | */ | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | #define SSID " | ||
+ | #define PASS " | ||
+ | // ******************* String form to sent to the client-browser ************************************ | ||
+ | String form = | ||
+ | "< | ||
+ | "< | ||
+ | "< | ||
+ | "< | ||
+ | "</ | ||
+ | |||
+ | ESP8266WebServer server(80); | ||
+ | long period; | ||
+ | int offset=1, | ||
+ | int pinCS = 0; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http:// | ||
+ | int numberOfHorizontalDisplays = 8; | ||
+ | int numberOfVerticalDisplays = 1; | ||
+ | String decodedMsg; | ||
+ | Max72xxPanel matrix = Max72xxPanel(pinCS, | ||
+ | |||
+ | String tape = " | ||
+ | int wait = 20; // In milliseconds | ||
+ | |||
+ | int spacer = 2; | ||
+ | int width = 5 + spacer; // The font width is 5 pixels | ||
+ | |||
+ | /* | ||
+ | handles the messages coming from the webbrowser, restores a few special characters and | ||
+ | constructs the strings that can be sent to the oled display | ||
+ | */ | ||
+ | void handle_msg() { | ||
+ | | ||
+ | matrix.fillScreen(LOW); | ||
+ | server.send(200, | ||
+ | refresh=1; | ||
+ | // Display msg on Oled | ||
+ | String msg = server.arg(" | ||
+ | Serial.println(msg); | ||
+ | decodedMsg = msg; | ||
+ | // Restore special characters that are misformed to %char by the client browser | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | decodedMsg.replace(" | ||
+ | // | ||
+ | |||
+ | |||
+ | | ||
+ | // | ||
+ | } | ||
+ | |||
+ | void setup(void) { | ||
+ | matrix.setIntensity(10); | ||
+ | |||
+ | // Adjust to your own needs | ||
+ | // matrix.setPosition(0, | ||
+ | // matrix.setPosition(1, | ||
+ | |||
+ | // Adjust to your own needs | ||
+ | matrix.setPosition(0, | ||
+ | matrix.setPosition(1, | ||
+ | matrix.setPosition(2, | ||
+ | matrix.setPosition(3, | ||
+ | matrix.setPosition(4, | ||
+ | matrix.setPosition(5, | ||
+ | matrix.setPosition(6, | ||
+ | matrix.setPosition(7, | ||
+ | | ||
+ | matrix.setRotation(0, | ||
+ | matrix.setRotation(1, | ||
+ | matrix.setRotation(2, | ||
+ | matrix.setRotation(3, | ||
+ | matrix.setRotation(4, | ||
+ | matrix.setRotation(5, | ||
+ | matrix.setRotation(6, | ||
+ | matrix.setRotation(7, | ||
+ | | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | // | ||
+ | Serial.begin(115200); | ||
+ | |||
+ | WiFi.begin(SSID, | ||
+ | while (WiFi.status() != WL_CONNECTED) { // Wait for connection | ||
+ | delay(500); | ||
+ | Serial.print(" | ||
+ | } | ||
+ | // Set up the endpoints for HTTP server, | ||
+ | server.on("/", | ||
+ | server.send(200, | ||
+ | }); | ||
+ | server.on("/ | ||
+ | server.begin(); | ||
+ | |||
+ | |||
+ | Serial.print(" | ||
+ | Serial.println(SSID); | ||
+ | |||
+ | char result[16]; | ||
+ | sprintf(result, | ||
+ | Serial.println(); | ||
+ | Serial.println(result); | ||
+ | decodedMsg = result; | ||
+ | Serial.println(" | ||
+ | |||
+ | Serial.println(WiFi.localIP()); | ||
+ | Serial.print(analogRead(A0)); | ||
+ | | ||
+ | } | ||
+ | |||
+ | |||
+ | void loop(void) { | ||
+ | |||
+ | for ( int i = 0 ; i < width * decodedMsg.length() + matrix.width() - 1 - spacer; i++ ) { | ||
+ | server.handleClient(); | ||
+ | if (refresh==1) i=0; | ||
+ | refresh=0; | ||
+ | matrix.fillScreen(LOW); | ||
+ | |||
+ | int letter = i / width; | ||
+ | int x = (matrix.width() - 1) - i % width; | ||
+ | int y = (matrix.height() - 8) / 2; // center the text vertically | ||
+ | |||
+ | while ( x + width - spacer >= 0 && letter >= 0 ) { | ||
+ | if ( letter < decodedMsg.length() ) { | ||
+ | matrix.drawChar(x, | ||
+ | } | ||
+ | |||
+ | letter--; | ||
+ | x -= width; | ||
+ | } | ||
+ | |||
+ | matrix.write(); | ||
+ | |||
+ | delay(wait); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | * Otros enlaces: [[https:// | ||
+ | * [[https:// | ||
+ |
personas/johnny/proyectos/matrices-led.1634407488.txt.gz · Última modificación: 2021/10/16 18:04 por kz