From 1fbe1d185542d1f58338fda989a7787aca842a79 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Mon, 7 Sep 2020 21:01:10 +0200 Subject: [PATCH 1/6] New Segments are now initialized with default speed and intensity --- CHANGELOG.md | 4 ++++ wled00/FX.h | 1 + wled00/FX_fcn.cpp | 3 +++ wled00/wled.h | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e12a25f00..be0750bec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ### Development versions after the 0.10.2 release +#### Build 2009070 + +- New Segments are now initialized with default speed and intensity + #### Build 2009030 - Fixed bootloop if mDNS is used on builds without OTA support diff --git a/wled00/FX.h b/wled00/FX.h index 05802b8fc..86238c2e3 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -37,6 +37,7 @@ #define DEFAULT_BRIGHTNESS (uint8_t)127 #define DEFAULT_MODE (uint8_t)0 #define DEFAULT_SPEED (uint8_t)128 +#define DEFAULT_INTENSITY (uint8_t)128 #define DEFAULT_COLOR (uint32_t)0xFFAA00 #define MIN(a,b) ((a)<(b)?(a):(b)) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index d979dfcf6..20bed9516 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -529,6 +529,7 @@ void WS2812FX::resetSegments() { _segments[0].colors[0] = DEFAULT_COLOR; _segments[0].start = 0; _segments[0].speed = DEFAULT_SPEED; + _segments[0].intensity = DEFAULT_INTENSITY; _segments[0].stop = _length; _segments[0].grouping = 1; _segments[0].setOption(SEG_OPTION_SELECTED, 1); @@ -541,6 +542,8 @@ void WS2812FX::resetSegments() { _segments[i].grouping = 1; _segments[i].setOption(SEG_OPTION_ON, 1); _segments[i].opacity = 255; + _segments[i].speed = DEFAULT_SPEED; + _segments[i].intensity = DEFAULT_INTENSITY; _segment_runtimes[i].reset(); } _segment_runtimes[0].reset(); diff --git a/wled00/wled.h b/wled00/wled.h index f1245f493..bdbc9b861 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2009030 +#define VERSION 2009070 // ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS). From 5896b1eb71642a71b34736944cdaa09883e93be2 Mon Sep 17 00:00:00 2001 From: Woody <27882680+WoodyLetsCode@users.noreply.github.com> Date: Mon, 7 Sep 2020 21:04:21 +0200 Subject: [PATCH 2/6] Open releases in new tab (#1152) * open releases in new tab * Revert "open releases in new tab" This reverts commit 6e3940c8eb46c8a17ed5477cf2f0ff9f1a2f5db7. * open releases in new tab Co-authored-by: Woody <> --- wled00/data/update.htm | 2 +- wled00/html_other.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/data/update.htm b/wled00/data/update.htm index be5949897..aa818c5d8 100644 --- a/wled00/data/update.htm +++ b/wled00/data/update.htm @@ -33,7 +33,7 @@

WLED Software Update

Installed version: ##VERSION##
Download the latest binary:

+ + \ No newline at end of file diff --git a/wled00/data/welcome.htm b/wled00/data/welcome.htm index 0542aff54..f0e1b463d 100644 --- a/wled00/data/welcome.htm +++ b/wled00/data/welcome.htm @@ -3,13 +3,13 @@ - - WLED Setup + + Welcome! - - - - -

- + +

Welcome to WLED!

Thank you for installing my application!

-If you encounter a bug or have a question/feature suggestion, feel free to open a GitHub issue!

Next steps:

Connect the module to your local WiFi here!

Just trying this out in AP mode?
- - +
+
\ No newline at end of file diff --git a/wled00/html_other.h b/wled00/html_other.h index dc77cd51f..e78f6d185 100644 --- a/wled00/html_other.h +++ b/wled00/html_other.h @@ -52,27 +52,17 @@ onclick="B()">Back)====="; // Autogenerated from wled00/data/welcome.htm, do not edit!! const char PAGE_welcome[] PROGMEM = R"=====(WLED Setup - - - -

-

Welcome to WLED!

Thank you for installing my application!

-If you encounter a bug or have a question/feature suggestion, feel free to open a GitHub issue! -

Next steps:

Connect the module to your local WiFi here! -

Just trying this out in AP mode?
-)====="; +content="#222222">Welcome! +

Welcome to WLED!

+Thank you for installing my application!

Next steps:

+Connect the module to your local WiFi here!

+Just trying this out in AP mode?

