Description
A pre-existing off-by-one bug affects random effect selection throughout the codebase. When selecting a random effect ID, the code calls random8(strip.getModeCount() - 1) or random16(strip.getModeCount() - 1), which prevents the last valid effect ID from ever being randomly selected.
Root Cause
FastLED's random8(N) and random16(N) functions return values in the range [0, N) (exclusive upper bound). To randomly select from effect IDs 0 through count-1, the code should call random*(count), not random*(count - 1).
Affected Locations
wled00/ir.cpp line 724 (currently random16(strip.getModeCount() - 1))
- Any other locations using similar patterns with
random8(strip.getModeCount() - 1)
Context
This issue was identified during review of PR #270 (16-bit effect IDs migration). The bug exists in the baseline mdev code and is not introduced by PR #270. The PR preserves the existing behavior while widening effect IDs from 8-bit to 16-bit.
Backlinks