From b68a0bd6a68457b27a07646a150d4812fb98daa2 Mon Sep 17 00:00:00 2001 From: Ivan Gorinov Date: Sun, 30 Oct 2011 20:22:35 -0700 Subject: [PATCH] Version 1.0.0 --- ameter.pro | 12 +++++++++--- ameterwidget.cpp | 19 +++++++++++++++---- ameterwidget.h | 1 + asettings.cpp | 22 +++++++++++++--------- asettings.h | 3 ++- debian/changelog | 7 ++++--- debian/control | 2 +- debian/copyright | 13 ++++--------- debian/files | 2 +- mainwindow.cpp | 22 +++++++++++++++++----- mainwindow.h | 4 +++- 11 files changed, 70 insertions(+), 37 deletions(-) diff --git a/ameter.pro b/ameter.pro index 6f10375..ce67a68 100644 --- a/ameter.pro +++ b/ameter.pro @@ -22,12 +22,17 @@ symbian:TARGET.CAPABILITY += NetworkServices CONFIG += mobility MOBILITY += sensors -SOURCES += main.cpp mainwindow.cpp \ +SOURCES += main.cpp \ + mainwindow.cpp \ ameterwidget.cpp \ - asettings.cpp + asettings.cpp \ + about.cpp + HEADERS += mainwindow.h \ ameterwidget.h \ - asettings.h + asettings.h \ + about.h + FORMS += # Please do not modify the following two lines. Required for deployment. @@ -41,3 +46,4 @@ OTHER_FILES += \ qtc_packaging/debian_fremantle/control \ qtc_packaging/debian_fremantle/compat \ qtc_packaging/debian_fremantle/changelog + diff --git a/ameterwidget.cpp b/ameterwidget.cpp index f2377e2..f5576ce 100644 --- a/ameterwidget.cpp +++ b/ameterwidget.cpp @@ -9,7 +9,10 @@ qreal g_n = 9.80665; qreal a_max = 2; int angle_step = 30; int divisions = 4; -qreal filter_k = 0.5; + +// Smoothing: 0 - none, 1 - light, 2 - medium, 3 - strong +int smoothing = 1; +qreal smoothing_k[] = {1, 0.5, 0.25, 0.125}; AMeterWidget::AMeterWidget(QWidget *parent) : QWidget(parent) @@ -44,6 +47,8 @@ int AMeterWidget::setGravity(qreal g) return 0; } +// This method is called on every update, keep division operations out + void AMeterWidget::paintEvent(QPaintEvent *e) { QPainter paint(this); @@ -146,6 +151,7 @@ void AMeterWidget::drawScale() bool AMeterWidget::filter(QAccelerometerReading *reading) { + qreal k = 1; bx = ax; by = ay; bz = az; @@ -154,11 +160,16 @@ bool AMeterWidget::filter(QAccelerometerReading *reading) ay = reading->y() * r_g; az = reading->z() * r_g; - ax = ax * (1.0 - filter_k) + bx * filter_k; - ay = ay * (1.0 - filter_k) + by * filter_k; - az = az * (1.0 - filter_k) + bz * filter_k; + if (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); + } update(); return true; } + diff --git a/ameterwidget.h b/ameterwidget.h index 35cd895..5a540ee 100644 --- a/ameterwidget.h +++ b/ameterwidget.h @@ -40,3 +40,4 @@ private: }; #endif // AMETERWIDGET_H + diff --git a/asettings.cpp b/asettings.cpp index 1ae9225..eb43884 100644 --- a/asettings.cpp +++ b/asettings.cpp @@ -2,7 +2,7 @@ extern qreal g_n; extern qreal a_max; -extern qreal filter_k; +extern int smoothing; extern int angle_step; extern int divisions; extern int data_rate; @@ -59,13 +59,16 @@ SettingsDialog::SettingsDialog(QWidget *parent): QDialog(parent) editRate->setInputMethodHints(Qt::ImhDigitsOnly); editRate->setText(QString::number(data_rate)); label->setBuddy(editRate); - label = new QLabel(QString::fromUtf8("&Filter depth"), this); + label = new QLabel(QString::fromUtf8("&Smoothing"), this); hbox->addWidget(label); - editFilter = new QLineEdit(this); - hbox->addWidget(editFilter); - editFilter->setInputMethodHints(Qt::ImhFormattedNumbersOnly); - editFilter->setText(QString::number(filter_k)); - label->setBuddy(editFilter); + comboSmoothing = new QComboBox(this); + comboSmoothing->addItem("None"); + comboSmoothing->addItem("Light"); + comboSmoothing->addItem("Medium"); + comboSmoothing->addItem("Strong"); + comboSmoothing->setCurrentIndex(smoothing); + hbox->addWidget(comboSmoothing); + label->setBuddy(comboSmoothing); vbox->addLayout(hbox); buttonOk = new QPushButton("Ok"); @@ -74,7 +77,7 @@ SettingsDialog::SettingsDialog(QWidget *parent): QDialog(parent) setLayout(vbox); - layout()->setSizeConstraint( QLayout::SetFixedSize ); + layout()->setSizeConstraint(QLayout::SetFixedSize); } SettingsDialog::~SettingsDialog() @@ -85,9 +88,10 @@ void SettingsDialog::accept() { g_n = editG->text().toDouble(); a_max = editMax->text().toDouble(); - filter_k = editFilter->text().toDouble(); + smoothing = comboSmoothing->currentIndex(); divisions = editDiv->text().toInt(); angle_step = editAngle->text().toInt(); data_rate = editRate->text().toInt(); QDialog::accept(); } + diff --git a/asettings.h b/asettings.h index 2ac0289..bf5a40b 100644 --- a/asettings.h +++ b/asettings.h @@ -6,6 +6,7 @@ #include #include #include +#include #include class SettingsDialog: public QDialog @@ -19,7 +20,7 @@ private: QLabel *label; QLineEdit *editG; QLineEdit *editMax; - QLineEdit *editFilter; + QComboBox *comboSmoothing; QLineEdit *editDiv; QLineEdit *editAngle; QLineEdit *editRate; diff --git a/debian/changelog b/debian/changelog index 43efb3a..c31660d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ -ameter (0.0.1) unstable; urgency=low +ameter (1.0.0) unstable; urgency=low - * Initial Release. + * Initial release for Maemo 5 (Nokia N900) + + -- Ivan Gorinov Sun, 30 Oct 2011 13:26:06 -0700 - -- Ivan Gorinov Mon, 27 Jun 2011 22:36:07 -0700 diff --git a/debian/control b/debian/control index 9ca1c1d..24f941d 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: ameter Section: user/utilities Priority: optional -Maintainer: Ivan Gorinov +Maintainer: Ivan Gorinov Build-Depends: debhelper (>= 5), libqt4-dev Standards-Version: 3.7.3 Homepage: http://catori.ru/igorinov/software/ameter/ diff --git a/debian/copyright b/debian/copyright index 0c5e9be..2f4f576 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,17 +1,15 @@ This package was debianized by Ivan Gorinov on Mon, 27 Jun 2011 22:36:07 -0700. -It was downloaded from +It was downloaded from Upstream Author(s): - - + Ivan Gorinov Copyright: - - + Copyright (C) 2011 Ivan Gorinov License: @@ -32,9 +30,6 @@ License: On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. -The Debian packaging is (C) 2011, Ivan Gorinov and +The Debian packaging is (C) 2011, Ivan Gorinov and is licensed under the GPL, see above. - -# Please also look if there are files or directories which have a -# different copyright/license attached and list them here. diff --git a/debian/files b/debian/files index 11c0158..b596ba0 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -ameter_0.0.1_armel.deb user/utilities optional +ameter_1.0.0_armel.deb user/utilities optional diff --git a/mainwindow.cpp b/mainwindow.cpp index 6efe040..672c4e2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,15 +1,17 @@ +#include + #include "mainwindow.h" #include "asettings.h" +#include "about.h" extern qreal g_n; extern qreal a_max; extern int divisions; extern int angle_step; +extern int smoothing; int data_rate = 0; -#include - MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { @@ -21,13 +23,15 @@ MainWindow::MainWindow(QWidget *parent) a_max = settings.value("max", a_max).toDouble(); divisions = settings.value("divisions", divisions).toInt(); angle_step = settings.value("angle_step", angle_step).toInt(); + smoothing = settings.value("smoothing", smoothing).toInt(); data_rate = settings.value("rate", data_rate).toInt(); - + awidget = new AMeterWidget(this); setCentralWidget(awidget); action = bar->addAction("&About"); + connect(action, SIGNAL(triggered()), this, SLOT(showAbout())); action = bar->addAction("&Settings"); - connect(action, SIGNAL(triggered()), this, SLOT(changeSettings())); + connect(action, SIGNAL(triggered()), this, SLOT(showSettings())); accelerometer = new QAccelerometer(this); accelerometer->setProperty("alwaysOn", true); accelerometer->addFilter(awidget); @@ -42,7 +46,14 @@ MainWindow::~MainWindow() delete accelerometer; } -void MainWindow::changeSettings() +void MainWindow::showAbout() +{ + AboutDialog dialog(this); + + dialog.exec(); +} + +void MainWindow::showSettings() { SettingsDialog dialog(this); QSettings settings("igorinov", "ameter", this); @@ -117,3 +128,4 @@ void MainWindow::showExpanded() show(); #endif } + diff --git a/mainwindow.h b/mainwindow.h index 6189ba3..59e8c86 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -32,7 +32,8 @@ public: void showExpanded(); public slots: - void changeSettings(); + void showAbout(); + void showSettings(); private: QAccelerometer *accelerometer; @@ -40,3 +41,4 @@ private: }; #endif // MAINWINDOW_H + -- 1.7.9.5