+)====="; // Autogenerated from wled00/data/liveview.htm, do not edit!! From 57421d2392e1188a0f4a27a1df5af3cf8eeeb592 Mon Sep 17 00:00:00 2001 From: Phil Bolduc Date: Sun, 13 Sep 2020 10:26:27 -0700 Subject: [PATCH 5/6] Async temperature usermod (#1178) * Change Temperature usermod to use async reading to avoid blocking * Fix comparison on wait time * Add * Simplify logic in the loop method * Optimize calls to minimize latency, inform user how long till first measurement * disable usermod if sensor not found * Added debug statements on init, update readme * fix spelling error of celsius --- usermods/Temperature/platformio_override.ini | 13 ++ usermods/Temperature/readme.md | 26 +++- usermods/Temperature/usermod_temperature.h | 141 ++++++++++++++++--- usermods/Temperature/usermods_list.cpp | 8 +- wled00/usermods_list.cpp | 8 +- 5 files changed, 166 insertions(+), 30 deletions(-) create mode 100644 usermods/Temperature/platformio_override.ini diff --git a/usermods/Temperature/platformio_override.ini b/usermods/Temperature/platformio_override.ini new file mode 100644 index 000000000..d9e3fbace --- /dev/null +++ b/usermods/Temperature/platformio_override.ini @@ -0,0 +1,13 @@ +; Options +; ------- +; USERMOD_DALLASTEMPERATURE - define this to have this user mod included wled00\usermods_list.cpp +; USERMOD_DALLASTEMPERATURE_CELSIUS - define this to report temperatures in degrees celsius, otherwise fahrenheit will be reported +; USERMOD_DALLASTEMPERATURE_MEASUREMENT_INTERVAL - the number of milliseconds between measurements, defaults to 60 seconds +; USERMOD_DALLASTEMPERATURE_FIRST_MEASUREMENT_AT - the number of milliseconds after boot to take first measurement, defaults to 20 seconds +; +[env:d1_mini_usermod_dallas_temperature_C] +extends = env:d1_mini +build_flags = ${common.build_flags_esp8266} -D USERMOD_DALLASTEMPERATURE -D USERMOD_DALLASTEMPERATURE_CELSIUS +lib_deps = ${env.lib_deps} + milesburton/DallasTemperature@^3.9.0 + OneWire@~2.3.5 diff --git a/usermods/Temperature/readme.md b/usermods/Temperature/readme.md index f6ce85329..5e26ba696 100644 --- a/usermods/Temperature/readme.md +++ b/usermods/Temperature/readme.md @@ -5,11 +5,18 @@ This usermod will read from an attached DS18B20 temperature sensor (as available The temperature is displayed both in the Info section of the web UI as well as published to the `/temperature` MQTT topic if enabled. This usermod will be expanded with support for different sensor types in the future. +If temperature sensor is not detected during boot, this usermod will be disabled. + ## Installation -Copy `usermod_temperature.h` to the wled00 directory. -Uncomment the corresponding lines in `usermods_list.cpp` and compile! -If this is the only v2 usermod you plan to use, you can alternatively replace `usermods_list.h` in wled00 with the one in this folder. +Copy the example `platformio_override.ini` to the root directory. This file should be placed in the same directory as `platformio.ini`. + +### Define Your Options + +* `USERMOD_DALLASTEMPERATURE` - define this to have this user mod included wled00\usermods_list.cpp +* `USERMOD_DALLASTEMPERATURE_CELSIUS` - define this to report temperatures in degrees celsious, otherwise fahrenheit will be reported +* `USERMOD_DALLASTEMPERATURE_MEASUREMENT_INTERVAL` - the number of milliseconds between measurements, defaults to 60 seconds +* `USERMOD_DALLASTEMPERATURE_FIRST_MEASUREMENT_AT` - the number of milliseconds after boot to take first measurement, defaults to 20 seconds ## Project link @@ -17,7 +24,10 @@ If this is the only v2 usermod you plan to use, you can alternatively replace `u ### PlatformIO requirements -You might have to uncomment `DallasTemperature@~3.8.0`,`OneWire@~2.3.5 under` `[common]` section in `platformio.ini`: +If you are using `platformio_override.ini`, you should be able to refresh the task list and see your custom task, for example `env:d1_mini_usermod_dallas_temperature_C`. + + +If you are not using `platformio_override.ini`, you might have to uncomment `DallasTemperature@~3.8.0`,`OneWire@~2.3.5 under` `[common]` section in `platformio.ini`: ```ini # platformio.ini @@ -38,3 +48,11 @@ lib_deps_external = OneWire@~2.3.5 ... ``` + +## Change Log + +2020-09-12 +* Changed to use async, non-blocking implementation +* Do not report low temperatures that indicate an error to mqtt +* Disable plugin if temperature sensor not detected +* Report the number of seconds until the first read in the info screen instead of sensor error \ No newline at end of file diff --git a/usermods/Temperature/usermod_temperature.h b/usermods/Temperature/usermod_temperature.h index eb123df01..d72be934b 100644 --- a/usermods/Temperature/usermod_temperature.h +++ b/usermods/Temperature/usermod_temperature.h @@ -11,61 +11,156 @@ #define TEMPERATURE_PIN 14 #endif -#define TEMP_CELSIUS // Comment out for Fahrenheit +// the frequency to check temperature, 1 minute +#ifndef USERMOD_DALLASTEMPERATURE_MEASUREMENT_INTERVAL +#define USERMOD_DALLASTEMPERATURE_MEASUREMENT_INTERVAL 60000 +#endif -#define MEASUREMENT_INTERVAL 60000 //1 Minute +// how many seconds after boot to take first measurement, 20 seconds +#ifndef USERMOD_DALLASTEMPERATURE_FIRST_MEASUREMENT_AT +#define USERMOD_DALLASTEMPERATURE_FIRST_MEASUREMENT_AT 20000 +#endif OneWire oneWire(TEMPERATURE_PIN); DallasTemperature sensor(&oneWire); class UsermodTemperature : public Usermod { private: - //set last reading as "40 sec before boot", so first reading is taken after 20 sec - unsigned long lastMeasurement = UINT32_MAX - 40000; - float temperature = 0.0f; - public: - void getReading() { - sensor.requestTemperatures(); - #ifdef TEMP_CELSIUS - temperature = sensor.getTempCByIndex(0); - #else - temperature = sensor.getTempFByIndex(0); - #endif + // The device's unique 64-bit serial code stored in on-board ROM. + // Reading directly from the sensor device address is faster than + // reading from index. When reading by index, DallasTemperature + // must first look up the device address at the specified index. + DeviceAddress sensorDeviceAddress; + // set last reading as "40 sec before boot", so first reading is taken after 20 sec + unsigned long lastMeasurement = UINT32_MAX - (USERMOD_DALLASTEMPERATURE_MEASUREMENT_INTERVAL - USERMOD_DALLASTEMPERATURE_FIRST_MEASUREMENT_AT); + // last time requestTemperatures was called + // used to determine when we can read the sensors temperature + // we have to wait at least 93.75 ms after requestTemperatures() is called + unsigned long lastTemperaturesRequest; + float temperature = -100; // default to -100, DS18B20 only goes down to -50C + // indicates requestTemperatures has been called but the sensor measurement is not complete + bool waitingForConversion = false; + // flag to indicate we have finished the first getTemperature call + // allows this library to report to the user how long until the first + // measurement + bool getTemperatureComplete = false; + // flag set at startup if DS18B20 sensor not found, avoids trying to keep getting + // temperature if flashed to a board without a sensor attached + bool disabled = false; + + void requestTemperatures() { + // there is requestTemperaturesByAddress however it + // appears to do more work, + // TODO: measure exection time difference + sensor.requestTemperatures(); + lastTemperaturesRequest = millis(); + waitingForConversion = true; } + void getTemperature() { + #ifdef USERMOD_DALLASTEMPERATURE_CELSIUS + temperature = sensor.getTempC(sensorDeviceAddress); + #else + temperature = sensor.getTempF(sensorDeviceAddress); + #endif + + lastMeasurement = millis(); + waitingForConversion = false; + getTemperatureComplete = true; + } + + public: + + void setup() { sensor.begin(); - sensor.setResolution(9); + + // get the unique 64-bit serial code stored in on-board ROM + // if getAddress returns false, the sensor was not found + disabled = !sensor.getAddress(sensorDeviceAddress, 0); + + if (!disabled) { + DEBUG_PRINTLN("Dallas Temperature found"); + // set the resolution for this specific device + sensor.setResolution(sensorDeviceAddress, 9, true); + // do not block waiting for reading + sensor.setWaitForConversion(false); + } else { + DEBUG_PRINTLN("Dallas Temperature not found"); + } } void loop() { - if (millis() - lastMeasurement > MEASUREMENT_INTERVAL) - { - getReading(); + if (disabled) { + return; + } + + unsigned long now = millis(); + // check to see if we are due for taking a measurement + // lastMeasurement will not be updated until the conversion + // is complete the the reading is finished + if (now - lastMeasurement < USERMOD_DALLASTEMPERATURE_MEASUREMENT_INTERVAL) + { + return; + } + + // we are due for a measurement, if we are not already waiting + // for a conversion to complete, then make a new request for temps + if (!waitingForConversion) + { + requestTemperatures(); + return; + } + + // we were waiting for a conversion to complete, have we waited log enough? + if (now - lastTemperaturesRequest >= 94 /* 93.75ms per the datasheet */) + { + getTemperature(); + if (WLED_MQTT_CONNECTED) { char subuf[38]; strcpy(subuf, mqttDeviceTopic); - strcat(subuf, "/temperature"); - mqtt->publish(subuf, 0, true, String(temperature).c_str()); + if (-100 <= temperature) { + // dont publish super low temperature as the graph will get messed up + // the DallasTemperature library returns -127C or -196.6F when problem + // reading the sensor + strcat(subuf, "/temperature"); + mqtt->publish(subuf, 0, true, String(temperature).c_str()); + } else { + // publish something else to indicate status? + } } - lastMeasurement = millis(); } } void addToJsonInfo(JsonObject& root) { + // dont add temperature to info if we are disabled + if (disabled) { + return; + } + JsonObject user = root["u"]; if (user.isNull()) user = root.createNestedObject("u"); JsonArray temp = user.createNestedArray("Temperature"); - if (temperature == DEVICE_DISCONNECTED_C) { + + if (!getTemperatureComplete) { + // if we haven't read the sensor yet, let the user know + // that we are still waiting for the first measurement + temp.add((USERMOD_DALLASTEMPERATURE_FIRST_MEASUREMENT_AT - millis()) / 1000); + temp.add(" sec until read"); + return; + } + + if (temperature <= -100) { temp.add(0); temp.add(" Sensor Error!"); return; } temp.add(temperature); - #ifdef TEMP_CELSIUS + #ifdef USERMOD_DALLASTEMPERATURE_CELSIUS temp.add("°C"); #else temp.add("°F"); @@ -76,4 +171,4 @@ class UsermodTemperature : public Usermod { { return USERMOD_ID_TEMPERATURE; } -}; \ No newline at end of file +}; diff --git a/usermods/Temperature/usermods_list.cpp b/usermods/Temperature/usermods_list.cpp index 1a1efdd70..50dd7816b 100644 --- a/usermods/Temperature/usermods_list.cpp +++ b/usermods/Temperature/usermods_list.cpp @@ -9,7 +9,10 @@ * \/ \/ \/ */ //#include "usermod_v2_example.h" -#include "usermod_temperature.h" +#ifdef USERMOD_DALLASTEMPERATURE +#include "../usermods/Temperature/usermod_temperature.h" +#endif + //#include "usermod_v2_empty.h" void registerUsermods() @@ -20,6 +23,9 @@ void registerUsermods() * \/ \/ \/ */ //usermods.add(new MyExampleUsermod()); +#ifdef USERMOD_DALLASTEMPERATURE usermods.add(new UsermodTemperature()); +#endif + //usermods.add(new UsermodRenameMe()); } \ No newline at end of file diff --git a/wled00/usermods_list.cpp b/wled00/usermods_list.cpp index dcecd0ff9..90b180740 100644 --- a/wled00/usermods_list.cpp +++ b/wled00/usermods_list.cpp @@ -10,7 +10,9 @@ * \/ \/ \/ */ //#include "usermod_v2_example.h" -//#include "usermod_temperature.h" +#ifdef USERMOD_DALLASTEMPERATURE +#include "../usermods/Temperature/usermod_temperature.h" +#endif //#include "usermod_v2_empty.h" void registerUsermods() @@ -21,6 +23,8 @@ void registerUsermods() * \/ \/ \/ */ //usermods.add(new MyExampleUsermod()); - //usermods.add(new UsermodTemperature()); + #ifdef USERMOD_DALLASTEMPERATURE + usermods.add(new UsermodTemperature()); + #endif //usermods.add(new UsermodRenameMe()); } \ No newline at end of file From 26a8686a54bf5cfa76807b2004d2df0ec6b02274 Mon Sep 17 00:00:00 2001 From: Jeff Rescignano Date: Sun, 13 Sep 2020 15:29:36 -0400 Subject: [PATCH 6/6] Firefox Custom Scrollbar (#1163) * Firefox custom scrollbar * Put Firefox scrollbar css in first body tag Co-authored-by: cschwinne --- wled00/data/index.htm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wled00/data/index.htm b/wled00/data/index.htm index 71292e4b1..8b532de8e 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -60,6 +60,8 @@ body { -ms-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; + scrollbar-width: 6px; + scrollbar-color: var(--c-sb) transparent; } html,