//#define QIODEVICE_DEBUG
-char const *LivingDevice::serialports[] = {"/dev/ttyUSB0", "/dev/ttyUSB1", "/dev/ttyUSB2", "/dev/ttyUSB3", "/dev/ttyUSB4"};
+char const *LivingDevice::serialports[] = {"/dev/ttyUSB0", "/dev/ttyUSB1", "/dev/ttyUSB2", "/dev/ttyUSB3", "/dev/ttyUSB4", "/dev/ttyUSB5"};
bool LivingDevice::usedports[] = {false, false, false, false, false};
LivingDevice::LivingDevice(QString name, int timeout)
void LivingDevice::discover(QString name, int timeout)
{
qDebug() << "Discovering" << name;
- for (int i = 0 ; i < 5 && !serialPort ; i++)
+ for (int i = 0 ; i < 6 && !serialPort ; i++)
{
if (usedports[i])
continue;
}
else
{
- qDebug() << "Not" << name;
+ qDebug() << "Found " << answer << ", not" << name;
closeSerialPort();
}
}
Force::Force(QWidget *parent) :
QMainWindow(parent),
- ui(new Ui::Fullscreen)
+ ui(new Ui::Fullscreen),
+ _origin(false)
{
ui->setupUi(this);
setWindowState(Qt::WindowMaximized);
if (!menu->getMouse())
qDebug() << "Warning: mouse not connected";
else
- menu->getMouse()->moveTo(500, 500);
+ menu->getMouse()->moveTo(1500, 700);
}
Force::~Force()
{
MenuPrincipal * menu = dynamic_cast<MenuPrincipal *>(this->parent());
if (menu->getMouse())
- menu->getMouse()->moveTo(0, 0);
+ {
+ if (_origin)
+ menu->getMouse()->moveTo(1500, 700);
+ else
+ menu->getMouse()->moveTo(0, 0);
+
+ _origin = !_origin;
+ }
}
private:
Ui::Fullscreen *ui;
QGraphicsScene _background;
+ bool _origin;
};
#endif // FORCE_H
{
unsigned int x = menu->getMouse()->getX();
unsigned int y = menu->getMouse()->getY();
- menu->getMouse()->moveTo(x, y - 100);
- menu->getMouse()->moveTo(x + 50, y - 100);
+ menu->getMouse()->moveTo(x, y - 200);
+ menu->getMouse()->moveTo(x + 100, y - 200);
}
}
{
unsigned int x = menu->getMouse()->getX();
unsigned int y = menu->getMouse()->getY();
- menu->getMouse()->moveTo(x, y + 100);
- menu->getMouse()->moveTo(x + 50, y + 50);
+ menu->getMouse()->moveTo(x, y + 200);
menu->getMouse()->moveTo(x + 100, y + 100);
- menu->getMouse()->moveTo(x + 100, y);
+ menu->getMouse()->moveTo(x + 200, y + 200);
+ menu->getMouse()->moveTo(x + 200, y);
}
}
{
unsigned int x = menu->getMouse()->getX();
unsigned int y = menu->getMouse()->getY();
- menu->getMouse()->moveTo(x, y + 100);
- menu->getMouse()->moveTo(x + 50, y);
- menu->getMouse()->moveTo(x + 50, y + 100);
+ menu->getMouse()->moveTo(x, y + 200);
+ menu->getMouse()->moveTo(x + 100, y);
+ menu->getMouse()->moveTo(x + 100, y + 200);
}
}
{
unsigned int x = menu->getMouse()->getX();
unsigned int y = menu->getMouse()->getY();
- menu->getMouse()->moveTo(x, y - 100);
- menu->getMouse()->movearc(x + 50, y - 100, -180);
- menu->getMouse()->moveTo(x + 100, y);
+ menu->getMouse()->moveTo(x, y - 200);
+ menu->getMouse()->movearc(x + 100, y - 200, -180);
+ menu->getMouse()->moveTo(x + 200, y);
}
}
GestureOutput.cpp \
Peephole.cpp \
LargeView.cpp \
- ScreenRotate.cpp
+ ScreenRotate.cpp \
+ ScreenRotationControl.cpp
HEADERS += MenuPrincipal.h \
Options.h \
GestureOutput.h \
Peephole.h \
LargeView.h \
- ScreenRotate.h
+ ScreenRotate.h \
+ ScreenRotationControl.h
FORMS += menuprincipal.ui \
options.ui \
fullscreen.ui \
- gestureoutput.ui
+ gestureoutput.ui \
+ screenrotationcontrol.ui
{
Peephole *p= new Peephole(this);
p->show();
- QTimer::singleShot(Peephole::updatedelay, p, SLOT(updatescreenpos()));
+ QTimer::singleShot(Peephole::_updatedelay, p, SLOT(updatescreenpos()));
}
void MenuPrincipal::openScreenRotate()
{
ScreenRotate *s = new ScreenRotate(this);
s->show();
+ QTimer::singleShot(ScreenRotate::_updatedelay, s, SLOT(updatescreenangle()));
}
#include <QThread>
#include <QTimer>
-const int Peephole::updatedelay = 100;
+const int Peephole::_updatedelay = 100;
Peephole::Peephole(QWidget *parent) :
QMainWindow(parent),
- screenpos(330),
- previousscreenpos(330),
- viewpos(0),
+ _screenpos(330),
+ _previousscreenpos(330),
+ _viewpos(0),
ui(new Ui::Fullscreen)
{
ui->setupUi(this);
ui->image->setScene(&_background);
QPixmap back("../../images/panorama.jpg");
_background.addPixmap(back);
- bgwidth = back.width();
+ _bgwidth = back.width();
ui->image->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->image->setDragMode(QGraphicsView::ScrollHandDrag);
ui->image->setResizeAnchor(QGraphicsView::AnchorViewCenter);
if (!menu->getScreen())
qDebug() << "Warning: screen not connected";
else
- rackwidth = menu->getScreen()->getWidth();
+ _rackwidth = menu->getScreen()->getWidth();
}
Peephole::~Peephole()
// prevents flooding the device
void Peephole::updatescreenpos()
{
- if (screenpos != previousscreenpos)
+ if (_screenpos != _previousscreenpos)
{
MenuPrincipal * menu = dynamic_cast<MenuPrincipal *>(this->parent());
if (menu->getScreen())
{
- menu->getScreen()->moveto(screenpos);
- previousscreenpos = screenpos;
+ menu->getScreen()->moveto(_screenpos);
+ _previousscreenpos = _screenpos;
}
}
- QTimer::singleShot(updatedelay, this, SLOT(updatescreenpos()));
+ QTimer::singleShot(_updatedelay, this, SLOT(updatescreenpos()));
}
void Peephole::scroll(int pos)
unsigned int range = ui->image->horizontalScrollBar()->maximum() - min;
if (range == 0)
return;
- unsigned int dest = rackwidth * pos / range - min;
- screenpos = dest;
+ unsigned int dest = _rackwidth * pos / range - min;
+ _screenpos = dest;
}
public:
explicit Peephole(QWidget *parent = 0);
~Peephole();
- static const int updatedelay;
+ static const int _updatedelay;
public slots:
void updatescreenpos();
void scroll(int pos);
private:
- int screenpos, previousscreenpos, viewpos;
- unsigned int rackwidth, bgwidth;
+ int _screenpos, _previousscreenpos, _viewpos;
+ unsigned int _rackwidth, _bgwidth;
Ui::Fullscreen *ui;
QGraphicsScene _background;
};
#include "ScreenRotate.h"
#include <QDebug>
-#include <MenuPrincipal.h>
#include <QGraphicsPixmapItem>
+#include <QTimer>
+
+#include <MenuPrincipal.h>
+
+const int ScreenRotate::_updatedelay = 500;
ScreenRotate::ScreenRotate(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Fullscreen),
- _window(NULL)
+ _window(NULL),
+ _screenangle(0),
+ _previousscreenangle(0)
{
ui->setupUi(this);
setWindowState(Qt::WindowMaximized);
connect(ui->appbutton2, SIGNAL(clicked()), this, SLOT(setupCalendar()));
connect(ui->appbutton3, SIGNAL(clicked()), this, SLOT(setupEmails()));
+ _rotationcontrol = new ScreenRotationControl(this->centralWidget());
+ connect(_rotationcontrol, SIGNAL(update(int)), this, SLOT(rotateScreen(int)));
+ _rotationcontrol->show();
+ //_rotationcontrol->raise();
+
MenuPrincipal * menu = dynamic_cast<MenuPrincipal *>(parent);
if (!menu->getScreen())
qDebug() << "Warning: screen not connected";
ScreenRotate::~ScreenRotate()
{
+ delete _rotationcontrol;
delete ui;
}
+// allows asynchronous udate
+// prevents flooding the device
+void ScreenRotate::updatescreenangle()
+{
+ if (_screenangle != _previousscreenangle)
+ {
+ MenuPrincipal * menu = dynamic_cast<MenuPrincipal *>(this->parent());
+ if (menu->getScreen())
+ {
+ menu->getScreen()->rotation(_screenangle);
+ _previousscreenangle = _screenangle;
+ }
+ }
+ QTimer::singleShot(_updatedelay, this, SLOT(updatescreenangle()));
+}
+
void ScreenRotate::rotateScreen()
{
MenuPrincipal * menu = dynamic_cast<MenuPrincipal *>(this->parent());
}
}
+void ScreenRotate::rotateScreen(int v)
+{
+ _screenangle = v;
+}
+
void ScreenRotate::setupEmails()
{
if (_window)
#include <QGraphicsScene>
#include <ui_fullscreen.h>
+#include <ScreenRotationControl.h>
namespace Ui {
class Fullscreen;
+ class ScreenRotationControl;
}
class ScreenRotate : public QMainWindow
explicit ScreenRotate(QWidget *parent = 0);
~ScreenRotate();
+ static const int _updatedelay;
+
public slots:
void rotateScreen();
+ void rotateScreen(int v);
void setupEmails();
void setupPresentation();
void setupCalendar();
+ void updatescreenangle();
private:
Ui::Fullscreen *ui;
+ ScreenRotationControl *_rotationcontrol;
QGraphicsScene _background;
QGraphicsPixmapItem *_window;
+ int _screenangle, _previousscreenangle;
bool _straight;
};
--- /dev/null
+#include "ScreenRotationControl.h"
+#include "ui_screenrotationcontrol.h"
+
+#include <QDebug>
+
+ScreenRotationControl::ScreenRotationControl(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::ScreenRotationControl)
+{
+ ui->setupUi(this);
+
+ connect(ui->screenangle, SIGNAL(valueChanged(int)), this, SLOT(transmitvalue(int)));
+ connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close()));
+}
+
+ScreenRotationControl::~ScreenRotationControl()
+{
+ delete ui;
+}
+
+void ScreenRotationControl::transmitvalue(int v)
+{
+ emit update(v);
+}
--- /dev/null
+#ifndef SCREENROTATIONCONTROL_H
+#define SCREENROTATIONCONTROL_H
+
+#include <QDialog>
+
+namespace Ui {
+ class ScreenRotationControl;
+}
+
+class ScreenRotationControl : public QDialog
+{
+ Q_OBJECT
+
+ public:
+ explicit ScreenRotationControl(QWidget *parent = 0);
+ ~ScreenRotationControl();
+
+ signals:
+ void update(int);
+
+ private slots:
+ void transmitvalue(int);
+
+ private:
+ Ui::ScreenRotationControl *ui;
+};
+
+#endif // SCREENROTATIONCONTROL_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ScreenRotationControl</class>
+ <widget class="QDialog" name="ScreenRotationControl">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>240</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Screen angular position</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="screenangle">
+ <property name="maximum">
+ <number>180</number>
+ </property>
+ <property name="singleStep">
+ <number>10</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksBothSides</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Close</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>