Version 1.0.0
authorIvan Gorinov <igorinov@gmail.com>
Mon, 31 Oct 2011 03:22:35 +0000 (20:22 -0700)
committerIvan Gorinov <igorinov@gmail.com>
Mon, 31 Oct 2011 03:22:35 +0000 (20:22 -0700)
ameter.pro
ameterwidget.cpp
ameterwidget.h
asettings.cpp
asettings.h
debian/changelog
debian/control
debian/copyright
debian/files
mainwindow.cpp
mainwindow.h

index 6f10375..ce67a68 100644 (file)
@@ -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
+
index f2377e2..f5576ce 100644 (file)
@@ -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;
 }
+
index 35cd895..5a540ee 100644 (file)
@@ -40,3 +40,4 @@ private:
 };
 
 #endif // AMETERWIDGET_H
+
index 1ae9225..eb43884 100644 (file)
@@ -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();
 }
+
index 2ac0289..bf5a40b 100644 (file)
@@ -6,6 +6,7 @@
 #include <QtGui/QHBoxLayout>
 #include <QtGui/QLabel>
 #include <QtGui/QLineEdit>
+#include <QtGui/QComboBox>
 #include <QtGui/QPushButton>
 
 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;
index 43efb3a..c31660d 100644 (file)
@@ -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 <igorinov@gmail.com>  Sun, 30 Oct 2011 13:26:06 -0700
 
- -- Ivan Gorinov <igorinov@unknown>  Mon, 27 Jun 2011 22:36:07 -0700
index 9ca1c1d..24f941d 100644 (file)
@@ -1,7 +1,7 @@
 Source: ameter
 Section: user/utilities
 Priority: optional
-Maintainer: Ivan Gorinov <igorinov@yandex.ru>
+Maintainer: Ivan Gorinov <igorinov@gmail.com>
 Build-Depends: debhelper (>= 5), libqt4-dev
 Standards-Version: 3.7.3
 Homepage: http://catori.ru/igorinov/software/ameter/
index 0c5e9be..2f4f576 100644 (file)
@@ -1,17 +1,15 @@
 This package was debianized by Ivan Gorinov <igorinov@unknown> on
 Mon, 27 Jun 2011 22:36:07 -0700.
 
-It was downloaded from <url://example.com>
+It was downloaded from <http://catori.ru/igorinov/software/ameter/>
 
 Upstream Author(s):
 
-    <put author's name and email here>
-    <likewise for another author>
+    Ivan Gorinov <igorinov@gmail.com>
 
 Copyright:
 
-    <Copyright (C) YYYY Name OfAuthor>
-    <likewise for another author>
+    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 <igorinov@unknown> and
+The Debian packaging is (C) 2011, Ivan Gorinov <igorinov@gmail.com> 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.
index 11c0158..b596ba0 100644 (file)
@@ -1 +1 @@
-ameter_0.0.1_armel.deb user/utilities optional
+ameter_1.0.0_armel.deb user/utilities optional
index 6efe040..672c4e2 100644 (file)
@@ -1,15 +1,17 @@
+#include <QtCore/QCoreApplication>
+
 #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 <QtCore/QCoreApplication>
-
 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
 }
+
index 6189ba3..59e8c86 100644 (file)
@@ -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
+