diff options
author | Daniel Garcia <danielgarcia@gmail.com> | 2016-01-07 22:27:10 +0300 |
---|---|---|
committer | Daniel Garcia <danielgarcia@gmail.com> | 2016-01-07 22:27:10 +0300 |
commit | 1ec83d92272552361623baeba51dcc7c88b16fde (patch) | |
tree | 541dc4782f36fed74df3d7625eb4b5d10d05d3b6 | |
parent | 78ad4262051fca6f8efcf75fbdd2993b3adb2dda (diff) |
If the version of arduino is greater than 150, toss a yield into FastLED::delay for folks using the scheduler library.
-rw-r--r-- | FastLED.cpp | 6 | ||||
-rw-r--r-- | FastLED.h | 3 |
2 files changed, 7 insertions, 2 deletions
diff --git a/FastLED.cpp b/FastLED.cpp index af92429e..c31f9296 100644 --- a/FastLED.cpp +++ b/FastLED.cpp @@ -114,14 +114,18 @@ void CFastLED::clearData() { void CFastLED::delay(unsigned long ms) { unsigned long start = millis(); - while((millis()-start) < ms) { + do { #ifndef FASTLED_ACCURATE_CLOCK // make sure to allow at least one ms to pass to ensure the clock moves // forward ::delay(1); #endif show(); +#if defined(ARDUINO) && (ARDUINO > 150) + yield(); +#endif } + while((millis()-start) < ms) { } void CFastLED::setTemperature(const struct CRGB & temp) { @@ -442,7 +442,8 @@ public: void showColor(const struct CRGB & color) { showColor(color, m_Scale); } /// Delay for the given number of milliseconds. Provided to allow the library to be used on platforms - /// that don't have a delay function (to allow code to be more portable) + /// that don't have a delay function (to allow code to be more portable). Note: this will call show + /// constantly to drive the dithering engine (and will call show at least once). /// @param ms the number of milliseconds to pause for void delay(unsigned long ms); |