From bc16b345253989cfc72994f7b62a8ab5e337f6b2 Mon Sep 17 00:00:00 2001 From: JbLb Date: Tue, 19 Dec 2017 09:55:42 +0100 Subject: [PATCH] new function for displaying text --- LibreMetric.ino | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/LibreMetric.ino b/LibreMetric.ino index d442305..c3096d9 100644 --- a/LibreMetric.ino +++ b/LibreMetric.ino @@ -59,7 +59,7 @@ void setup() { matrix.setRotation(i, 1); } - display_message("Wifi"); + display_static_message("Wifi"); WiFiManager wifiManager; #ifndef DEBUG_WifiM @@ -68,6 +68,7 @@ void setup() { wifiManager.setTimeout(180); if(!wifiManager.autoConnect("LibreMetric")) { DEBUG_PRINTLN(F("failed to connect and timeout occurred")); + display_static_message("No OK"); delay(6000); ESP.reset(); //reset and try again delay(180000); @@ -75,6 +76,8 @@ void setup() { matrix.fillScreen(LOW); // At this stage the WiFi manager will have successfully connected to a network, or if not will try again in 180-seconds DEBUG_PRINTLN(F("WiFi connected...")); + display_static_message("OK"); + delay(10*wait); DEBUG_PRINTLN(WiFi.localIP()); configTime(timezone * 3600, dstOffset * 3600, ntpServer); // First sync of time with (S)NTP @@ -83,7 +86,7 @@ void setup() { telnetServer.begin(); telnetServer.setNoDelay(true); #endif - + //---------------------------------------------------------------------- server.begin(); DEBUG_PRINTLN(F("Webserver started...")); @@ -133,7 +136,17 @@ void loop() { yield(); } void display_static_message(String message){ - + if (width * message.length() - spacer > matrix.width()) { + display_message(message); + } + else { + 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 + } } void display_message(String message){ for ( int i = 0 ; i < width * message.length() + matrix.width() - spacer; i++ ) {