projects
/
ameter
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reset indicator when the screen is locked
[ameter]
/
ameterwidget.cpp
diff --git
a/ameterwidget.cpp
b/ameterwidget.cpp
index
f11ee02
..
4d2203d
100644
(file)
--- a/
ameterwidget.cpp
+++ b/
ameterwidget.cpp
@@
-30,6
+30,8
@@
AMeterWidget::AMeterWidget(QWidget *parent)
bx = 0;
by = 0;
bz = 0;
bx = 0;
by = 0;
bz = 0;
+
+ in_reset = 1;
}
AMeterWidget::~AMeterWidget()
}
AMeterWidget::~AMeterWidget()
@@
-55,13
+57,16
@@
void AMeterWidget::paintEvent(QPaintEvent *e)
qreal cx, cy, rx, ry;
qreal x1, y1, a;
qreal cx, cy, rx, ry;
qreal x1, y1, a;
- a = sqrt(ax * ax + ay * ay + az * az);
-
if (background)
{
paint.drawImage(QPoint(0, 0), *background);
}
if (background)
{
paint.drawImage(QPoint(0, 0), *background);
}
+ if (in_reset) {
+ return;
+ }
+
+ a = sqrt(ax * ax + ay * ay + az * az);
paint.setRenderHints(QPainter::Antialiasing);
cx = width() / 2;
paint.setRenderHints(QPainter::Antialiasing);
cx = width() / 2;
@@
-170,16
+175,25
@@
bool AMeterWidget::filter(QAccelerometerReading *reading)
ay = reading->y() * r_g;
az = reading->z() * r_g;
ay = reading->y() * r_g;
az = reading->z() * r_g;
- if (smoothing > 0 && smoothing < 4)
+ if (!in_reset && smoothing > 0 && smoothing < 4)
{
k = smoothing_k[smoothing];
ax = ax * k + bx * (1.0 - k);
ay = ay * k + by * (1.0 - k);
az = az * k + bz * (1.0 - k);
}
{
k = smoothing_k[smoothing];
ax = ax * k + bx * (1.0 - k);
ay = ay * k + by * (1.0 - k);
az = az * k + bz * (1.0 - k);
}
-
+
+ in_reset = 0;
update();
return true;
}
update();
return true;
}
+void AMeterWidget::reset()
+{
+ in_reset = 0;
+ ax = 0;
+ ay = 0;
+ az = 0;
+}
+