blob: 50dd86a0d3d423a5e4b33b50412c43801b039c61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "androidpressure.h"
AndroidPressure::AndroidPressure(int type, QSensor *sensor, QObject *parent)
: SensorEventQueue<QPressureReading>(type, sensor, parent)
{}
void AndroidPressure::dataReceived(const ASensorEvent &event)
{
// check https://developer.android.com/reference/android/hardware/SensorEvent.html#sensor.type_pressure:
auto pressurePa = qreal(event.pressure) * 100;
if (sensor()->skipDuplicates() && qFuzzyCompare(pressurePa, m_reader.pressure()))
return;
m_reader.setTimestamp(uint64_t(event.timestamp / 1000));
m_reader.setPressure(pressurePa); //Android uses hPa, we use Pa
newReadingAvailable();
}
|