Skip to content

Add optional gravity-based screen rotation for the CoreS3 (BMI270)#97

Open
grimwiz wants to merge 3 commits into
m5stack:mainfrom
grimwiz:cores3-imu-rotation
Open

Add optional gravity-based screen rotation for the CoreS3 (BMI270)#97
grimwiz wants to merge 3 commits into
m5stack:mainfrom
grimwiz:cores3-imu-rotation

Conversation

@grimwiz

@grimwiz grimwiz commented Jul 2, 2026

Copy link
Copy Markdown

Adds common/cores3-imu-rotation.yaml — an optional add-on package for cores3-satellite-base.yaml that keeps the satellite's screen right-side-up: the on-board BMI270 is read via ESPHome's native motion: hub and the display flips between the two landscape orientations (0/180) from the sign of the in-plane gravity component.

Usage:

packages:
  m5stack-cores3: !include ../../common/cores3-satellite-base.yaml
  imu-rotation:   !include ../../common/cores3-imu-rotation.yaml

Design notes:

  • No changes to the base — purely additive include; no external components (native motion:/bmi270, min ESPHome 2026.1 already required by the base).
  • CoreS3's BMI270 answers at 0x69 (not the 0x68 default), on bsp_bus.
  • Native trigger semantics, minimal code: on_value_range on 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 irreducible set_rotation + touch-mirror calls.
  • mipi_spi recomputes MADCTL in set_rotation() at runtime, so the flip only needs the component.update redraw.
  • Touch stays aligned with the screen: the touchscreen core doesn't track display rotation at runtime, so each flip 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.

Testing: rotation logic is hardware-proven on a CoreS3-Lite (in daily use); this packaging compiles clean against cores3-satellite-base.yaml with 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

grimwiz added 3 commits July 2, 2026 06:34
…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).
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.

1 participant