默认 I²C 连接

I2C

Connection

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
Bit Field Offset Bits Format Description
测量模式 0 2 Decimal 0=正常; 1=正偏置; 2=负偏置;3=保留
数据输出速率 2 3 Decimal 0=0.75Hz; 1=1.5Hz; 2=3Hz; 3=7.5Hz; 4=15Hz; 5=30Hz; 6=75Hz; 7=保留;
采样平均次数 5 2 Decimal 0=1次; 1=2次; 2=4次; 3=8 次
配置寄存器B 0x01 R/W byte Binary
Bit Field Offset Bits Format Description
保留 0 5 Decimal 必须为0
增益 / 量程 5 3 Decimal 0=0.88±Ga1370LSB/Ga;1=1.3±Ga1090LSB/Ga;2=1.9±Ga820LSB/Ga;3=2.5±Ga660LSB/Ga;4=4.0±Ga440LSB/Ga;5=4.7±Ga390LSB/Ga;6=5.6±Ga330LSB/Ga;7=8.1±Ga230LSB/Ga
模式寄存器 0x02 R/W byte Binary
Bit Field Offset Bits Format Description
模式 0 2 Decimal 0=连续测量;1=单次测量;2=待机;3=待机
保留 2 6 Decimal 必须为0
数据X 0x03 Read Only int16BE Hex
数据Z 0x05 Read Only int16BE Hex
数据Y 0x07 Read Only int16BE Hex
状态寄存器 0x09 Read Only byte Binary
Bit Field Offset Bits Format Description
就绪 0 1 Binary 1:有新的测量数据可以读 0:没有新数据
锁定 1 1 Binary 1:数据锁定 0:数据正常
识别寄存器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