From 134ec052fc9ac621e06119e3d1c5c4fb6c006bab Mon Sep 17 00:00:00 2001 From: cschwinne Date: Mon, 8 May 2017 21:00:06 +0200 Subject: [PATCH] added power button to html made spiffs optional (disabled by default) --- readme.md | 19 +++++++------------ wled00/data/index.htm | 25 ++++++++++++++++++++++++- wled00/htmls00.h | 4 ++++ wled00/wled00.ino | 7 +++++-- wled00/wled04_file.ino | 9 +++++++++ wled00/wled05_init.ino | 5 ++++- 6 files changed, 53 insertions(+), 16 deletions(-) diff --git a/readme.md b/readme.md index e2eaceec9..5c6b868fb 100644 --- a/readme.md +++ b/readme.md @@ -1,13 +1,12 @@ WLED is a basic, fast and (relatively) (ok, VERY relatively) secure implementation of a ESP8266 webserver to control Neopixel (WS2812B) leds -Uses ESP arduino version 2.3.0 (latest as of April 2017). +Uses ESP arduino version 2.3.0 (latest as of May 2017). Contents in the /data directory may be uploaded to SPIFFS. Features: (V0.3pd) - RGB and brightness sliders - Settings page - configuration over network - Access Point and station mode - automatic failsafe AP -- Edit page. Change html and other files via OTA. - WS2812FX library integrated for nearly 50 special effects! - Nightlight function (gradually dims down) - Notifier function (multiple ESPs sync color via UDP broadcast) @@ -17,9 +16,10 @@ Features: (V0.3pd) - Alexa smart home device server - (unstable) NTP and experimental analog clock function - better client HTML page (not yet implemented) +- Edit page. Change html and other files via OTA. (needs to be enabled in source) Compile settings: -Board: WeMos D1 mini (untested with other HW, should work if it has 4MB flash) +Board: WeMos D1 mini (untested with other HW, should work though) CPU frequency: 80 MHz Flash size : 4MB (1MB SPIFFS) Upload speed: 115200 @@ -31,22 +31,17 @@ Quick start guide: Just flash a basic HTTP OTA updater sketch and upload the bin! -1. Make sure your ESP module has a min. 4MB SPI flash module. (currently working on supporting 1MB modules) +1. Make sure your ESP module has a min. 4MB SPI flash module. (SHOULD now support 1MB modules, untested) Connect a WS2812B RGB led strip to GPIO2. Optionally connect a NO-pushbutton to GPIO0 (internal pull-up) and ground. 2. Follow a guide to setup your Arduino client (I am using version 1.8.1) with the ESP8266 libraries. For current compiles I use version 2.3.0. -3. You will also need the ESP8266 SPIFFS sketch data uploader. (currently working on making this step unnecessary) --> In the newest commit this step is not essential (HTML included in sketch), but recommended, since otherwise you have to upload the pictures manually to /edit SPIFFS --> The software will always use the HTML files in SPIFFS. If they are not existing, it will fallback to the sketch embedded HTML files. - -4. In file "wled00.ino", change the LED count to the amount you connected. Proceed to flash the sketch and the SPIFFS data. -You should also change the access point and OTA update passphrases for added security (you can change them later, this is just the "factory default"). +3. In file "wled00.ino", you should change the access point and OTA update passphrases for added security (you can change them later, this is just the "factory default"). Flash the sketch. 5. Connect to automatically started WiFi access point "WLED-AP" using default passwort "wled1234". Go to the IP "192.168.4.1". -6. Click on the wrench icon to edit settings like connecting the module to your home WiFi. +6. Click on the cog icon to edit settings like connecting the module to your home WiFi. 7. Have fun with the software! @@ -87,7 +82,7 @@ Method 2: The software has an integrated OTA software update capability. First you have to enable it by typing in the correct OTA passphrase (default: "wledota") in the settings menu. Remove the tick in the checkbox "OTA locked". Then save settings and reboot the ESP. Now you can go to "/update" to update binary firmware. -To edit flash content (images and HTML), go to "/edit". +To edit flash content (images and HTML), go to "/edit". (only if USEFS was uncommented in source) After you are done, it is recommended to lock the OTA function again. To do so, tick the checkbox again (you can change the passphrase by typing in a new one now). Reboot. If you try to access the update page now, you should see the message "OTA lock active". diff --git a/wled00/data/index.htm b/wled00/data/index.htm index 4ed086c36..2c116f35c 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -114,6 +114,25 @@ } else { nsb.style.fill="black"; } + if (Ctrl_form.SA.value > 0) + { + tgb.style.fill="green"; + } else { + tgb.style.fill="black"; + } + } + function ToggleT() + { + if (Ctrl_form.SA.value > 0) + { + strA = "&T=0"; + Ctrl_form.SA.value = 0; + } else + { + strA = "&T=2"; + } + UpdateVals(); + GetArduinoIO(); } function ToggleFX() { @@ -397,7 +416,7 @@ transform: translate(-50%, -50%); } svg { - width: 15vw; + width: 12vw; height: 10vmin; } input[type=range] { @@ -474,6 +493,9 @@ + + + @@ -495,6 +517,7 @@
+ diff --git a/wled00/htmls00.h b/wled00/htmls00.h index 591aebd23..f38ca8c83 100644 --- a/wled00/htmls00.h +++ b/wled00/htmls00.h @@ -231,8 +231,12 @@ const char PAGE_index[] PROGMEM = R"=====( /* * SPIFFS editor html */ +#ifdef USEFS const char PAGE_edit[] PROGMEM = R"=====( ESP Editor
)====="; +#else +const char PAGE_edit[] PROGMEM = R"=====(SPIFFS disabled by firmware)====="; +#endif diff --git a/wled00/wled00.ino b/wled00/wled00.ino index a2f35a092..c40542f82 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -22,10 +22,13 @@ #include "CallbackFunction.h" //version in format yymmddb (b = daily build) -#define VERSION 1705081 +#define VERSION 1705082 //to toggle usb serial debug (un)comment following line -#define DEBUG +//#define DEBUG + +//spiffs FS only useful for debug +//#define USEFS #ifdef DEBUG #define DEBUG_PRINT(x) Serial.print (x) diff --git a/wled00/wled04_file.ino b/wled00/wled04_file.ino index 2b4b704c9..dbe406aa7 100644 --- a/wled00/wled04_file.ino +++ b/wled00/wled04_file.ino @@ -1,6 +1,7 @@ /* * Utility for SPIFFS filesystem */ +#ifdef USEFS String formatBytes(size_t bytes){ if (bytes < 1024){ @@ -122,3 +123,11 @@ void handleFileCreate(){ server.send(200, "text/plain", ""); path = String(); } + +#else +bool handleFileRead(String path){return false;} +void handleFileList(){} +void handleFileCreate(){} +void handleFileDelete(){} +void handleFileUpload(){} +#endif diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 9639016ab..25e25eb60 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -5,7 +5,8 @@ void wledInit() { Serial.begin(115200); - + + #ifdef USEFS SPIFFS.begin(); { Dir dir = SPIFFS.openDir("/"); @@ -18,6 +19,8 @@ void wledInit() } DEBUG_PRINTF("\n"); } + #endif + DEBUG_PRINTLN("Init EEPROM"); EEPROM.begin(1024); loadSettingsFromEEPROM();