diff --git a/analysis/preview/preview_fix_pose0_v7.png b/analysis/preview/preview_fix_pose0_v7.png new file mode 100644 index 0000000..f1f2c1f --- /dev/null +++ b/analysis/preview/preview_fix_pose0_v7.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3729c85023ad2db4d9dbcf3dbb137e4978d15b72979b9428e4bf20b9023496b +size 767935 diff --git a/analysis/preview/preview_fix_pose180_v7.png b/analysis/preview/preview_fix_pose180_v7.png new file mode 100644 index 0000000..debe9e0 --- /dev/null +++ b/analysis/preview/preview_fix_pose180_v7.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ba6a9d5638222dc1c70d42a17c092d0e35dbd3bcfbdf3c806a2dba389c89f2d +size 762300 diff --git a/analysis/preview/preview_fix_pose270_v7.png b/analysis/preview/preview_fix_pose270_v7.png new file mode 100644 index 0000000..e03a80b --- /dev/null +++ b/analysis/preview/preview_fix_pose270_v7.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d3301d96fc4c4cc26fa35bee1e5866db1f8cadd0ca1d3f53616edd643303add +size 775704 diff --git a/analysis/preview/preview_fix_pose90_v7.png b/analysis/preview/preview_fix_pose90_v7.png new file mode 100644 index 0000000..4353a68 --- /dev/null +++ b/analysis/preview/preview_fix_pose90_v7.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f5ab1a7a11974f638063711579b8dbbbbf65dcc3f76968609200ae98573329e +size 775296 diff --git a/android/app/src/main/kotlin/com/mag160c/thermal/ui/DeviceOrientation.kt b/android/app/src/main/kotlin/com/mag160c/thermal/ui/DeviceOrientation.kt index 03ab966..3675ffb 100644 --- a/android/app/src/main/kotlin/com/mag160c/thermal/ui/DeviceOrientation.kt +++ b/android/app/src/main/kotlin/com/mag160c/thermal/ui/DeviceOrientation.kt @@ -13,8 +13,15 @@ import kotlinx.coroutines.flow.StateFlow * Physical orientation of the phone relative to its portrait grip, from the * accelerometer. [deg] is the CLOCKWISE rotation of the device as seen by * the user: 0 = upright portrait, 90 = turned clockwise (portrait top edge - * points to the user's right, gravity along +X device), 180 = upside down, - * 270 = turned counter-clockwise. + * points to the user's right, sensor reads -g on X), 180 = upside down + * (sensor reads -g on Y), 270 = turned counter-clockwise (sensor reads +g + * on X). + * + * Android accelerometer convention (REAL devices): at rest the reading is + * "acceleration minus gravity", i.e. it points to world UP in device coords + * — flat on a table screen-up -> z=+9.81, upright portrait -> y=+9.81. + * (Note the emulator's virtual sensor uses the opposite, gravity-vector + * convention; do not "fix" this mapping to match emulator defaults.) * * The activity is portrait-locked (composition glued to the phone frame, so * the thermal image region always matches the lens direction). UI layers use @@ -45,11 +52,12 @@ object DeviceOrientation : SensorEventListener { override fun onSensorChanged(event: SensorEvent) { val gx = event.values[0] val gy = event.values[1] + // world-up in device coords: (0,+g)=0 (-g,0)=90 (0,-g)=180 (+g,0)=270. // hysteresis: only switch pose when the dominant axis clearly wins, // so ~45 deg in-between holds keep the previous reading val next = when { - abs(gx) > abs(gy) + 2.5f -> if (gx > 0) 90 else 270 - abs(gy) > abs(gx) + 2.5f -> if (gy < 0) 0 else 180 + abs(gx) > abs(gy) + 2.5f -> if (gx < 0) 90 else 270 + abs(gy) > abs(gx) + 2.5f -> if (gy > 0) 0 else 180 else -> _deg.value } if (next != _deg.value) _deg.value = next diff --git a/build-artifacts/mag160c-app-debug.apk b/build-artifacts/mag160c-app-debug.apk index 9024b90..5613b4e 100644 --- a/build-artifacts/mag160c-app-debug.apk +++ b/build-artifacts/mag160c-app-debug.apk @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f8168002febd300de25e27c9db84cb5b01b8228f18c679c8f05ffeace506043e +oid sha256:c94cca39eccb20a020f732dbfe4dcc3bd86684d50cf676216612536eec7c9a71 size 11863017 diff --git a/docs/android_app/HANDOFF_DEVELOPMENT.md b/docs/android_app/HANDOFF_DEVELOPMENT.md index 2dc5144..721a501 100644 --- a/docs/android_app/HANDOFF_DEVELOPMENT.md +++ b/docs/android_app/HANDOFF_DEVELOPMENT.md @@ -111,6 +111,10 @@ res/drawable/*.xml 自绘矢量图标(双弧圆等可靠几何图形 Display.rotation 恒 0 不可用)。顶栏/底部导航条目 `graphicsLayer rotationZ=-φ` 原位预旋转;渲染器 OSD 文字 `canvas.rotate(-φ)` 绕锚点旋转(标记圆点、色标条 几何仍钉死在图像上)。对话框与其他页签暂不补偿。 +- **加速度计符号约定(第七轮教训,勿改回)**:真机 TYPE_ACCELEROMETER 静止读数 + 指向世界上方(竖屏正持 y=+9.81);模拟器虚拟传感器是反的重力约定(y=-9.81)。 + DeviceOrientation 映射按**真机约定**写,模拟器测试须用反号值驱动 + (φ=0→`adb emu sensor set acceleration 0:9.81:0`)。 - **图像恒 90°CW 绘制为 3:4 竖向**,填满可用区域(顶栏下~底导航上)。 - **文字/图标恒屏幕水平**(可读);标记文字位置自动跟随(probeToScreen 固定 90° 映射: `fx=1-sy/120, fy=sx/160`)。 diff --git a/docs/android_app/session_state.md b/docs/android_app/session_state.md index d59ab62..a7e5d03 100644 --- a/docs/android_app/session_state.md +++ b/docs/android_app/session_state.md @@ -154,6 +154,18 @@ - [x] 单元测试全过;APK 已更新。 - 注:对话框(调色板等)与其他页签内容未做补偿旋转(保持竖屏可读),如需再加。 +## 用户反馈修复 第七轮(2026-09-07,真机朝向全反修复) + +- [x] **用户反馈**:真机正持竖屏时屏幕内容倒立,其他方向也全反。 +- [x] **根因**:第六轮把加速度计符号约定写反。Android 真机 TYPE_ACCELEROMETER + 静止读数 = "加速度减重力",指向世界上方向(平放屏幕朝上 z=+9.81、竖屏正持 + y=+9.81);模拟器虚拟传感器却是重力向量约定(正持 y=-9.81),故模拟器测试 + "通过"而真机全反(所有姿态差 180°)。 +- [x] **修复**:DeviceOrientation 映射改为 (0,+g)=0、(-g,0)=90、(0,-g)=180、(+g,0)=270; + 代码注释明确标注"勿按模拟器默认值改回"。模拟器用反号值复测:姿态 0 恢复正常 + 正持显示,90/180/270 补偿几何不变(preview_fix_pose*_v7.png)。 +- [x] 单元测试全过;APK 已更新。 + ## 待办 - 真机USB实测(温度绝对值标定、FFC/录像/MDT保存端到端)