Store bathroom night brightness as a whole percentage #72

Merged
rob merged 1 commit from bathroom-night-brightness into main 2026-09-25 06:07:37 +00:00
Collaborator

Follow-up to #71 (merged before this landed). The bathroom night brightness setting is now a whole percentage (1-100, default 30) rather than a raw 0.1 % level, which is a friendlier unit for a setting a person dials in directly.

SemanticClass::Level (0x2C) is renamed to Percentage (1 %, 0-100) with a matching row added to spec section 6; BathroomPolicy is untouched and still takes a 0.1 % level, so the conversion (value() * 10) happens at the one point the setting meets the dimmer, in onFrame.

Tested with pio test -e native (448 cases, all passing, including the shared test vectors) and pio run -e node_lighting.

Follow-up to #71 (merged before this landed). The bathroom night brightness setting is now a whole percentage (1-100, default 30) rather than a raw 0.1 % level, which is a friendlier unit for a setting a person dials in directly. `SemanticClass::Level` (0x2C) is renamed to `Percentage` (1 %, 0-100) with a matching row added to spec section 6; `BathroomPolicy` is untouched and still takes a 0.1 % level, so the conversion (`value() * 10`) happens at the one point the setting meets the dimmer, in `onFrame`. Tested with `pio test -e native` (448 cases, all passing, including the shared test vectors) and `pio run -e node_lighting`.
Store bathroom night brightness as a whole percentage
All checks were successful
Build and test / build (pull_request) Successful in 1m13s
Build and test / release (pull_request) Has been skipped
e5a1ac2d8a
Claude left a comment

Checked out and verified against origin/main (the local worktree's main was stale, but the real diff matches the PR description exactly — a single commit, four files).

  • value() * 10: SettingEndpoint::value() is uint16_t clamped to [1,100], the multiply promotes to int with no overflow, and the max result (1000) is exactly can::units::levelMax. Plain integer arithmetic, no float, no levelFromPercent — correct, and the right call since the task never needed the float rounding that helper is for.
  • Spec edits: minimal, both rows fit the existing table patterns (section 5.2 band list, section 6 quantity row alongside Duration/Colour temperature). No stray prose.
  • Rename is complete: no leftover SemanticClass::Level, bathroomNightLevel, epBathroomNightLevel, "bathNightLevel", or the old test name anywhere in the tree.
  • test_bathroom_policy.cpp correctly left untouched — confirmed BathroomPolicy::onOccupancy takes a raw 0.1% nightLevel and never touches SemanticClass or the setting; its literals (1000, 300 etc.) are unaffected by the percent/level rename.
  • No regression from #71's review rounds: the "1, not 0" comment survives (reworded for percent), formatting is clean in the changed hunks (one pre-existing clang-format violation elsewhere in main.cpp, on a line this PR doesn't touch).
  • pio test -e native (448/448) and CI (Build and test / build on e5a1ac2) both green.

Nothing to change — approving would be the right call here but self-approval is blocked by Forgejo.

Checked out and verified against `origin/main` (the local worktree's `main` was stale, but the real diff matches the PR description exactly — a single commit, four files). - `value() * 10`: `SettingEndpoint::value()` is `uint16_t` clamped to [1,100], the multiply promotes to `int` with no overflow, and the max result (1000) is exactly `can::units::levelMax`. Plain integer arithmetic, no float, no `levelFromPercent` — correct, and the right call since the task never needed the float rounding that helper is for. - Spec edits: minimal, both rows fit the existing table patterns (section 5.2 band list, section 6 quantity row alongside Duration/Colour temperature). No stray prose. - Rename is complete: no leftover `SemanticClass::Level`, `bathroomNightLevel`, `epBathroomNightLevel`, `"bathNightLevel"`, or the old test name anywhere in the tree. - `test_bathroom_policy.cpp` correctly left untouched — confirmed `BathroomPolicy::onOccupancy` takes a raw 0.1% `nightLevel` and never touches `SemanticClass` or the setting; its literals (1000, 300 etc.) are unaffected by the percent/level rename. - No regression from #71's review rounds: the "1, not 0" comment survives (reworded for percent), formatting is clean in the changed hunks (one pre-existing clang-format violation elsewhere in `main.cpp`, on a line this PR doesn't touch). - `pio test -e native` (448/448) and CI (`Build and test / build` on `e5a1ac2`) both green. Nothing to change — approving would be the right call here but self-approval is blocked by Forgejo.
rob merged commit d47248450f into main 2026-09-25 06:07:37 +00:00
rob deleted branch bathroom-night-brightness 2026-09-25 06:07:38 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rob/CampervanControlSystems!72
No description provided.