fix: minor model/encoding validation (§4)#109
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Add SensorType.BQ27220 = 5 (was missing; degraded to raw int). - AdvertisementData.touch_event now rejects negative or >6 start_byte (negative indexing previously returned garbage; firmware range is 0-6). - encode_image(GRAYSCALE_4) now raises instead of returning packed 2bpp that no firmware path accepts (4-gray needs two 1-bit planes; prepare_image already routes it through encode_gray4_bitplanes()). - Fix buzzer docstrings to cite command 0x0077 (0x0075 is LED STOP). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JRrm95f1qNZzDM9r2SB6KW
6a3323d to
8184ae5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A batch of small, self-contained §4-minor correctness fixes.
SensorType.BQ27220 = 5— was missing, so the value degraded to a raw int.AdvertisementData.touch_eventnow rejects a negative or>6start_byte. A negative offset previously indexed from the end of the block and returned garbage; the firmware-valid range is 0–6.encode_image(GRAYSCALE_4)now raises instead of returning packed 2bpp that no firmware path accepts — 4-gray needs two 1-bit controller planes (prepare_imagealready routes it throughencode_gray4_bitplanes()). Mirrors the existing BWR/BWY guard.0x0077(the actual buzzer code;0x0075is LED STOP). Wire bytes were already correct.Test plan
uv run pytest -q→ 446 passed (3 new:BQ27220 == 5,encode_image(GRAYSCALE_4)raises,touch_eventrejects out-of-range offsets)ruff,mypyclean🤖 Generated with Claude Code