mpu/pkg/mpu6050/i2c.go

14 lines
297 B
Go
Raw Permalink Normal View History

2024-07-24 11:29:00 +00:00
package mpu6050
import (
"encoding/binary"
)
func (d device) readWord(register byte) (int16, error) {
bytes := make([]byte, 2)
if err := d.device.ReadReg(register, bytes); err != nil {
return 0, err
}
return int16(binary.BigEndian.Uint16(bytes)), nil // !!! CHECK uint->int convertsion
}