Add optional gravity-based screen rotation for the CoreS3 (BMI270)#97
Open
grimwiz wants to merge 3 commits into
Open
Add optional gravity-based screen rotation for the CoreS3 (BMI270)#97grimwiz wants to merge 3 commits into
grimwiz wants to merge 3 commits into
Conversation
…I270) Optional include alongside cores3-satellite-base.yaml: reads the on-board BMI270 (native ESPHome motion hub, 0x69 on bsp_bus) and flips the display between the two landscape orientations from the in-plane gravity sign, with a 0.30 g deadzone so a flat device keeps its current orientation. mipi_spi applies set_rotation at runtime, so the flip is just a redraw. Rotation logic hardware-proven on a CoreS3-Lite; this packaging compiles clean against cores3-satellite-base.yaml (esphome 2026.6.4). Supersedes the IMU-rotation part of m5stack/M5CoreS3-Esphome#39.
The touchscreen core doesn't track display rotation at runtime, so the flip lambda also mirrors both touch axes (mirror X + Y == 180°) via the public set_mirror_x/set_mirror_y setters — position-sensitive touch zones keep working in either orientation. Compiles clean (esphome 2026.6.4).
on_value_range on the acceleration_y sensor provides the transition detection and hysteresis natively — the gap between the +/-0.30 g bands is the deadzone, so a flat device keeps its orientation. The only remaining lambdas are the irreducible set_rotation + touch-mirror calls (no yaml action exists for runtime display rotation). Compiles clean (2026.6.4).
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.
Adds
common/cores3-imu-rotation.yaml— an optional add-on package forcores3-satellite-base.yamlthat keeps the satellite's screen right-side-up: the on-board BMI270 is read via ESPHome's nativemotion:hub and the display flips between the two landscape orientations (0/180) from the sign of the in-plane gravity component.Usage:
Design notes:
motion:/bmi270, min ESPHome 2026.1 already required by the base).bsp_bus.on_value_rangeon the acceleration-Y sensor provides transition detection and hysteresis — the gap between the ±0.30 g bands is the deadzone, so a device lying flat keeps its current orientation. No globals, no polling interval; the only lambdas are the irreducibleset_rotation+ touch-mirror calls.mipi_spirecomputes MADCTL inset_rotation()at runtime, so the flip only needs thecomponent.updateredraw.set_mirror_x/set_mirror_ysetters — position-sensitive touch zones keep working in either orientation.Testing: rotation logic is hardware-proven on a CoreS3-Lite (in daily use); this packaging compiles clean against
cores3-satellite-base.yamlwith esphome 2026.6.4.This resubmits the one part of m5stack/M5CoreS3-Esphome#39 not already covered here, per @lboue's pointer to this repo. (The old PRs are closed.)
🤖 Generated with Claude Code
https://claude.ai/code/session_01TaFALu42vGvofsvrUUyXH9