Skip to content

Instantly share code, notes, and snippets.

@hatsunea
Last active June 27, 2022 13:29
Show Gist options
  • Save hatsunea/01e9e78fc202eac1d94e9e5f7519c9c0 to your computer and use it in GitHub Desktop.
Save hatsunea/01e9e78fc202eac1d94e9e5f7519c9c0 to your computer and use it in GitHub Desktop.
internal PressureResolution PressureResolution { get; set; } = PressureResolution.High;
private PowerMode PowerMode = PowerMode.Sleep;
private CalibrationData Qmp6988Cali = new();
private IkData Qmp6988Ik = new();
private I2cDevice I2c;
public Qmp6988(I2cDevice device)
{
this.I2c = device;
// 初期化
SoftwareReset();
GetCalibrationData();
}
/// <summary>
/// 初期化
/// </summary>
internal void SetPowerMode(PowerMode powerMode)
{
// 解像度やパワーモードを設定
var data = this.ReadToRegister(Register.CTRL_MEAS, 1);
this.PowerMode = powerMode;
this.WriteToRegister(Register.CTRL_MEAS, (byte)((byte)data[0] | (byte)TempResolution.Low | (byte)PressureResolution | (byte)PowerMode));
}
private void WriteToRegister(Register register, byte value)
{
SpanByte writeBuff = new byte[]
{
(byte)register, (byte)value
};
this.I2c.Write(writeBuff);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment