Skip to content

Smart tab5keyboard#533

Open
Shadowtrance wants to merge 13 commits into
TactilityProject:mainfrom
Shadowtrance:smart-tab5keyboard
Open

Smart tab5keyboard#533
Shadowtrance wants to merge 13 commits into
TactilityProject:mainfrom
Shadowtrance:smart-tab5keyboard

Conversation

@Shadowtrance

@Shadowtrance Shadowtrance commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Tab5 + Tab5 Keyboard are now "smart" 🧠

  • Detects if the keyboard is connected on boot - if yes, auto-rotates display to landscape (live only, doesn't touch your saved display settings).
  • Hot-pluggable (works, but a bit fiddly - polled ~once/sec, so there's up to a 1s delay either way). detects if attached after boot too.
  • On attach: if the display isn't already in landscape, it live-rotates to landscape (without touching your saved display settings).
  • On detach: if it auto-rotated to landscape on attach, it rotates back to whatever orientation you had before plugging in.
  • If you manually set landscape yourself (via Display Settings) while the keyboard is attached, unplugging won't rotate away from it - your manual choice always wins.
  • LEDs and keyboard registers also get re-synced on reattach (they reset to power-on defaults when unplugged).
  • Bonus: fixed a launcher bug where the home screen icon layout (row vs column) wouldn't update immediately after a rotation change while the launcher was visible - now it reflows live.

Misc changes:

  • Tab5 - switched sd card from SPI to SDMMC driver.
  • Tab5 - num_fbs = 1 > 2.
  • Fixed issue where usb mode logo would act strange and use the incorrect logo when the display wasn't in default orientation when rebooting to usb mode.
  • Added function to get direct framebuffers (MIPI DSI only) - currently only used in my doom port.
  • Added reboot to os from usb msc mode.
  • Minor tweaks to the sdmmc driver.
  • Bonus symbols

Summary by CodeRabbit

Release Notes

  • New Features

    • Upgraded SD support from SPI to SD/MMC with configurable host slot and max speed.
    • Keyboard hot-plug detection with automatic display rotation, including reliable post-boot activation.
    • USB boot splash now includes a “Return to OS” option.
  • Bug Fixes

    • More resilient USB mass-storage boot behavior, including improved eject/disconnect handling.
    • Improved rendering stability on Tab5 by using additional frame buffers on supported panels.
    • Smoother launcher layout adjustments during rotation/orientation changes.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 26f124cf-9820-4717-94a4-532c033e0c24

📥 Commits

Reviewing files that changed from the base of the PR and between 6ceeef1 and 4782e81.

📒 Files selected for processing (1)
  • Tactility/Source/hal/usb/UsbMock.cpp

📝 Walkthrough

Walkthrough

This PR delivers several hardware improvements for the M5Stack Tab5. The Tab5 keyboard gains hot-plug detection: new Tab5Keyboard methods (reinitDevice, checkAttachState, applyAutoRotation, lateStart) handle I2C re-initialization and LVGL display auto-rotation on connect/disconnect, with a module-level FreeRTOS timer driving post-boot detection. The SD card interface is migrated from SPI to SDMMC, removing the SPI factory and replacing the DTS node with an sdmmc0 controller; Esp32SdmmcConfig gains slot and max_freq_khz fields. A getFrameBuffers virtual method is added to DisplayDriver and implemented in EspLcdDisplayDriver; both Tab5 display panels are updated to num_fbs = 2; and the API is exposed through TactilityC with ELF symbol registration. USB MSC boot-mode handling gains startedFromBootMode tracking, eject-triggered esp_restart, and explicit tud_disconnect delay; BootApp snapshots isUsbBootMode() at creation time. The launcher adds orientation-change callbacks to recompute button flex direction and margins. TactilityC gains ESP32-P4 CMake dependencies and additional ELF-exported symbols.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Smart tab5keyboard' is vague and does not clearly convey the main changes, which include keyboard detection, automatic rotation, SD card driver migration, frame buffer adjustments, USB boot improvements, and launcher fixes. Consider using a more descriptive title that captures the primary scope, such as 'Add smart keyboard detection with auto-rotation for Tab5' or 'Implement Tab5 keyboard hot-plug detection and auto-rotate display'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Devices/m5stack-tab5/Source/module.cpp (1)

124-134: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Roll back hp_detect_timer when keyboard timer setup fails.

start() can return ERROR_RESOURCE after hp_detect_timer is already running. That leaves a partially started module state and can block correct re-init behavior on the next start() call.

Suggested fix
     kb_detect_timer = xTimerCreate("kb_detect", pdMS_TO_TICKS(KB_DETECT_POLL_MS), pdTRUE, nullptr, keyboardDetectCallback);
     if (!kb_detect_timer) {
         LOG_E(TAG, "Failed to create kb_detect timer");
+        xTimerStop(hp_detect_timer, pdMS_TO_TICKS(100));
+        xTimerDelete(hp_detect_timer, pdMS_TO_TICKS(100));
+        hp_detect_timer = nullptr;
         return ERROR_RESOURCE;
     }
     if (xTimerStart(kb_detect_timer, pdMS_TO_TICKS(100)) != pdPASS) {
         LOG_E(TAG, "Failed to start kb_detect timer");
         xTimerDelete(kb_detect_timer, pdMS_TO_TICKS(100));
         kb_detect_timer = nullptr;
+        xTimerStop(hp_detect_timer, pdMS_TO_TICKS(100));
+        xTimerDelete(hp_detect_timer, pdMS_TO_TICKS(100));
+        hp_detect_timer = nullptr;
         return ERROR_RESOURCE;
     }

Also applies to: 138-148


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b7ce668b-27ed-459f-84c9-14cd0d272d22

📥 Commits

Reviewing files that changed from the base of the PR and between 8dabda2 and 0b9ea44.

📒 Files selected for processing (22)
  • Devices/m5stack-tab5/Source/Configuration.cpp
  • Devices/m5stack-tab5/Source/devices/Ili9881cDisplay.cpp
  • Devices/m5stack-tab5/Source/devices/SdCard.cpp
  • Devices/m5stack-tab5/Source/devices/SdCard.h
  • Devices/m5stack-tab5/Source/devices/St7123Display.cpp
  • Devices/m5stack-tab5/Source/devices/Tab5Keyboard.cpp
  • Devices/m5stack-tab5/Source/devices/Tab5Keyboard.h
  • Devices/m5stack-tab5/Source/module.cpp
  • Devices/m5stack-tab5/m5stack,tab5.dts
  • Drivers/EspLcdCompat/Source/EspLcdDisplayDriver.h
  • Platforms/platform-esp32/bindings/espressif,esp32-sdmmc.yaml
  • Platforms/platform-esp32/include/tactility/drivers/esp32_sdmmc.h
  • Platforms/platform-esp32/source/drivers/esp32_sdmmc_fs.cpp
  • Tactility/Include/Tactility/hal/display/DisplayDriver.h
  • Tactility/Source/app/boot/Boot.cpp
  • Tactility/Source/app/launcher/Launcher.cpp
  • Tactility/Source/hal/usb/UsbTusb.cpp
  • TactilityC/CMakeLists.txt
  • TactilityC/Include/tt_hal_display.h
  • TactilityC/Source/symbols/gcc_soft_float_p4.cpp
  • TactilityC/Source/tt_hal_display.cpp
  • TactilityC/Source/tt_init.cpp
💤 Files with no reviewable changes (2)
  • Devices/m5stack-tab5/Source/devices/SdCard.h
  • Devices/m5stack-tab5/Source/devices/SdCard.cpp

Comment thread Devices/m5stack-tab5/Source/devices/Tab5Keyboard.cpp
Comment thread Devices/m5stack-tab5/Source/module.cpp Outdated
Comment thread Platforms/platform-esp32/bindings/espressif,esp32-sdmmc.yaml
Comment thread Tactility/Source/hal/usb/UsbTusb.cpp Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3ab40414-e598-4267-8318-6f55de2aab62

📥 Commits

Reviewing files that changed from the base of the PR and between 0b9ea44 and bb49ac7.

📒 Files selected for processing (9)
  • Devices/m5stack-tab5/Source/devices/Tab5Keyboard.cpp
  • Devices/m5stack-tab5/Source/devices/Tab5Keyboard.h
  • Devices/m5stack-tab5/Source/module.cpp
  • Platforms/platform-esp32/bindings/espressif,esp32-sdmmc.yaml
  • Tactility/Include/Tactility/hal/usb/Usb.h
  • Tactility/Private/Tactility/hal/usb/UsbTusb.h
  • Tactility/Source/app/boot/Boot.cpp
  • Tactility/Source/hal/usb/Usb.cpp
  • Tactility/Source/hal/usb/UsbTusb.cpp
🚧 Files skipped from review as they are similar to previous changes (5)
  • Platforms/platform-esp32/bindings/espressif,esp32-sdmmc.yaml
  • Devices/m5stack-tab5/Source/devices/Tab5Keyboard.h
  • Tactility/Source/app/boot/Boot.cpp
  • Devices/m5stack-tab5/Source/devices/Tab5Keyboard.cpp
  • Devices/m5stack-tab5/Source/module.cpp

Comment thread Tactility/Source/hal/usb/UsbTusb.cpp
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