1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-21 22:50:55 +00:00

update examples with esp8266 specifics

This commit is contained in:
David Gauchard 2023-07-19 12:07:25 +02:00
parent c3bf9c5d00
commit b45f4f7356
6 changed files with 80 additions and 0 deletions

View File

@ -26,8 +26,18 @@
#include <WiFi.h> #include <WiFi.h>
#include <ESPmDNS.h> #include <ESPmDNS.h>
#else #else
// esp8266
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESP8266mDNS.h> #include <ESP8266mDNS.h>
#include <umm_malloc/umm_heap_select.h>
#ifndef MMU_IRAM_HEAP
#warning Try MMU option '2nd heap shared' in 'tools' IDE menu (cf. https://arduino-esp8266.readthedocs.io/en/latest/mmu.html#option-summary)
#warning use decorators: { HeapSelectIram doAllocationsInIRAM; ESPUI.addControl(...) ... } (cf. https://arduino-esp8266.readthedocs.io/en/latest/mmu.html#how-to-select-heap)
#warning then check http://<ip>/heap
#endif // MMU_IRAM_HEAP
#ifndef DEBUG_ESP_OOM
#error on ESP8266 and ESPUI, you must define OOM debug option when developping
#endif
#endif #endif
//Settings //Settings
@ -62,6 +72,11 @@ volatile bool updates = false;
// This is the main function which builds our GUI // This is the main function which builds our GUI
void setUpUI() { void setUpUI() {
#ifdef ESP8266
{ HeapSelectIram doAllocationsInIRAM;
#endif
//Turn off verbose debugging //Turn off verbose debugging
ESPUI.setVerbosity(Verbosity::Quiet); ESPUI.setVerbosity(Verbosity::Quiet);
@ -274,6 +289,11 @@ void setUpUI() {
//Finally, start up the UI. //Finally, start up the UI.
//This should only be called once we are connected to WiFi. //This should only be called once we are connected to WiFi.
ESPUI.begin(HOSTNAME); ESPUI.begin(HOSTNAME);
#ifdef ESP8266
} // HeapSelectIram
#endif
} }
//This callback generates and applies inline styles to a bunch of controls to change their colour. //This callback generates and applies inline styles to a bunch of controls to change their colour.

View File

@ -0,0 +1 @@
// placeholder

View File

@ -8,7 +8,17 @@ DNSServer dnsServer;
#if defined(ESP32) #if defined(ESP32)
#include <WiFi.h> #include <WiFi.h>
#else #else
// esp8266
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <umm_malloc/umm_heap_select.h>
#ifndef MMU_IRAM_HEAP
#warning Try MMU option '2nd heap shared' in 'tools' IDE menu (cf. https://arduino-esp8266.readthedocs.io/en/latest/mmu.html#option-summary)
#warning use decorators: { HeapSelectIram doAllocationsInIRAM; ESPUI.addControl(...) ... } (cf. https://arduino-esp8266.readthedocs.io/en/latest/mmu.html#how-to-select-heap)
#warning then check http://<ip>/heap
#endif // MMU_IRAM_HEAP
#ifndef DEBUG_ESP_OOM
#error on ESP8266 and ESPUI, you must define OOM debug option when developping
#endif
#endif #endif
const char* ssid = "ESPUI"; const char* ssid = "ESPUI";
@ -235,6 +245,10 @@ void setup(void)
Serial.print("IP address: "); Serial.print("IP address: ");
Serial.println(WiFi.getMode() == WIFI_AP ? WiFi.softAPIP() : WiFi.localIP()); Serial.println(WiFi.getMode() == WIFI_AP ? WiFi.softAPIP() : WiFi.localIP());
#ifdef ESP8266
{ HeapSelectIram doAllocationsInIRAM;
#endif
status = ESPUI.addControl(ControlType::Label, "Status:", "Stop", ControlColor::Turquoise); status = ESPUI.addControl(ControlType::Label, "Status:", "Stop", ControlColor::Turquoise);
uint16_t select1 = ESPUI.addControl( uint16_t select1 = ESPUI.addControl(
@ -281,6 +295,10 @@ void setup(void)
*/ */
ESPUI.begin("ESPUI Control"); ESPUI.begin("ESPUI Control");
#ifdef ESP8266
} // HeapSelectIram
#endif
} }
void loop(void) void loop(void)

View File

@ -8,7 +8,17 @@ DNSServer dnsServer;
#if defined(ESP32) #if defined(ESP32)
#include <WiFi.h> #include <WiFi.h>
#else #else
// esp8266
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <umm_malloc/umm_heap_select.h>
#ifndef MMU_IRAM_HEAP
#warning Try MMU option '2nd heap shared' in 'tools' IDE menu (cf. https://arduino-esp8266.readthedocs.io/en/latest/mmu.html#option-summary)
#warning use decorators: { HeapSelectIram doAllocationsInIRAM; ESPUI.addControl(...) ... } (cf. https://arduino-esp8266.readthedocs.io/en/latest/mmu.html#how-to-select-heap)
#warning then check http://<ip>/heap
#endif // MMU_IRAM_HEAP
#ifndef DEBUG_ESP_OOM
#error on ESP8266 and ESPUI, you must define OOM debug option when developping
#endif
#endif #endif
const char* ssid = "ESPUI"; const char* ssid = "ESPUI";
@ -225,6 +235,10 @@ void setup(void)
Serial.print("IP address: "); Serial.print("IP address: ");
Serial.println(WiFi.getMode() == WIFI_AP ? WiFi.softAPIP() : WiFi.localIP()); Serial.println(WiFi.getMode() == WIFI_AP ? WiFi.softAPIP() : WiFi.localIP());
#ifdef ESP8266
{ HeapSelectIram doAllocationsInIRAM;
#endif
statusLabelId = ESPUI.label("Status:", ControlColor::Turquoise, "Stop"); statusLabelId = ESPUI.label("Status:", ControlColor::Turquoise, "Stop");
millisLabelId = ESPUI.label("Millis:", ControlColor::Emerald, "0"); millisLabelId = ESPUI.label("Millis:", ControlColor::Emerald, "0");
ESPUI.button("Push Button", &buttonCallback, ControlColor::Peterriver, "Press"); ESPUI.button("Push Button", &buttonCallback, ControlColor::Peterriver, "Press");
@ -257,6 +271,10 @@ void setup(void)
* password, for example begin("ESPUI Control", "username", "password") * password, for example begin("ESPUI Control", "username", "password")
*/ */
ESPUI.begin("ESPUI Control"); ESPUI.begin("ESPUI Control");
#ifdef ESP8266
} // HeapSelectIram
#endif
} }
void loop(void) void loop(void)

