Merge pull request #146 from Debenben/tiltSensor

add workaround for wrong tilt orientation
This commit is contained in:
Nathan Kellenicki 2022-01-18 17:26:47 -08:00 committed by GitHub
commit a0279a1fb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,14 @@ export class TechnicMediumHubTiltSensor extends Device {
let z = -message.readInt16LE(4); let z = -message.readInt16LE(4);
const y = message.readInt16LE(6); const y = message.readInt16LE(6);
const x = message.readInt16LE(8); const x = message.readInt16LE(8);
// workaround for calibration problem or bug in technicMediumHub firmware 1.1.00.0000
if(y === 90 || y === -90) {
z = Math.sign(y)*(z + 180);
if(z > 180) z -= 360;
if(z < -180) z += 360;
}
this.notify("tilt", { x, y, z }); this.notify("tilt", { x, y, z });
break; break;