Skip to content

Conversation

@lihuanhuan
Copy link
Contributor

@lihuanhuan lihuanhuan commented Jul 23, 2025

Summary by CodeRabbit

  • New Features

    • Added gesture detection for touch input, including support for clicks, swipes (up, down, left, right), and smooth vertical scrolling.
    • Enhanced bootloader UI with scrolling and partial redraw support for update information.
    • Introduced configurable LCD windowing to limit drawing regions.
    • Improved icon rendering and switched to compressed icon resources for better efficiency.
  • Improvements

    • Modularized touch input zone detection for more reliable and maintainable input handling.
    • Optimized UI progress bar updates to reduce unnecessary redraws during firmware updates.
    • Improved handling and display of multiple secure element (SE) firmware items with clearer labeling.
    • Unified user confirmation dialogs for firmware installation with gesture support.
  • Bug Fixes

    • Corrected minor issues in touch event handling and UI drawing alignment.

@lihuanhuan lihuanhuan requested a review from a team as a code owner July 23, 2025 08:12
@coderabbitai
Copy link

coderabbitai bot commented Jul 23, 2025

Walkthrough

This update adds gesture detection for touch input, modularizes input zone matching, refactors the update info UI for scrolling, optimizes SE firmware handling, and introduces LCD window clipping. Several new functions and struct fields are added, and some image resources are replaced with compressed versions.

Changes

Files/Paths Change Summary
core/embed/bootloader/bootui.c, bootui.h Modularized input zone matching; refactored update info UI; added scrolling support; updated icon rendering.
core/embed/bootloader/icon_onekey.h Replaced raw image array with compressed icon data.
core/embed/emmc_wrapper/emmc_commands.c Refined SE firmware handling; unified confirmation dialog; optimized progress bar updates.
core/embed/extmod/modtrezorui/mipi_lcd.c, mipi_lcd.h Added LCD window clipping; new lcd_set_window function and declaration.
core/embed/trezorhal/image.h Added se_address field to update_info_t struct.
core/embed/trezorhal/touch.c, touch.h Added gesture detection logic, enums, structs, constants, and function for gestures.

Estimated code review effort

4 (~90 minutes)

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.38.6)
core/embed/bootloader/icon_onekey.h

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 453565d and 1ce4bf7.

