Skip to content

fix(panel): Galahad II LCD brightness fix - #3

Merged
geretti merged 1 commit into
hello-nexus:mainfrom
caumeira:fix/galahad2-lcd-brightness-only
Sep 16, 2026
Merged

geretti merged 1 commit into
hello-nexus:mainfrom
caumeira:fix/galahad2-lcd-brightness-only

Conversation

@caumeira

@caumeira caumeira commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Split out from #1 per review feedback there - just the brightness fix, so it can merge on its own while the pump RGB work (now #5) takes its time.

Summary

  • Fixes brightness: LcdSetting (0x04) is the reference driver's family-wide brightness-only mode (not Galahad-specific - HydroShift takes it too), applied unconditionally instead of gated behind a per-model constructor parameter.
  • Brightness changes apply immediately instead of waiting for the next frame tick.

Test plan

  • dotnet build succeeds
  • Verified on real Galahad II LCD hardware: brightness slider applies instantly, glass renders pushed frames correctly

I've read and agree to the CLA (CONTRIBUTING.md / CLA.md).

@caumeira
caumeira force-pushed the fix/galahad2-lcd-brightness-only branch from 2aef443 to 63b84ce Compare September 16, 2026 00:59
@caumeira

Copy link
Copy Markdown
Contributor Author

Squashed down to the minimal diff - dropped every comment/formatting-only change, kept only what's strictly required: LcdSettingMode (0x04) for brightness, and the immediate-apply wiring (IBrightnessPanelTransport.ApplyBrightness() → StreamedPanelCoordinator → the panel PATCH route). Production diff is now 55 insertions / 9 deletions across 5 files.

Also closed #1 per your note - I'll resubmit the pump RGB as a fresh, independent PR off main once this one's settled, rather than trying to rebase the old branch.

@geretti geretti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at head 63b84ce3. The production side is right and I have no changes to ask for there; the test half and the description still carry pieces of #1. Items 1-3 are required, 4-5 optional. Line numbers are against 63b84ce3.

What I checked

  • Protocol: sgtaziz/lian-li-linux hydroshift_lcd/controller.rs set_brightness (line 972) sends LcdControlMode::LcdSetting = 4, and set_rotation does the same, for the whole family. The "settings mode hands the glass back" comment on main was never hardware-checked (commit 9b8bafef says so in its message), so 0x04 for both Galahad II and HydroShift is the correct reading.
  • Cross-thread HID access: ApplyBrightness() now runs from the HTTP thread. JpegPanelHub.SetBrightness and SendFrame both take _lock, so the control write and its ack drain are serialized against the frame path. Fine.
  • Branch is 6 commits behind origin/main, merges clean. The JpegPanel*, LianLiAio* and StreamedPanelCoordinator* suites (87 tests) pass on the head; I did not run the full suite or an AOT publish.

1. (required) Remove the #1 leftovers from the tests

The comment on this PR says the comment/formatting-only changes were dropped; 63b84ce3 still has them.

tests/Nexus.Service.Tests/JpegPanels/LianLiAioHandshakeTests.cs

  • Lines 59, 73, 115, 128: new LianLiAioHandshake(\n "…", 24) wrapped over two lines. On main these are one line, and the wrap is what the removed #1 constructor parameter needed. Put them back on one line.
  • Line 57 Galahad_attach_keeps_the_glass_in_application_mode: asserts OnAttach behaviour main already has and this PR does not change. Delete.
  • Line 71 Galahad_brightness_packet_uses_the_hardware_verified_settings_mode: keep. It is the one new test that pins the fix byte-for-byte.

