Skip to content

Instantly share code, notes, and snippets.

@hatsunea
Last active June 27, 2022 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hatsunea/087d47fe69ccd2b8312c65e77536f000 to your computer and use it in GitHub Desktop.
Save hatsunea/087d47fe69ccd2b8312c65e77536f000 to your computer and use it in GitHub Desktop.
internal float CalcPressureHectopascals()
{
return this.CalcPressure() / 100;
}
internal float CalcPressure()
{
// データを取得
var data = this.ReadToPressure(Register.PRESS_TXD);
var pRaw = (int)(System.Buffers.Binary.BinaryPrimitives.ReadUInt32BigEndian(data) - Math.Pow(2, 23));
data = this.ReadToPressure(Register.TEMP_TXD);
var tRaw = (int)(System.Buffers.Binary.BinaryPrimitives.ReadUInt32BigEndian(data) - Math.Pow(2, 23));
// 温度補正
var tInt = ConvTx02e(tRaw);
var pInt = Pressure02e(pRaw, tInt);
return (float)pInt / 16.0f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment