// global config #include "config.h" //################# LIBRARIES ########################## #include #include #include // https://github.com/tzapu/WiFiManager #include #include #include #include #include #include #include "OTAsetup.h" #include "d_helper.h" //################# DISPLAY CONNECTIONS ################ // LED Matrix Pin -> ESP8266 Pin // Vcc -> 3v (3V on NodeMCU 3V3 on WEMOS) // Gnd -> Gnd (G on NodeMCU) // DIN -> D7 (Same Pin for WEMOS) // CS -> D4 (Same Pin for WEMOS) // CLK -> D5 (Same Pin for WEMOS) //################ PROGRAM SETTINGS #################### String version = "0.1b"; int PORT = 80; int wait = 50; int spacer = 1; int width = 5 + spacer; String SITE_WIDTH = "1000"; int timezone = 1; int dstOffset = 1; const char* ntpServer = "fr.pool.ntp.org"; int brightness = 16; int pinCS = D4; int numberOfHorizontalDisplays = 4; int numberOfVerticalDisplays = 1; //################## INITIALIZING ###################### char time_value[20]; String message, webpage; ESP8266WebServer server(PORT); Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays); void configModeCallback (WiFiManager *myWiFiManager) { // AP config mode display_message("Setup"); } void setup() { Serial.begin(115200); // initialize serial communications DEBUG_PRINT(F("\n\r")); matrix.fillScreen(LOW); //clr screen initOTA(); for (int i=0; i matrix.width()) { display_message_long(message); } else { matrix.fillScreen(LOW); int x = (matrix.width()-(width * message.length() - spacer))/2; int y = (matrix.height() - 8) / 2; // center the text vertically for ( int i =0; i < message.length(); i++ ){ matrix.drawChar(x + (i * width), y, message[i], HIGH, LOW, 1); // HIGH LOW means foreground ON, background OFF, reverse these to invert the display! } matrix.write(); // Send bitmap to display delay(4000); } } void display_message_long(String message){ for ( int i = 0 ; i < width * message.length() + matrix.width() - spacer; i++ ) { 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 < message.length() ) { matrix.drawChar(x, y, message[letter], HIGH, LOW, 1); // HIGH LOW means foreground ON, background OFF, reverse these to invert the display! } letter--; x -= width; } matrix.write(); // Send bitmap to display delay(wait); } } void GetMessage() { webpage = ""; append_page_header(); String IPaddress = WiFi.localIP().toString(); webpage += "
"; webpage += "

Message à envoyer :


"; webpage += "
"; webpage += "

Luminosité :


"; append_page_footer(); if (server.args() > 0 ) { // Arguments were received for ( uint8_t i = 0; i <= server.args(); i++ ) { String Argument_Name = server.argName(i); String client_response = server.arg(i); if (Argument_Name == "message") message = client_response; if (Argument_Name == "brightness") brightness = client_response.toInt(); } } server.send(200, "text/html", webpage); // Send a response to the client to enter their inputs, if needed, Enter=defaults } void append_page_header() { webpage = F(""); webpage += ""; webpage += F("Envoi de messages - LibreMetric

LibreMetric "); webpage += version+"

"; } void append_page_footer(){ // Saves repeating many lines of code for HTML page footers webpage += F(""); webpage += F(""); }