View File

@ -8,7 +8,17 @@ DNSServer dnsServer;
#if defined(ESP32) #if defined(ESP32)
#include <WiFi.h> #include <WiFi.h>
#else #else
// esp8266
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <umm_malloc/umm_heap_select.h>
#ifndef MMU_IRAM_HEAP
#warning Try MMU option '2nd heap shared' in 'tools' IDE menu (cf. https://arduino-esp8266.readthedocs.io/en/latest/mmu.html#option-summary)
#warning use decorators: { HeapSelectIram doAllocationsInIRAM; ESPUI.addControl(...) ... } (cf. https://arduino-esp8266.readthedocs.io/en/latest/mmu.html#how-to-select-heap)
#warning then check http://<ip>/heap
#endif // MMU_IRAM_HEAP
#ifndef DEBUG_ESP_OOM
#error on ESP8266 and ESPUI, you must define OOM debug option when developping
#endif
#endif #endif
const char* ssid = "ESPUI"; const char* ssid = "ESPUI";
@ -233,6 +243,10 @@ void setup(void)
Serial.print("IP address: "); Serial.print("IP address: ");
Serial.println(WiFi.getMode() == WIFI_AP ? WiFi.softAPIP() : WiFi.localIP()); Serial.println(WiFi.getMode() == WIFI_AP ? WiFi.softAPIP() : WiFi.localIP());
#ifdef ESP8266
{ HeapSelectIram doAllocationsInIRAM;
#endif
uint16_t tab1 = ESPUI.addControl(ControlType::Tab, "Settings 1", "Settings 1"); uint16_t tab1 = ESPUI.addControl(ControlType::Tab, "Settings 1", "Settings 1");
uint16_t tab2 = ESPUI.addControl(ControlType::Tab, "Settings 2", "Settings 2"); uint16_t tab2 = ESPUI.addControl(ControlType::Tab, "Settings 2", "Settings 2");
uint16_t tab3 = ESPUI.addControl(ControlType::Tab, "Settings 3", "Settings 3"); uint16_t tab3 = ESPUI.addControl(ControlType::Tab, "Settings 3", "Settings 3");
@ -279,6 +293,10 @@ void setup(void)
*/ */
ESPUI.begin("ESPUI Control"); ESPUI.begin("ESPUI Control");
#ifdef ESP8266
} // HeapSelectIram
#endif
} }
void loop(void) void loop(void)

View File

@ -98,8 +98,13 @@ public:
#endif // def ESP32 #endif // def ESP32
unsigned int jsonUpdateDocumentSize = 2000; unsigned int jsonUpdateDocumentSize = 2000;
#ifdef ESP8266
unsigned int jsonInitialDocumentSize = 2000;
unsigned int jsonChunkNumberMax = 5;
#else
unsigned int jsonInitialDocumentSize = 8000; unsigned int jsonInitialDocumentSize = 8000;
unsigned int jsonChunkNumberMax = 0; unsigned int jsonChunkNumberMax = 0;
#endif
bool sliderContinuous = false; bool sliderContinuous = false;
void onWsEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len); void onWsEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len);
bool captivePortal = true; bool captivePortal = true;