tests/Nexus.Service.Tests/JpegPanels/JpegPanelHubTests.cs

  • Line 76: the existing frame test was switched from GalahadIiLcd to HydroShiftLcd with nothing in this PR motivating it. Restore GalahadIiLcd.
  • Line 99 Galahad_frames_use_the_1024_byte_b_jpeg_reports, line 121 Galahad_discovery_asks_the_overlay_for_raw_bgra_and_encodes_jpeg, line 186 Galahad_uses_the_b_jpeg_frame_channel_and_control_stays_on_b: all three assert model-table and frame-path behaviour that is unchanged on main. Delete them. (If any of them exists to guard something #1 will change, it belongs in that PR.)
  • Line 195 Dimmable(): reflowed from one expression to a multi-line with { ... } block for no change in content. Restore the main form.

After this the test diff should be: the 0x04 assertion change at JpegPanelHubTests.cs:214, the renamed/reworded HydroShift test in LianLiAioHandshakeTests.cs (A_brightness_change_uses_the_family_wide_settings_mode), the new Galahad packet test, and the coordinator test.

2. (required) Fix the PR description

First Summary bullet, "Puts the Galahad II LCD glass into application mode so pushed frames actually render", describes no change in this diff: LianLiAioHandshake.OnAttach already sends ModeApplication on main. Drop the bullet. The other two bullets are accurate.

Per CONTRIBUTING.md, the validation section is your statement of what ran on your machine, so please also confirm it still matches after the test cleanup (test-only changes do not need a hardware re-run).

3. (required) Rename a now-wrong test name

JpegPanelHubTests.cs:203 SetBrightness_reaches_an_attached_panel_in_application_mode now asserts LcdSettingMode, so "in_application_mode" is false. Something like SetBrightness_reaches_an_attached_panel_in_lcd_setting_mode.

4. (optional) Make ApplyBrightness void

IStreamedPanelTransport.cs:48, JpegPanelStreamTransport.cs:68, StreamedPanelCoordinator.cs:198. The only production caller, PanelRoutes.cs:339, discards the result, and the bool has mixed meaning inside TryApplyBrightnessLocked (true for "record has no value / unchanged" at lines 111 and 117, false for "TTL not expired" at line 94 and for a rejected write at line 119). A void keeps the interface honest about what callers use. If you take this, the coordinator test asserts on the fake's ApplyCalls / LastApplied already, so nothing else moves.

5. (optional) Inline TryApplyBrightness

JpegPanelStreamTransport.cs:77 is a one-line lock wrapper with a single caller at line 159. lock (_brightnessLock) { TryApplyBrightnessLocked(); } inside PushFrame reads the same and saves a method.

@caumeira
caumeira force-pushed the fix/galahad2-lcd-brightness-only branch from 63b84ce to 11a1e8d Compare September 16, 2026 02:10
@caumeira

Copy link
Copy Markdown
Contributor Author

All fixed at 11a1e8d (squashed to one commit, same as before).

1. #1 leftovers in tests - removed. LianLiAioHandshakeTests.cs: the two-line constructor wraps are back on one line, Galahad_attach_keeps_the_glass_in_application_mode is deleted (unchanged main behaviour), Galahad_brightness_packet_uses_the_hardware_verified_settings_mode kept. JpegPanelHubTests.cs: the frame test is back to GalahadIiLcd, the three model-table/frame-path tests are deleted, Dimmable() is back to the one-expression form. Test diff is now just what you listed: the 0x04 assertion, the renamed HydroShift test, the new Galahad packet test, and the coordinator test.

2. PR description - dropped the inaccurate bullet, updated the #1 reference to point at #5 (the pump RGB resubmit). Test-only cleanup, so the validation section still matches what ran on hardware.

3. Test rename - SetBrightness_reaches_an_attached_panel_in_lcd_setting_mode.

4/5 (optional, took both) - ApplyBrightness is void end to end (interface, JpegPanelStreamTransport, StreamedPanelCoordinator, and the coordinator test's fake). TryApplyBrightness is inlined into PushFrame as lock (_brightnessLock) { TryApplyBrightnessLocked(); }.

@geretti

geretti commented Sep 16, 2026

Copy link
Copy Markdown
Member

Checked 11a1e8d7. Items 1-5 are all done as described - the test diff is exactly the four pieces, the description bullet is gone, ApplyBrightness is void end to end, TryApplyBrightness is inlined. The JpegPanel* / LianLiAio* / StreamedPanelCoordinator* suites pass (83) and the branch merges clean on main.

One thing to fix before this can go in: the branch is no longer one commit on main. 63b84ce3 sat directly on origin/main (3674a3ca); 11a1e8d7 now sits on 36c7a540 on 0b02a571, which are the old #1 commits. So the diff against main went from 5 production files to 8 and picked up changes that are not the brightness fix:

File What came back in
src/Peripherals/JpegPanels/JpegPanelHub.cs _report comment reworded; the FillChunk call split from 2 lines to 6
src/Peripherals/JpegPanels/JpegPanelModel.cs class doc reflowed; the GalahadIiLcd initializer reflowed from 1 line to 4
src/Peripherals/JpegPanels/JpegPanelProtocol.cs LianLiSequenced doc reworded
src/Peripherals/JpegPanels/LianLiAioHandshake.cs class doc reworded (and drops the report-C sentence)
src/Panel/Streams/JpegPanelStreamTransport.cs class doc reworded; wanted is not int percent || percent == _brightnessApplied split into two if blocks
src/Panel/Streams/IStreamedPanelTransport.cs the "ignores" -> "ignore" typo fix - this one is fine to keep

Please make it one commit whose parent is origin/main, e.g. git rebase --onto origin/main 36c7a540 fix/galahad2-lcd-brightness-only, then re-check git diff --stat origin/main...HEAD shows only IStreamedPanelTransport.cs, JpegPanelStreamTransport.cs, StreamedPanelCoordinator.cs, LianLiAioHandshake.cs, PanelRoutes.cs and the three test files. Keep the typo fix if you like; drop the rest. The code as it stands in those five files at 11a1e8d7 is the right end state, so nothing else needs to change and no hardware re-run is needed for a rebase that leaves the fix bytes identical.

@caumeira
caumeira force-pushed the fix/galahad2-lcd-brightness-only branch from 11a1e8d to 7d93b68 Compare September 16, 2026 03:32
@caumeira

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main as a single commit (git rebase --onto origin/main 36c7a540 fix/galahad2-lcd-brightness-only), dropping the two stale ancestor commits from the old #1. git diff --stat origin/main...HEAD now shows exactly the expected set:

  • src/Panel/Streams/IStreamedPanelTransport.cs
  • src/Panel/Streams/JpegPanelStreamTransport.cs
  • src/Panel/Streams/StreamedPanelCoordinator.cs
  • src/Peripherals/JpegPanels/LianLiAioHandshake.cs
  • src/Routes/PanelRoutes.cs
  • the three test files

PanelRoutes.cs needed re-adding by hand during the rebase (the streams.ApplyBrightness(updated.Id) wiring on LcdBrightness.HasValue had been dropped along the way) — it's back in and building clean; behavior at that file matches what the earlier round already established. No hardware re-run needed, the fix bytes are unchanged.

Force-pushed to this branch.

@geretti

geretti commented Sep 16, 2026

Copy link
Copy Markdown
Member

7d93b682 is the right single commit and CI is green (build with warnings-as-errors + full suite). One last cleanup, then this merges. Three edits from the old #1 branch are still in the diff because they sit in files the fix also touches; restore each to its main form:

  1. src/Panel/Streams/JpegPanelStreamTransport.cs class <summary> - the rewrite drops the reason the transport buffers ("the paced writer may split or concatenate writes"). Restore the original two paragraphs verbatim.
  2. src/Peripherals/JpegPanels/LianLiAioHandshake.cs class <summary> - the rewrite drops the report-C sentence (512-byte frames on newer firmware, use_c_command in the reference driver). Restore the original paragraph verbatim.
  3. src/Panel/Streams/JpegPanelStreamTransport.cs in TryApplyBrightnessLocked - the wanted is not int percent || percent == _brightnessApplied condition was split into two if blocks. Restore the single condition (both branches return true).

Everything else stays as is. Amend into the one commit and force-push; comment/formatting only, so no hardware re-run. I'll approve the CI run again when it lands.

…ately

- LianLiAioHandshake.ApplyBrightness now sends the reference driver's
  LcdSetting mode (0x04) instead of application mode (0x01), which is
  what the panel actually expects for a brightness-only control write.
- A brightness change now applies immediately (IBrightnessPanelTransport
  gets ApplyBrightness(), wired through StreamedPanelCoordinator and
  the panel-device PATCH route) instead of waiting for the frame-path's
  periodic recheck.

Tested on real Galahad II LCD hardware: brightness applies instantly,
panel renders pushed frames correctly with Nexus Control on.
@caumeira
caumeira force-pushed the fix/galahad2-lcd-brightness-only branch from 7d93b68 to ac34b9c Compare September 16, 2026 04:05
@caumeira

Copy link
Copy Markdown
Contributor Author

Restored the three leftover comment/structure diffs from the old #1 branch:

  • `JpegPanelStreamTransport.cs` class summary back to the original two paragraphs (paced-writer split/concatenate rationale).
  • `LianLiAioHandshake.cs` class summary back to the original, including the report-C sentence.
  • `TryApplyBrightnessLocked`'s two split `if` blocks collapsed back into the single `wanted is not int percent || percent == _brightnessApplied` condition.

Comment/formatting only, fix bytes unchanged. Force-pushed as `ac34b9c2`.

@geretti geretti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All rounds addressed at ac34b9c2: single commit on main, diff is the fix plus its tests only, CI green.

@geretti
geretti merged commit 19640f9 into hello-nexus:main Sep 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants