Conversation
applyLedFixedLayers() biases every hue by hOffset before taking the modulo, so the negative adjustments used by the battery, RSSI and throttle layers cannot push the hue below zero. That bias has to be a full turn, but it was HSV_HUE_MAX (359) instead of 360, so every LED handled by this layer came out one degree low. Colour 2 (red, hue 0) therefore reached the strip as hue 359, which hsvToRgb24() turns into R=255 G=0 B=4 instead of R=255 G=0 B=0 - the pink tint that was reported. The GPS layer writes its colour straight to the LED buffer without the offset, which is why the same red looks correct in GPS mode. With the full turn restored the battery and RSSI ramps again hit the colours listed in docs/LedStrip.md. Fixes iNavFlight#9633
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can switch off images and animations for a plain-text comment |
PR Summary by QodoCorrect fixed LED layer's one-degree hue shift
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
|
Note: #11820 (LED rainbow overlay) touches the same hue path in |
|
@sensei-hacker Checked #11820 against this one. They do not collide, and the rainbow overlay does not carry the same off-by-one. No overlap in the diff. This PR changes one line inside The rainbow's hue construction is already correct. ledColor.h = (rainbowHue + (rainbowIndex * rainbowDelta)) % 360;That is the same 360, so its hue never picks up the one-degree shift this PR fixes. Neither masks nor re-introduces the other, and the merge order does not matter. One cosmetic thing for #11820, not a defect: it hardcodes I also looked at its From reading only; no LED hardware here. |
Problem
#9633: on a SpeedyBee F405WING running INAV 7.0.0 with a WS2812 bar, an LED set to COLOR mode with colour 2 (documented as red) lights up pink. The same LED switched to GPS mode without a fix shows a proper red, so the reporter asked for colour 2 to be changed to match the GPS red.
Cause
src/main/io/ledstrip.c:444onmaintenance-10.x:applyLedFixedLayers()starts withhOffset = HSV_HUE_MAX(359,src/main/common/color.h:40) and applies it at line 498 ascolor.h = (color.h + hOffset) % (HSV_HUE_MAX + 1). The offset is meant as a neutral full turn so the negative adjustments of the battery and RSSI branches (down to -30) cannot push the hue below zero, but a full turn is 360, not 359. Every hue through this layer comes out one degree low: red (hue 0) becomes hue 359, whichhsvToRgb24()(src/main/common/colorconversion.c:74, case 5) renders as R255 G0 B4 instead of R255 G0 B0. The GPS layer (ledstrip.c:637) writes its colour throughapplyLedHsv()with no offset, which is why the same palette entry is correct there.Change
One line:
hOffsetstarts atHSV_HUE_MAX + 1(360), with a comment stating why. The palette table, the conversion function and the function-channel branch (which assignshOffsetinstead of adding to it) are untouched. No stored setting or default changes.Test
Not run on hardware or SITL. Cause verified by reading
ledstrip.c:444and:498andcolorconversion.c:74; the RGB values follow directly from theswitch (hue / 60)cases: hue 359 vs 0 gives 255,0,4 vs 255,0,0 (red), hue 119 vs 120 gives 4,255,0 vs 0,255,0 (green). With the fix, the battery and RSSI ramps give hue 0 (red) at 20 % and hue 330 (deep pink) at 0 %, as listed indocs/LedStrip.md. No fork CI run exists for this branch yet.Flash / RAM
Not measured yet. The upstream firmware CI has not been released for this PR, so no size report exists.
Docs
No documentation change needed:
docs/LedStrip.mdalready lists colour 2 as red and the battery/RSSI ramps as red at 20 % and deep pink at 0 %; the fix makes the firmware match that text.