Skip to content

Commit

Permalink
small update
Browse files Browse the repository at this point in the history
based on feedback from the PR to upstream
* support "0 FPS" meaning "unlimited"
* keep FRAMETIME_FIXED fixed
  • Loading branch information
softhack007 committed Nov 4, 2024
1 parent 6bae356 commit dc4964a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
15 changes: 8 additions & 7 deletions wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@ bool strip_uses_global_leds(void) __attribute__((pure)); // WLEDMM implemented
#endif

/* Not used in all effects yet */
#define FPS_UNLIMITED 249
#define FPS_UNLIMITED 250
#define FPS_UNLIMITED_AC 0 // WLEDMM upstream uses "0 fps" for unlimited. We support both ways
#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_FASTPATH) // WLEDMM go faster on ESP32
#define WLED_FPS 120
#define FRAMETIME_FIXED (strip.getFrameTime() < 10 ? 12 : 24)
#define WLED_FPS_SLOW 60
#define FRAMETIME_FIXED_SLOW (15) // = 66 FPS => 1000/66
#define FRAMETIME strip.getFrameTime()
#define MIN_SHOW_DELAY (max(2, (_frametime*5)/8)) // WLEDMM support higher framerates (up to 250fps) -- 5/8 = 62%
#define WLED_FPS 120
#define WLED_FPS_SLOW 60
#define FRAMETIME_FIXED 24 // used in Blurz, Freqmap, Scrolling text
//#define FRAMETIME_FIXED (strip.getFrameTime() < 10 ? 12 : 24)
#define FRAMETIME_FIXED_SLOW (15) // = 66 FPS => 1000/66 // used in Solid, Colortwinkles, Candle
#else
#define WLED_FPS 42
#define FRAMETIME_FIXED (1000/WLED_FPS)
#define WLED_FPS_SLOW 42
#define WLED_FPS_SLOW 42
#define FRAMETIME_FIXED_SLOW (1000/WLED_FPS_SLOW)
//#define FRAMETIME _frametime
#define FRAMETIME strip.getFrameTime()
//#define MIN_SHOW_DELAY (_frametime < 16 ? 8 : 15) // Upstream legacy
#define MIN_SHOW_DELAY (_frametime < 16 ? (_frametime <8? (_frametime <7? (_frametime <6 ? 2 :3) :4) : 8) : 15) // WLEDMM support higher framerates (up to 250fps)
Expand Down
14 changes: 7 additions & 7 deletions wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1877,15 +1877,15 @@ void WS2812FX::service() {
#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_FASTPATH) // WLEDMM go faster on ESP32
//if (_suspend) return;
if (elapsed < 2) return; // keep wifi alive
if ( !_triggered && (_targetFps < FPS_UNLIMITED) && (_targetFps > 0)) {
if ( !_triggered && (_targetFps != FPS_UNLIMITED) && (_targetFps != FPS_UNLIMITED_AC)) {
if (elapsed < MIN_SHOW_DELAY) return; // WLEDMM too early for service
}
#else // legacy
if (elapsed < MIN_SHOW_DELAY) return;
if (nowUp - _lastShow < MIN_SHOW_DELAY) return;
#endif

bool doShow = false;
unsigned speedLimit = (_targetFps < FPS_UNLIMITED) ? (0.85f * FRAMETIME) : 1; // WLEDMM lower limit for effect frametime
unsigned speedLimit = (_targetFps != FPS_UNLIMITED) && (_targetFps != FPS_UNLIMITED_AC) ? (0.85f * FRAMETIME) : 1; // WLEDMM minimum for effect frametime

_isServicing = true;
_segment_index = 0;
Expand Down Expand Up @@ -2120,10 +2120,10 @@ uint16_t WS2812FX::getFps() const {
}

void WS2812FX::setTargetFps(uint8_t fps) {
if (fps > 0 && fps <= 251) _targetFps = fps; // WLEDMM allow higher framerates
_frametime = 1000 / _targetFps;
if (_frametime < 1) _frametime = 1; // WLEDMM better safe than sorry
if (fps >= FPS_UNLIMITED) _frametime = 3; // WLEDMM unlimited mode
if (fps <= 251) _targetFps = fps; // WLEDMM allow higher framerates
if (fps > 0) _frametime = 1000 / _targetFps;
else _frametime = 2; // AC WLED compatibility
if (fps >= FPS_UNLIMITED) _frametime = 2; // WLEDMM unlimited mode
}

void WS2812FX::setMode(uint8_t segid, uint8_t m) {
Expand Down
6 changes: 4 additions & 2 deletions wled00/data/settings_leds.htm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@

gId('ampwarning').style.display = (d.Sf.MA.value > 7200) ? 'inline':'none';

gId('fpswarning').style.display = (d.Sf.FR.value > 69) ? 'block':'none'; // WLEDMM
gId('fpsNone').style.display = ((d.Sf.FR.value == 0) || (d.Sf.FR.value > 249))? 'block':'none'; // WLEDMM
gId('fpswarning').style.display = (d.Sf.FR.value > 69) || (d.Sf.FR.value == 0) ? 'block':'none'; // WLEDMM
gId('fpshelp1').style.display = ((d.Sf.FR.value > 80) && (d.Sf.FR.value < 132)) ? 'block':'none'; // WLEDMM
gId('fpshelp2').style.display = ((d.Sf.FR.value > 132) && (d.Sf.FR.value < 196)) ? 'block':'none'; // WLEDMM
gId('fpshelp3').style.display = (d.Sf.FR.value > 196) ? 'block':'none'; // WLEDMM
Expand Down Expand Up @@ -732,7 +733,8 @@ <h3>Advanced</h3>
<option value="2">Linear (never wrap)</option>
<option value="3">None (not recommended)</option>
</select><br>
Target refresh rate: <input type="number" class="s" min="1" max="250" name="FR" oninput="UI()" required> FPS
Target refresh rate: <input type="number" class="s" min="0" max="250" name="FR" oninput="UI()" required> FPS
<div id="fpsNone" style="color:green; display: none;"><b>unlimited FPS mode.</b><br></div>
<div id="fpswarning" style="color:GoldenRod; display: none;">
&#9888; WLED may become unstable above 70 fps.<br>
To protect your setup,
Expand Down

0 comments on commit dc4964a

Please sign in to comment.