默认 I²C 连接
I2CConnection
- Device Address
0x3C- Adapter
- JooieeUsbI2C
- Address Format
- Hex
- Auto Refresh Interval
- 100 ms
- Speed Mode
- 100K
- Address Type
- 8BIT
- VCC Mode
- IO
- VIO Mode
- 3.3V
Registers
| Name | Address | Access | Type | Format | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 配置寄存器A | 0x00 |
R/W | byte |
Binary | |||||||||||||||||||||
|
|||||||||||||||||||||||||
| 配置寄存器B | 0x01 |
R/W | byte |
Binary | |||||||||||||||||||||
|
|||||||||||||||||||||||||
| 模式寄存器 | 0x02 |
R/W | byte |
Binary | |||||||||||||||||||||
|
|||||||||||||||||||||||||
| 数据X | 0x03 |
Read Only | int16BE |
Hex | |||||||||||||||||||||
| 数据Z | 0x05 |
Read Only | int16BE |
Hex | |||||||||||||||||||||
| 数据Y | 0x07 |
Read Only | int16BE |
Hex | |||||||||||||||||||||
| 状态寄存器 | 0x09 |
Read Only | byte |
Binary | |||||||||||||||||||||
|
|||||||||||||||||||||||||
| 识别寄存器A | 0x0A |
Read Only | char |
Hex | 固定字符 "H" | ||||||||||||||||||||
| 识别寄存器B | 0x0B |
Read Only | char |
Hex | 固定字符 "4" | ||||||||||||||||||||
| 识别寄存器C | 0x0C |
Read Only | char |
Hex | 固定字符 "3" | ||||||||||||||||||||
Script
JavaScript
// custom function could be called in
// template and other functions
export async function onAutoRefresh( values ) {
let x = values.get("数据X") - 75;
let y = values.get("数据Y") + 480;
// 单位:弧度
// 范围:-π ~ +π
// 参考方向:X 轴正方向
// 旋转方向:逆时针为正
let headingRad = Math.atan2(y, x);
// 航向角 范围 -180° ~ +180°
let headingDeg = headingRad * 180 / Math.PI;
// 转成 0 ~ 360°
if (headingDeg < 0) {
headingDeg += 360;
}
// 修正固定偏移量
let correctedHeading = headingDeg + $this.variable("角度修正量") * 1;
if ( correctedHeading >= 360 ) {
correctedHeading = correctedHeading - 360;
}
$this.variable("无修正航向角", correctedHeading);
}
Variables
| Name | Type | Default |
|---|---|---|
无修正航向角 |
number |
0 |
角度修正量 |
number |
66 |