Skip to content

Fix board rotation from CLI/ini not wrapping to -180..180 - #582

Merged
qu1ck merged 1 commit into
openscopeproject:masterfrom
DominikPalo:fix-board-rotation-wrap
Oct 6, 2026
Merged

qu1ck merged 1 commit into
openscopeproject:masterfrom
DominikPalo:fix-board-rotation-wrap

Conversation

@DominikPalo

Copy link
Copy Markdown
Contributor

Config.set_from_args converted --board-rotation (and board_rotation from --use-ini, which goes through the same argparse default) with:

self.board_rotation = math.fmod(args.board_rotation // 5, 37)

fmod(x, 37) is not a 360° wrap. Board rotation is stored in 5° steps with a valid range of -36..36, so 360° corresponds to 72 steps, not 37. Any value outside -180..180 ended up at an unrelated angle: --board-rotation 270 gave 85°, 360 gave 175° and 185 gave 0°. The result was also a float ("board_rotation": 17.0 in the generated page).

This change keeps the existing behavior for every value within -180..180 (including the floor to a multiple of 5) and wraps values outside that range to the equivalent angle in 5° steps. The result is now an int. The now-unused local import math is removed.

Testing

Config.add_options + set_from_args on master vs this branch:

--board-rotation master this PR
0, 5, 90, -90, 175, 180, -180 same angle (as float) same angle (as int)
7 / -7 5° / -10° 5° / -10° (unchanged)
185 0° -175°
270 85° -90°
-270 -85° 90°
360 / 720 175° / 165° 0° / 0°
450 / -450 80° / -80° 90° / -90°

End to end, generating a BOM with --board-rotation 270, and with board_rotation=54 in ibom.config.ini plus --use-ini, now produces "board_rotation": -18 (-90°) in the page config instead of 17.0 (85°).

Note: the --board-rotation help text says the value is "rounded" to a multiple of 5, but the code floors it (e.g. -7 becomes -10°). I left that unchanged to keep this fix focused.

🤖 Generated with Claude Code

set_from_args converted --board-rotation with fmod(rot // 5, 37), which
is not a 360 degree wrap: 270 became 85 degrees, 360 became 175 and 185
became 0. The result was also a float. Values within -180..180 keep
their previous behavior; values outside are wrapped to the equivalent
angle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qu1ck
qu1ck merged commit ba80454 into openscopeproject:master Oct 6, 2026
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