new function for displaying text

master
JbLb 8 years ago
parent 6dfaf005d7
commit bc16b34525

@ -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++ ) {

Loading…
Cancel
Save