@@ -451,11 +451,11 @@ end
451451Read raw gyroscope values (X, Y, Z) as signed 16-bit integers.
452452"""
453453function read_gyro_raw (imu:: ICM42688 )
454- buf = @view imu. rx_buf[ 1 : 6 ]
455- read_regs! (imu, ICM42688Registers . GYRO_DATA_X1, buf)
456- gx = parse_int16_be (buf[1 ], buf[2 ])
457- gy = parse_int16_be (buf[3 ], buf[4 ])
458- gz = parse_int16_be (buf[5 ], buf[6 ])
454+ read_regs! ( imu, ICM42688Registers . GYRO_DATA_X1, 6 )
455+ buf = imu . rx_buf
456+ gx = parse_int16_be (buf[2 ], buf[3 ])
457+ gy = parse_int16_be (buf[4 ], buf[5 ])
458+ gz = parse_int16_be (buf[6 ], buf[7 ])
459459 return (gx, gy, gz)
460460end
461461
476476Read raw temperature value as a signed 16-bit integer.
477477"""
478478function read_temp_raw (imu:: ICM42688 )
479- buf = @view imu. rx_buf[1 : 2 ]
480- read_regs! (imu, ICM42688Registers. TEMP_DATA1, buf)
481- return parse_int16_be (buf[1 ], buf[2 ])
479+ read_regs! (imu, ICM42688Registers. TEMP_DATA1, 2 )
480+ return parse_int16_be (imu. rx_buf[2 ], imu. rx_buf[3 ])
482481end
483482
484483"""
@@ -500,17 +499,17 @@ Reads 14 consecutive bytes starting from TEMP_DATA1 (0x1D).
500499Layout: TEMP(2) + ACCEL(6) + GYRO(6) = 14 bytes.
501500"""
502501function read_all_raw (imu:: ICM42688 )
503- buf = @view imu. rx_buf[ 1 : 14 ]
504- read_regs! (imu, ICM42688Registers . TEMP_DATA1, buf)
502+ read_regs! ( imu, ICM42688Registers . TEMP_DATA1, 14 )
503+ buf = imu . rx_buf # data at indices 2..15
505504
506505 return ICM42688Data (
507- parse_int16_be (buf[3 ], buf[4 ]), # ACCEL_X
508- parse_int16_be (buf[5 ], buf[6 ]), # ACCEL_Y
509- parse_int16_be (buf[7 ], buf[8 ]), # ACCEL_Z
510- parse_int16_be (buf[1 ], buf[2 ]), # TEMP
511- parse_int16_be (buf[9 ], buf[10 ]), # GYRO_X
512- parse_int16_be (buf[11 ], buf[12 ]), # GYRO_Y
513- parse_int16_be (buf[13 ], buf[14 ]) # GYRO_Z
506+ parse_int16_be (buf[4 ], buf[5 ]), # ACCEL_X
507+ parse_int16_be (buf[6 ], buf[7 ]), # ACCEL_Y
508+ parse_int16_be (buf[8 ], buf[9 ]), # ACCEL_Z
509+ parse_int16_be (buf[2 ], buf[3 ]), # TEMP
510+ parse_int16_be (buf[10 ], buf[11 ]), # GYRO_X
511+ parse_int16_be (buf[12 ], buf[13 ]), # GYRO_Y
512+ parse_int16_be (buf[14 ], buf[15 ]) # GYRO_Z
514513 )
515514end
516515
614613Read the number of bytes currently in the FIFO.
615614"""
616615function read_fifo_count (imu:: ICM42688 )
617- buf = @view imu. rx_buf[1 : 2 ]
618- read_regs! (imu, ICM42688Registers. FIFO_COUNTH, buf)
619- return (UInt16 (buf[1 ]) << 8 ) | UInt16 (buf[2 ])
616+ read_regs! (imu, ICM42688Registers. FIFO_COUNTH, 2 )
617+ return (UInt16 (imu. rx_buf[2 ]) << 8 ) | UInt16 (imu. rx_buf[3 ])
620618end
621619
622620"""
0 commit comments