1 |
1 |
2 |
2 |
3 #include "tapcontroller.h" |
3 #include "tapcontroller.h" |
|
4 #include <QDebug> |
|
5 |
4 |
6 |
5 const qreal TapController::m_timewindow=1000; |
7 const qreal TapController::m_timewindow=1000; |
6 |
8 |
7 |
9 |
8 TapController::TapController(): m_step(20){} |
10 TapController::TapController(): TimedController(), m_step(20){ |
|
11 m_accelerometer.connectToBackend(); |
|
12 m_accelerometer.start(); |
|
13 connect(&m_accelerometer, SIGNAL(readingChanged()), this, SLOT(updateAcce())); |
9 |
14 |
10 |
|
11 void TapController::startSensor() |
|
12 { |
|
13 m_tap.connectToBackend(); |
15 m_tap.connectToBackend(); |
14 m_tap.start(); |
16 m_tap.start(); |
15 connect(&m_tap, SIGNAL(readingChanged()), this, SLOT(update())); |
17 connect(&m_tap, SIGNAL(readingChanged()), this, SLOT(update())); |
16 m_accelerometer.connectToBackend(); |
18 |
17 m_accelerometer.start(); |
|
18 connect(&m_tap, SIGNAL(readingChanged()), this, SLOT(updateAcce())); |
|
19 } |
19 } |
20 |
20 |
|
21 TapController::~TapController(){ |
|
22 m_tap.stop(); |
|
23 disconnect(&m_tap); |
|
24 m_accelerometer.stop(); |
|
25 disconnect(&m_accelerometer); |
|
26 } |
21 |
27 |
22 void TapController::stopSensor(){ |
|
23 m_tap.stop(); |
|
24 m_accelerometer.stop(); |
|
25 } |
|
26 |
28 |
27 |
29 |
28 void TapController::update() |
30 void TapController::update() |
29 { |
31 { |
30 int direction = m_tap.reading()->tapDirection(); |
32 int direction = m_tap.reading()->tapDirection(); |