📒 Files selected for processing (9)
  • core/embed/bootloader/bootui.c (4 hunks)
  • core/embed/bootloader/bootui.h (2 hunks)
  • core/embed/bootloader/icon_onekey.h (1 hunks)
  • core/embed/emmc_wrapper/emmc_commands.c (8 hunks)
  • core/embed/extmod/modtrezorui/mipi_lcd.c (5 hunks)
  • core/embed/extmod/modtrezorui/mipi_lcd.h (1 hunks)
  • core/embed/trezorhal/image.h (1 hunks)
  • core/embed/trezorhal/touch.c (1 hunks)
  • core/embed/trezorhal/touch.h (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • core/embed/extmod/modtrezorui/mipi_lcd.h
🚧 Files skipped from review as they are similar to previous changes (8)
  • core/embed/trezorhal/image.h
  • core/embed/emmc_wrapper/emmc_commands.c
  • core/embed/bootloader/icon_onekey.h
  • core/embed/bootloader/bootui.h
  • core/embed/trezorhal/touch.h
  • core/embed/extmod/modtrezorui/mipi_lcd.c
  • core/embed/trezorhal/touch.c
  • core/embed/bootloader/bootui.c
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Gen check
  • GitHub Check: Style check
  • GitHub Check: Defs check
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@revan-zhang
Copy link
Contributor

revan-zhang commented Jul 23, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

somebodyLi
somebodyLi previously approved these changes Jul 23, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🔭 Outside diff range comments (1)
core/embed/bootloader/bootui.c (1)

800-880: LCD window bounds may overflow
end_x = x0 + w and end_y = y0 + h exceed max index when w or h equals the full resolution.

  • core/embed/extmod/modtrezorui/mipi_lcd.c: lcd_set_window sets end_x = x0 + w, end_y = y0 + h
  • core/embed/bootloader/bootui.c:
    • lcd_set_window(0, SUBTITLE_OFFSET_Y - bar_height / 2, MAX_DISPLAY_RESX, UPDATE_SECTION_HEIGHT);
    • lcd_set_window(0, 0, MAX_DISPLAY_RESX, MAX_DISPLAY_RESY);
🧹 Nitpick comments (2)
core/embed/trezorhal/touch.c (1)

83-92: Variable names ads_dx and ads_dy unclear.

Should be abs_dx and abs_dy.

-  int ads_dx = abs(dx);
-  int ads_dy = abs(dy);
-  if (ads_dx < SWIPE_THRESHOLD_PIXELS && ads_dy < SWIPE_THRESHOLD_PIXELS)
+  int abs_dx = abs(dx);
+  int abs_dy = abs(dy);
+  if (abs_dx < SWIPE_THRESHOLD_PIXELS && abs_dy < SWIPE_THRESHOLD_PIXELS)
     return SWIPE_NONE;
-  if (ads_dx > ads_dy)
+  if (abs_dx > abs_dy)
     return dx > 0 ? SWIPE_RIGHT : SWIPE_LEFT;
   else
     return dy > 0 ? SWIPE_DOWN : SWIPE_UP;
core/embed/bootloader/bootui.c (1)

797-798: Magic number needs explanation.

340 pixel height should be documented or made a named constant.

+// Maximum height for scrollable update section
 #define UPDATE_SECTION_HEIGHT 340
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 01ea1e3 and 933dfe8.

📒 Files selected for processing (9)
  • core/embed/bootloader/bootui.c (5 hunks)
  • core/embed/bootloader/bootui.h (2 hunks)
  • core/embed/bootloader/icon_onekey.h (1 hunks)
  • core/embed/emmc_wrapper/emmc_commands.c (8 hunks)
  • core/embed/extmod/modtrezorui/mipi_lcd.c (5 hunks)
  • core/embed/extmod/modtrezorui/mipi_lcd.h (1 hunks)
  • core/embed/trezorhal/image.h (1 hunks)
  • core/embed/trezorhal/touch.c (1 hunks)
  • core/embed/trezorhal/touch.h (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Gen check
  • GitHub Check: Style check
  • GitHub Check: Defs check
🔇 Additional comments (12)
core/embed/trezorhal/image.h (1)

126-126: LGTM!

The se_address field addition is consistent with the existing struct pattern.

core/embed/bootloader/icon_onekey.h (1)

124-133: LGTM!

Good switch from raw pixel data to compressed TOIg format.

core/embed/trezorhal/touch.h (1)

52-117: LGTM!

Well-structured gesture detection types and API.

core/embed/trezorhal/touch.c (1)

79-79: LGTM!

Proper function closure.

core/embed/extmod/modtrezorui/mipi_lcd.h (1)

95-95: LGTM!

Clear window clipping API.

core/embed/bootloader/bootui.c (5)

538-610: Function logic looks correct.

Input coordinate matching is properly modularized.


616-619: Clean refactor.

Good use of the extracted helper function.


625-627: Public interface addition is sound.

Exposes the input matching functionality correctly.


895-923: Scrolling logic appears correct.

Boundary checks and offset calculations look proper.


938-941: Icon rendering updated correctly.

Switched from raw display to compressed icon format.

core/embed/bootloader/bootui.h (2)

90-90: Function declaration looks good.

Well-placed and follows naming conventions.


102-102: Function declaration looks good.

Appropriate extension of existing functionality.

@lihuanhuan lihuanhuan enabled auto-merge (squash) July 23, 2025 08:33
@lihuanhuan lihuanhuan merged commit 4fc4980 into OneKeyHQ:main Jul 23, 2025
9 checks passed
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.

4 participants