1
0
mirror of https://github.com/s00500/ESPUI.git synced 2025-07-05 02:40:18 +00:00

Checkpoint adding fileDisplay object

This commit is contained in:
Martin
2024-02-06 22:38:17 -05:00
parent aa9a62bbdf
commit ea8de92246
7 changed files with 95 additions and 21 deletions

View File

@ -805,6 +805,11 @@ uint16_t ESPUIClass::separator(const char* label)
return addControl(ControlType::Separator, label, "", ControlColor::Alizarin, Control::noParent, nullptr);
}
uint16_t ESPUIClass::fileDisplay(const char* label, ControlColor color, String filename)
{
return addControl(ControlType::FileDisplay, label, filename, color, Control::noParent);
}
uint16_t ESPUIClass::accelerometer(const char* label, std::function<void(Control*, int)> callback, ControlColor color)
{
return addControl(ControlType::Accel, label, "", color, Control::noParent, callback);
@ -1425,6 +1430,14 @@ void ESPUIClass::begin(const char* _title, const char* username, const char* pas
server->onNotFound([this](AsyncWebServerRequest* request) {
if (captivePortal)
{
AsyncResponseStream *response = request->beginResponseStream("text/html");
String responseText;
responseText.reserve(1024);
responseText += F("<!DOCTYPE html><html><head><title>Captive Portal</title></head><body>");
responseText += ("<p>If site does not re-direct click here <a href='http://" + WiFi.softAPIP().toString() + "'>this link</a></p>");
responseText += ("</body></html><head><meta http-equiv=\"Refresh\" content=\"0; URL='http://" + WiFi.softAPIP().toString() + "'\" /></head>");
response->write(responseText.c_str(), responseText.length());
request->send(response);
request->redirect("/");
}
else

View File

@ -143,6 +143,7 @@ public:
uint16_t gauge(const char* label, ControlColor color, int value, int min = 0,
int max = 100); // Create Gauge display
uint16_t separator(const char* label); //Create separator
uint16_t fileDisplay(const char* label, ControlColor color, String filename);
// Input only
uint16_t accelerometer(const char* label, std::function<void(Control*, int)> callback, ControlColor color);

View File

@ -280,3 +280,4 @@ void Control::onWsEvent(String & cmd, String& data)
}
} while (false);
}

View File

@ -30,8 +30,9 @@ enum ControlType : uint8_t
Accel,
Separator,
Time,
FileDisplay,
Fragment,
Fragment = 98,
Password = 99,
UpdateOffset = 100,
};
@ -93,6 +94,7 @@ public:
private:
bool _ToBeDeleted = false;
uint32_t ControlChangeID = 0;
String OldValue = emptyString;
};
#define UI_TITLE ControlType::Title