summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp
blob: 7cd9aa102585991545da299a1a281ce45fc06d8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtSensors module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
****************************************************************************/

#include "sensorfworientationsensor.h"

#include <datatypes/posedata.h>

char const * const SensorfwOrientationSensor::id("sensorfw.orientationsensor");

SensorfwOrientationSensor::SensorfwOrientationSensor(QSensor *sensor)
    : SensorfwSensorBase(sensor)
    , m_initDone(false)
{
    init();
    setReading<QOrientationReading>(&m_reading);
    sensor->setDataRate(10);//set a default rate
}


void SensorfwOrientationSensor::start()
{
    if (reinitIsNeeded)
        init();
    if (m_sensorInterface) {
        Unsigned data(((OrientationSensorChannelInterface*)m_sensorInterface)->orientation());
        m_reading.setOrientation(SensorfwOrientationSensor::getOrientation(data.x()));
        m_reading.setTimestamp(data.UnsignedData().timestamp_);
        newReadingAvailable();
    }
    SensorfwSensorBase::start();
}


void SensorfwOrientationSensor::slotDataAvailable(const Unsigned& data)
{
    m_reading.setOrientation(SensorfwOrientationSensor::getOrientation(data.x()));
    m_reading.setTimestamp(data.UnsignedData().timestamp_);
    newReadingAvailable();
}

bool SensorfwOrientationSensor::doConnect()
{
    Q_ASSERT(m_sensorInterface);
    return QObject::connect(m_sensorInterface, SIGNAL(orientationChanged(Unsigned)),
                            this, SLOT(slotDataAvailable(Unsigned)));
}

QString SensorfwOrientationSensor::sensorName() const
{
    return "orientationsensor";
}

QOrientationReading::Orientation SensorfwOrientationSensor::getOrientation(int orientation)
{
    switch (orientation) {
    case PoseData::BottomDown: return QOrientationReading::TopUp;
    case PoseData::BottomUp:   return QOrientationReading::TopDown;
    case PoseData::LeftUp:     return QOrientationReading::LeftUp;
    case PoseData::RightUp:    return QOrientationReading::RightUp;
    case PoseData::FaceUp:     return QOrientationReading::FaceUp;
    case PoseData::FaceDown:   return QOrientationReading::FaceDown;
    }
    return QOrientationReading::Undefined;
}

void SensorfwOrientationSensor::init()
{
    m_initDone = false;
    initSensor<OrientationSensorChannelInterface>(m_initDone);
}
oted-type-before-zero'>upstream/users/alexey-bataev/spr/slpfix-pr87011-missing-sign-extension-of-demoted-type-before-zero Vendor branches of https://github.com/llvm/llvm-project.git
summaryrefslogtreecommitdiffstats
path: root/libcxxabi/test
Commit message (Expand)AuthorAgeFilesLines
* [demangler] Respect try_to_parse_template_argsErik Pilkington2017-07-131-0/+1
* Fix incomplete type test on OS X; workaround weird DYLD_LIBRARY_PATH behaviorEric Fiselier2017-07-061-1/+5
* Add some catch(...) blocks to the tests so that if they fail, we get a good e...Marshall Clow2017-06-221-0/+13
* [demangler] Fix a exponential string copying bugErik Pilkington2017-05-281-0/+1
* __cxa_demangle: Fix constructor cv qualifier handlingTamas Berghammer2017-05-241-0/+1
* [demangler] Fix a crash in the demangler during parsing of a lamdbaErik Pilkington2017-05-241-1/+3
* [libcxxabi] Fix the test case committed in r303175.Akira Hatanaka2017-05-161-0/+1
* [libcxxabi] Align unwindHeader on a double-word boundary.Akira Hatanaka2017-05-161-0/+33
* Revert r302978 and r302981.Akira Hatanaka2017-05-141-48/+0
* [libcxxabi] Align unwindHeader on a double-word boundary.Akira Hatanaka2017-05-131-0/+48
* Revert "[libcxxabi] Align unwindHeader on a double-word boundary."Akira Hatanaka2017-05-111-46/+0
* [libcxxabi] Align unwindHeader on a double-word boundary.Akira Hatanaka2017-05-111-0/+46
* Fix use of now removed %exec test substitutionEric Fiselier2017-05-102-2/+2
* Fix use of removed SH test replacement %execEric Fiselier2017-05-101-1/+1
* XFAIL noexcept member function throw/catch test under GCC.Eric Fiselier2017-05-091-0/+4
* Fix PR25874 - cxa_thread_atexit_test.pass.cpp has an incorrect XFAIL.Eric Fiselier2017-04-204-10/+0
* Fix exception address alignment test for EHABIAsiri Rathnayake2017-04-04