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.
qtc_packaging/debian_fremantle/control \
qtc_packaging/debian_fremantle/compat \
qtc_packaging/debian_fremantle/changelog
+
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)
return 0;
}
+// This method is called on every update, keep division operations out
+
void AMeterWidget::paintEvent(QPaintEvent *e)
{
QPainter paint(this);
bool AMeterWidget::filter(QAccelerometerReading *reading)
{
+ qreal k = 1;
bx = ax;
by = ay;
bz = az;
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;
}
+
};
#endif // AMETERWIDGET_H
+
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;
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");
setLayout(vbox);
- layout()->setSizeConstraint( QLayout::SetFixedSize );
+ layout()->setSizeConstraint(QLayout::SetFixedSize);
}
SettingsDialog::~SettingsDialog()
{
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();
}
+
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
+#include <QtGui/QComboBox>
#include <QtGui/QPushButton>
class SettingsDialog: public QDialog
QLabel *label;
QLineEdit *editG;
QLineEdit *editMax;
- QLineEdit *editFilter;
+ QComboBox *comboSmoothing;
QLineEdit *editDiv;
QLineEdit *editAngle;
QLineEdit *editRate;
-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
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/
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:
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.
-ameter_0.0.1_armel.deb user/utilities optional
+ameter_1.0.0_armel.deb user/utilities optional
+#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)
{
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);
delete accelerometer;
}
-void MainWindow::changeSettings()
+void MainWindow::showAbout()
+{
+ AboutDialog dialog(this);
+
+ dialog.exec();
+}
+
+void MainWindow::showSettings()
{
SettingsDialog dialog(this);
QSettings settings("igorinov", "ameter", this);
show();
#endif
}
+
void showExpanded();
public slots:
- void changeSettings();
+ void showAbout();
+ void showSettings();
private:
QAccelerometer *accelerometer;
};
#endif // MAINWINDOW_H
+