基于 MPU6050 传感器的屏幕方向检测与可视化系统
-
安装依赖:
python3 -m venv venv && source venv/bin/activatepip install -r screen-orientation-detection/requirements.txt
-
运行后端服务:
python screen-orientation-detection/sos.py --sensor-face front(正面安装)python screen-orientation-detection/sos.py --sensor-face back(背面安装)
-
接口与端口:
- WebSocket:
ws://<ip>:18765 - REST:
GET http://<ip>:18766/api/orientation、GET http://<ip>:18766/api/raw
- WebSocket:
-
前端查看:
- 直接打开
sos/index.html,查看实时角度、Pitch/Roll 与安装朝向标签 - 页面支持“重连 WebSocket”按钮和横屏左右文案自适配
- 直接打开
-
运行参数:
--sensor-face front|back控制安装翻转(同步下发到前端为sensorFaceFront)
-
代码内可调:
ORIENTATION_CORRECTION(screen-orientation-detection/sos.py)用于整体角度校正(0/90/180/270)
screen-orientation-detection/sos.py:后端(WebSocket + REST)与 MPU6050 读取screen-orientation-detection/index.html:前端演示页面screen-orientation-detection/requirements.txt:Python 依赖.gitignore:忽略缓存、环境与生成文件
