Skip to content

Conversation

@takaokouji
Copy link

Summary

Added new tilt-related blocks to MicroBit More extension to match the original microbit extension:

  • Event block: "どれかの向きに傾いたとき" (when tilted in any direction)
  • Boolean block: "[DIRECTION] に傾いた" (tilted in direction)
  • Reporter block: "[DIRECTION] 方向の傾き" (tilt angle in direction)

Implementation Details

Task 3B: whenTilted event block

  • Added "TILTED" option to GESTURES_MENU
  • Implemented tilt-specific gap detection logic similar to "moved" event
  • Uses 5-frame gap threshold and 30-frame forced trigger

Task 3C: isTilted boolean block

  • Added TILT_DIRECTION_MENU (ANY, UP, DOWN, LEFT, RIGHT)
  • Returns true if tilt event occurred within 5-frame time window
  • Uses gesture event timestamps for detection

Task 3D: getTiltAngle reporter block

  • Added TILT_ANGLE_DIRECTION_MENU (FRONT, BACK, LEFT, RIGHT)
  • Uses pitch/roll values to calculate tilt angle:
    • FRONT → pitch, BACK → -pitch
    • LEFT → roll, RIGHT → -roll

Japanese Translations

All blocks and menu items have Japanese translations for both ja and ja-Hira locales.

Test Coverage

  • Lint: npm run lint passes
  • Build: npm run build via smalruby3-gui succeeds

Related

🤖 Generated with Claude Code

takaokouji and others added 3 commits January 16, 2026 17:51
Add a new gesture option "TILTED" that triggers when any of the tilt
events (TILT_UP, TILT_DOWN, TILT_LEFT, TILT_RIGHT) occur. This matches
the microbit extension's "(どれかの向き▼)に傾いたとき" behavior.

Implementation details:
- Add TILTED menu item to GESTURES_MENU
- Add state tracking variables for tilt events
- Add TILTED handling in whenGesture method with gap detection logic
- Add Japanese translations for the new menu item

Refs smalruby/smalruby3-develop#20

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added a new boolean block "[DIRECTION] に傾いた" that detects tilt state:

Implementation:
- Added TILT_DIRECTION_MENU with options: ANY, UP, DOWN, LEFT, RIGHT
- Added isTilted method that returns true if tilted within 5 frames
- Uses gesture event timestamps for tilt detection
- Matches microbit extension pattern for user migration

Japanese translations:
- Block: "[DIRECTION] に傾いた" / "[DIRECTION] にかたむいた"
- Menu items: どれかの向き, 上, 下, 左, 右

Related to: smalruby/smalruby3-develop#20

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added a new reporter block "[DIRECTION] 方向の傾き" that returns tilt angle:

Implementation:
- Added TILT_ANGLE_DIRECTION_MENU with options: FRONT, BACK, LEFT, RIGHT
- Added getTiltAngle method using pitch/roll values:
  - FRONT → pitch (forward tilt angle)
  - BACK → -pitch (backward tilt angle)
  - LEFT → roll (left tilt angle)
  - RIGHT → -roll (right tilt angle)
- Matches microbit extension pattern for user migration

Japanese translations:
- Block: "[DIRECTION] 方向の傾き" / "[DIRECTION] ほうこうのかたむき"
- Menu items: 前, 後ろ, 左, 右 / まえ, うしろ, ひだり, みぎ

Related to: smalruby/smalruby3-develop#20

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
takaokouji and others added 9 commits January 16, 2026 22:02
- FRONT vertical now returns -90 as expected by user
- Nose-up is now positive for pitch, matching description
- Clockwise tilt is now positive for roll, matching description
- Corrected inverted behavior in getTiltAngle, getPitch, and getRoll blocks

Issue #20
…n logic

- Modified getTiltAngle to return positive values when tilted in the specified direction
- Re-implemented isTilted to use tilt angle value (>= 15 degrees) instead of gesture events
- This matches the behavior of the standard micro:bit extension and fixes user-reported issues

Issue #20
- Updated tiltDirectionMenu and GESTURES_MENU labels (English and Japanese)
- Changed 'up' to 'front' and 'down' to 'back' to match physical orientation
- Fixed 'titl' typo in English default strings

Issue #20
- Swapped MbitMoreGestureID mapping for 1 and 2 to correct inverted tilt front/back detection
- Updated Japanese (ja/ja-Hira) translations for tilt gestures from 'へ傾いた' to 'に傾いた'
- Confirmed 'TILTED' (any) gesture correctly filters only tilt directions

Issue #20
- Implemented whenPinConnected hat block (Standard micro:bit compatibility)
- Reuses whenTouchEvent logic with fixed 'DOWN' (touched) event
- Added touchPinIDMenu restricting pins to 0, 1, and 2
- Added translations for the new block in ja, ja-Hira, and de

Issue #20
- Fixed broken JSDoc comment that caused whenTouchEvent to be incorrectly parsed
- Resolves 'this.whenTouchEvent is not a function' error

Issue #20
- Remove gap and timeout thresholds for TILTED gesture
- Make TILTED gesture a simple proxy for TILT_UP, TILT_DOWN, TILT_LEFT, and TILT_RIGHT events
- Remove unused tilt tracking properties from constructor

Co-Authored-By: Gemini <noreply@google.com>
@takaokouji takaokouji merged commit cc73cc0 into develop Jan 16, 2026
1 check passed
@takaokouji takaokouji deleted the feature/issue-20-tilt-blocks branch January 16, 2026 17:48
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