0

I got a problem with my code, i'm programming on ESP8266 dev board, using i2c lcd

Look at the last line ManageWifi.cpp

#ifndef ALARMCLOCK_ESP_MANAGELCD_H
#include "ManageLcd.h"
ManageLcd lcdManager;
#endif
    server.on("/setAlarm", HTTP_GET, [](AsyncWebServerRequest * request) {
    if(request->hasParam("time")) {
        AsyncWebParameter* p = request->getParam("time");
        Serial.printf("Received %s with value %s from IP: \n", p->name().c_str(), p->value().c_str());
        Serial.println(request->client()->remoteIP());
        request->send(200, "text/plain", "OK");
        timeManager.saveAlarmTime(String(p->value()));
        lcdManager.printTextLcd("New request"); <--- This line causes crash
    }
    });

ManageLCD.h

class ManageLcd {
public:
  void printTextLcd(String text);
};

ManageLcd.cpp

#include "ManageLcd.h"
void ManageLcd::printTextLcd(String text){
    display.clearDisplay();
    display.display();
    display.print(text);
    display.display();
    delay(1000);
}

Error i get on serial monitor https://pastebin.com/Uftz5ThJ I don't have idea how to decode this. Using those libraries https://github.com/me-no-dev/ESPAsyncWebServer and https://github.com/adafruit/Adafruit_SSD1306

1 Answers1

0

You are missing to call the setupLcd from the ManageLcd object.

Here is an example of its initialization:

ManageLcd lcdManager;
if(!lcdManager.setupLcd()) {
    while(true){
        Serial.println("LCD allocation failed");
        delay(1000);
    }
}
lcdManager.clearLcd();
lcdManager.printTextLcd("New request");
campescassiano
  • 809
  • 5
  • 18