From 72826655cacd22aaf12c2c1c3030c35014e061cd Mon Sep 17 00:00:00 2001 From: Ivan Gorinov Date: Mon, 31 Oct 2011 21:05:48 -0700 Subject: [PATCH] Deleted irrelevant files --- ameterwidget-dbus.cpp | 183 ------------------------------------------------- ameterwidget-dbus.h | 51 -------------- 2 files changed, 234 deletions(-) delete mode 100644 ameterwidget-dbus.cpp delete mode 100644 ameterwidget-dbus.h diff --git a/ameterwidget-dbus.cpp b/ameterwidget-dbus.cpp deleted file mode 100644 index 446fc96..0000000 --- a/ameterwidget-dbus.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include -#include - -#include - -#include "ameterwidget.h" - -#define SET_IM_STATUS 1 - -AMeterWidget::AMeterWidget(QWidget *parent) - : QWidget(parent) -{ - // Reciprocal of gravity - rg = 1.0 / G_N; -// timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(tick())); -// timer->start(250); - image = 0; - - ax = 0; - ay = 0; - az = 0; - - bx = 0; - by = 0; - bz = 0; - - status = 2; - telepathist = new Telepathist(this); - tt = 0; - - m_sensor = new QAccelerometer(this); - m_sensor->addFilter(this); - m_sensor->start(); -} - -AMeterWidget::~AMeterWidget() -{ - -} - -void AMeterWidget::paintEvent(QPaintEvent *e) -{ - QPainter paint(this); - qreal cx, cy, rx, ry; - qreal x1, y1, a; - - a = sqrt(ax * ax + ay * ay + az * az); - - if (image) - { - paint.drawImage(QPoint(0, 0), *image); - } - - paint.setRenderHints(QPainter::Antialiasing); - - cx = width() / 2; - cy = height() / 2; - rx = cy / 2; - ry = cy / 2; - - x1 = cx - ax * rx; - y1 = cy + ay * ry; - - paint.setPen(QPen(QBrush(QColor(255, 255, 255, 255)), 1)); - paint.setBrush(QBrush(QColor(255, 255, 255, 255))); - paint.drawEllipse(QPointF(x1, y1), 3, 3); - paint.drawLine(QPointF(cx, cy), QPointF(x1, y1)); -} - -void AMeterWidget::resizeEvent(QResizeEvent *e) -{ - QPainter *paint; - qreal cx, cy, rx, ry; - - if (image) - { - delete image; - image = 0; - } - - image = new QImage(size(), QImage::Format_ARGB32); - paint = new QPainter(image); - paint->setRenderHints(QPainter::Antialiasing); - - cx = width() / 2; - cy = height() / 2; - rx = cy / 2; - ry = cy / 2; - - paint->setPen(QPen(QBrush(QColor(64, 64, 64, 255)), 3)); - - paint->drawLine(QPointF(cx, 0), QPointF(cx, cy + cy)); - paint->drawLine(QPointF(0, cy), QPointF(cx + cx, cy)); - - paint->drawEllipse(QPointF(cx, cy), rx, ry); - paint->drawEllipse(QPointF(cx, cy), 2 * rx, 2 * ry); - paint->drawEllipse(QPointF(cx, cy), 3 * rx, 3 * ry); - paint->drawEllipse(QPointF(cx, cy), 4 * rx, 4 * ry); - - paint->setPen(QPen(QBrush(QColor(64, 64, 64, 255)), 1)); - - paint->drawLine(QPointF(cx - cx, cy + cx), QPointF(cx + cx, cy - cx)); - paint->drawLine(QPointF(cx - cx, cy - cx), QPointF(cx + cx, cy + cx)); - - paint->drawEllipse(QPointF(cx, cy), 0.25 * rx, 0.25 * ry); - paint->drawEllipse(QPointF(cx, cy), 0.50 * rx, 0.50 * ry); - paint->drawEllipse(QPointF(cx, cy), 0.75 * rx, 0.75 * ry); - - paint->drawEllipse(QPointF(cx, cy), 1.25 * rx, 1.25 * ry); - paint->drawEllipse(QPointF(cx, cy), 1.50 * rx, 1.50 * ry); - paint->drawEllipse(QPointF(cx, cy), 1.75 * rx, 1.75 * ry); - - paint->drawEllipse(QPointF(cx, cy), 2.25 * rx, 2.25 * ry); - paint->drawEllipse(QPointF(cx, cy), 2.50 * rx, 2.50 * ry); - paint->drawEllipse(QPointF(cx, cy), 2.75 * rx, 2.75 * ry); - - - paint->drawEllipse(QPointF(cx, cy), 3.25 * rx, 3.25 * ry); - paint->drawEllipse(QPointF(cx, cy), 3.50 * rx, 3.50 * ry); - paint->drawEllipse(QPointF(cx, cy), 3.75 * rx, 3.75 * ry); - - delete paint; -} - -bool AMeterWidget::filter(QAccelerometerReading *reading) -{ - ax = reading->x() * rg; - ay = reading->y() * rg; - az = reading->z() * rg; - - update(); - - return true; -} - -void AMeterWidget::tick() -{ - char strbuf[128]; - int x, y, z; - QFile *f; - - bx = ax; - by = ay; - bz = az; - - f = new QFile("/sys/class/i2c-adapter/i2c-3/3-001d/coord"); - if (f->open(QFile::ReadOnly)) - { - f->read(strbuf, 127); - if (sscanf(strbuf, "%d %d %d", &x, &y, &z) == 3) - { - ax = x * 0.001; - ay = y * 0.001; - az = z * 0.001; - } - } - delete f; - -#ifdef SET_IM_STATUS - - if (fabs(ax - bx) > 0.125 || fabs(ay - by) > 0.125 || fabs(az - bz) > 0.125) - { - tt = 0; - if (status != 2) - { - telepathist->setStatus(2, "available", "In the pocket"); - status = 0; - } - } else { - tt++; - } - - if (tt == 480) - { - telepathist->setStatus(3, "away", "Fishing"); - status = 3; - } - -#endif - - update(); -} diff --git a/ameterwidget-dbus.h b/ameterwidget-dbus.h deleted file mode 100644 index 5c09c13..0000000 --- a/ameterwidget-dbus.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef AMETERWIDGET_H -#define AMETERWIDGET_H - -#include -#include - -#include - -/* -#include -#include -*/ - -// Neccessary for Qt Mobility API usage -QTM_USE_NAMESPACE - -#include "telepathist.h" - -#define G_N 9.80665 - -class AMeterWidget : public QWidget, public QAccelerometerFilter -{ - Q_OBJECT - -public: - AMeterWidget(QWidget *parent = 0); - ~AMeterWidget(); - -public slots: - void tick(); - virtual bool filter(QAccelerometerReading *reading); - -protected: - virtual void paintEvent(QPaintEvent *); - virtual void resizeEvent(QResizeEvent *); - - QTimer *timer; - QImage *image; - - qreal ax, ay, az; - qreal bx, by, bz; - unsigned status; - Telepathist *telepathist; - unsigned tt; - -private: - QAccelerometer* m_sensor; - qreal rg; -}; - -#endif // AMETERWIDGET_H -- 1.7.9.5