mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Free some more bytes from GPIOViewer
This commit is contained in:
parent
9fc47b7d90
commit
1854b9a069
@ -18,24 +18,24 @@
|
|||||||
#define XDRV_121 121
|
#define XDRV_121 121
|
||||||
|
|
||||||
#ifndef GV_PORT
|
#ifndef GV_PORT
|
||||||
#define GV_PORT 5557
|
#define GV_PORT 5557 // SSE webserver port
|
||||||
#endif
|
#endif
|
||||||
#ifndef GV_SAMPLING_INTERVAL
|
#ifndef GV_SAMPLING_INTERVAL
|
||||||
#define GV_SAMPLING_INTERVAL 100 // [GvSampling] milliseconds - Use Tasmota Scheduler (100) or Ticker (20..99,101..1000)
|
#define GV_SAMPLING_INTERVAL 100 // [GvSampling] milliseconds - Use Tasmota Scheduler (100) or Ticker (20..99,101..1000)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GV_KEEP_ALIVE 1000 // milliseconds - If no activity after this do a heap size event anyway
|
#define GV_KEEP_ALIVE 1000 // milliseconds - If no activity after this do a heap size event anyway
|
||||||
|
|
||||||
//#define GV_BASE_URL "https://thelastoutpostworkshop.github.io/microcontroller_devkit/gpio_viewer/assets/"
|
//#define GV_BASE_URL "https://thelastoutpostworkshop.github.io/microcontroller_devkit/gpio_viewer/assets/"
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#ifndef GV_BASE_URL
|
#ifndef GV_BASE_URL
|
||||||
#undef GV_BASE_URL // Fix compiler warning
|
#undef GV_BASE_URL // Fix compiler warning
|
||||||
#define GV_BASE_URL "https://ota.tasmota.com/tasmota/gpio_viewer/assets/"
|
#define GV_BASE_URL "https://ota.tasmota.com/tasmota/gpio_viewer/assets/"
|
||||||
#endif
|
#endif
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#ifndef GV_BASE_URL
|
#ifndef GV_BASE_URL
|
||||||
#undef GV_BASE_URL // Fix compiler warning
|
#undef GV_BASE_URL // Fix compiler warning
|
||||||
#define GV_BASE_URL "https://ota.tasmota.com/tasmota32/gpio_viewer/assets/"
|
#define GV_BASE_URL "https://ota.tasmota.com/tasmota32/gpio_viewer/assets/"
|
||||||
#endif
|
#endif
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
@ -49,12 +49,11 @@ const char *GVRelease = "1.0.7";
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char HTTP_GV_EVENT[] PROGMEM =
|
const char HTTP_GV_EVENT[] PROGMEM =
|
||||||
// Set CORS headers for global responses
|
|
||||||
"HTTP/1.1 200 OK\n"
|
"HTTP/1.1 200 OK\n"
|
||||||
"Content-Type: text/event-stream;\n"
|
"Content-Type: text/event-stream;\n" // Server Sent Event protocol
|
||||||
"Connection: keep-alive\n"
|
"Connection: keep-alive\n" // Permanent connection
|
||||||
"Cache-Control: no-cache\n"
|
"Cache-Control: no-cache\n" // Do not store data into local cache
|
||||||
"Access-Control-Allow-Origin: *\n\n";
|
"Access-Control-Allow-Origin: *\n\n"; // Enable CORS
|
||||||
|
|
||||||
enum GVPinTypes {
|
enum GVPinTypes {
|
||||||
GV_DigitalPin = 0,
|
GV_DigitalPin = 0,
|
||||||
@ -119,7 +118,7 @@ void GVHandleRoot(void) {
|
|||||||
0,
|
0,
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
ESP_getFreeSketchSpace() / 1024);
|
ESP_getFreeSketchSpace() / 1024);
|
||||||
if (content == nullptr) { return; } // Avoid crash
|
if (content == nullptr) { return; } // Avoid crash
|
||||||
GV.WebServer->send_P(200, "text/html", content);
|
GV.WebServer->send_P(200, "text/html", content);
|
||||||
free(content);
|
free(content);
|
||||||
}
|
}
|
||||||
@ -172,8 +171,8 @@ void GVCloseEvent(void) {
|
|||||||
void GVEventSend(const char *message, const char *event, uint32_t id) {
|
void GVEventSend(const char *message, const char *event, uint32_t id) {
|
||||||
if (GV.WebClient.connected()) {
|
if (GV.WebClient.connected()) {
|
||||||
// generateEventMessage() in AsyncEventSource.cpp
|
// generateEventMessage() in AsyncEventSource.cpp
|
||||||
// GV.WebClient.printf_P(PSTR("retry: 0\r\nid: %u\r\nevent: %s\r\ndata: %s\r\n\r\n"), id, event, message);
|
// GV.WebClient.printf_P(PSTR("retry:0\nid:%u\nevent:%s\ndata:%s\n\n"), id, event, message);
|
||||||
GV.WebClient.printf_P(PSTR("id: %u\r\nevent: %s\r\ndata: %s\r\n\r\n"), id, event, message);
|
GV.WebClient.printf_P(PSTR("id:%u\nevent:%s\ndata:%s\n\n"), id, event, message);
|
||||||
} else {
|
} else {
|
||||||
GVEventDisconnected();
|
GVEventDisconnected();
|
||||||
}
|
}
|
||||||
@ -299,7 +298,7 @@ void GVMonitorTask(void) {
|
|||||||
* Commands
|
* Commands
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
const char kGVCommands[] PROGMEM = "GV|" // Prefix
|
const char kGVCommands[] PROGMEM = "GV|" // Prefix
|
||||||
"Viewer|Sampling";
|
"Viewer|Sampling";
|
||||||
|
|
||||||
void (* const GVCommand[])(void) PROGMEM = {
|
void (* const GVCommand[])(void) PROGMEM = {
|
||||||
@ -313,13 +312,13 @@ void CmndGvViewer(void) {
|
|||||||
*/
|
*/
|
||||||
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 2)) {
|
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 2)) {
|
||||||
uint32_t state = XdrvMailbox.payload;
|
uint32_t state = XdrvMailbox.payload;
|
||||||
if (2 == state) { // Toggle
|
if (2 == state) { // Toggle
|
||||||
state = GV.active ^1;
|
state = GV.active ^1;
|
||||||
}
|
}
|
||||||
if (state) { // On
|
if (state) { // On
|
||||||
GVBegin();
|
GVBegin();
|
||||||
} else { // Off
|
} else { // Off
|
||||||
GVCloseEvent(); // Stop current updates
|
GVCloseEvent(); // Stop current updates
|
||||||
GVStop();
|
GVStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,8 +334,8 @@ void CmndGvSampling(void) {
|
|||||||
GvSampling 20 .. 1000 - Set sampling interval
|
GvSampling 20 .. 1000 - Set sampling interval
|
||||||
*/
|
*/
|
||||||
if ((XdrvMailbox.payload >= 20) && (XdrvMailbox.payload <= 1000)) {
|
if ((XdrvMailbox.payload >= 20) && (XdrvMailbox.payload <= 1000)) {
|
||||||
GVCloseEvent(); // Stop current updates
|
GVCloseEvent(); // Stop current updates
|
||||||
GV.sampling = XdrvMailbox.payload; // 20 - 1000 milliseconds
|
GV.sampling = XdrvMailbox.payload; // 20 - 1000 milliseconds
|
||||||
}
|
}
|
||||||
ResponseCmndNumber(GV.sampling);
|
ResponseCmndNumber(GV.sampling);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user