summaryrefslogtreecommitdiff
path: root/qt/RGBController
diff options
context:
space:
mode:
Diffstat (limited to 'qt/RGBController')
-rw-r--r--qt/RGBController/Makefile30
-rwxr-xr-xqt/RGBController/RGBControllerbin97400 -> 107032 bytes
-rwxr-xr-xqt/RGBController/RGBController.pro7
-rwxr-xr-xqt/RGBController/RGBController.pro.user2
-rwxr-xr-xqt/RGBController/controllerwindow.cpp335
-rwxr-xr-xqt/RGBController/controllerwindow.h87
-rw-r--r--qt/RGBController/controllerwindow.obin105712 -> 132072 bytes
-rw-r--r--[-rwxr-xr-x]qt/RGBController/controllerwindow.ui18
-rw-r--r--qt/RGBController/main.obin3176 -> 3176 bytes
-rw-r--r--qt/RGBController/moc_controllerwindow.cpp87
-rw-r--r--qt/RGBController/moc_controllerwindow.obin16920 -> 17448 bytes
-rw-r--r--qt/RGBController/moc_predefs.h2
-rwxr-xr-xqt/RGBController/old_src/old.ui430
-rw-r--r--qt/RGBController/old_src/serial.cpp86
-rw-r--r--qt/RGBController/old_src/serial.h32
-rw-r--r--qt/RGBController/old_src/serial_communication.cpp (renamed from qt/RGBController/serial_communication.cpp)8
-rw-r--r--qt/RGBController/old_src/serial_communication.h (renamed from qt/RGBController/serial_communication.h)4
-rw-r--r--qt/RGBController/serial_communication.obin10376 -> 0 bytes
-rw-r--r--qt/RGBController/ui_controllerwindow.h27
19 files changed, 940 insertions, 215 deletions
diff --git a/qt/RGBController/Makefile b/qt/RGBController/Makefile
index efaa9b4..415befe 100644
--- a/qt/RGBController/Makefile
+++ b/qt/RGBController/Makefile
@@ -49,11 +49,9 @@ OBJECTS_DIR = ./
####### Files
SOURCES = main.cpp \
- controllerwindow.cpp \
- serial_communication.cpp moc_controllerwindow.cpp
+ controllerwindow.cpp moc_controllerwindow.cpp
OBJECTS = main.o \
controllerwindow.o \
- serial_communication.o \
moc_controllerwindow.o
DIST = /usr/lib/qt/mkspecs/features/spec_pre.prf \
/usr/lib/qt/mkspecs/common/unix.conf \
@@ -166,6 +164,8 @@ DIST = /usr/lib/qt/mkspecs/features/spec_pre.prf \
/usr/lib/qt/mkspecs/modules/qt_lib_multimediawidgets_private.pri \
/usr/lib/qt/mkspecs/modules/qt_lib_network.pri \
/usr/lib/qt/mkspecs/modules/qt_lib_network_private.pri \
+ /usr/lib/qt/mkspecs/modules/qt_lib_networkauth.pri \
+ /usr/lib/qt/mkspecs/modules/qt_lib_networkauth_private.pri \
/usr/lib/qt/mkspecs/modules/qt_lib_nfc.pri \
/usr/lib/qt/mkspecs/modules/qt_lib_nfc_private.pri \
/usr/lib/qt/mkspecs/modules/qt_lib_opengl.pri \
@@ -276,10 +276,8 @@ DIST = /usr/lib/qt/mkspecs/features/spec_pre.prf \
/usr/lib/qt/mkspecs/features/exceptions.prf \
/usr/lib/qt/mkspecs/features/yacc.prf \
/usr/lib/qt/mkspecs/features/lex.prf \
- RGBController.pro controllerwindow.h \
- serial_communication.h main.cpp \
- controllerwindow.cpp \
- serial_communication.cpp
+ RGBController.pro controllerwindow.h main.cpp \
+ controllerwindow.cpp
QMAKE_TARGET = RGBController
DESTDIR =
TARGET = RGBController
@@ -402,6 +400,8 @@ Makefile: RGBController.pro /usr/lib/qt/mkspecs/linux-g++/qmake.conf /usr/lib/qt
/usr/lib/qt/mkspecs/modules/qt_lib_multimediawidgets_private.pri \
/usr/lib/qt/mkspecs/modules/qt_lib_network.pri \
/usr/lib/qt/mkspecs/modules/qt_lib_network_private.pri \
+ /usr/lib/qt/mkspecs/modules/qt_lib_networkauth.pri \
+ /usr/lib/qt/mkspecs/modules/qt_lib_networkauth_private.pri \
/usr/lib/qt/mkspecs/modules/qt_lib_nfc.pri \
/usr/lib/qt/mkspecs/modules/qt_lib_nfc_private.pri \
/usr/lib/qt/mkspecs/modules/qt_lib_opengl.pri \
@@ -630,6 +630,8 @@ Makefile: RGBController.pro /usr/lib/qt/mkspecs/linux-g++/qmake.conf /usr/lib/qt
/usr/lib/qt/mkspecs/modules/qt_lib_multimediawidgets_private.pri:
/usr/lib/qt/mkspecs/modules/qt_lib_network.pri:
/usr/lib/qt/mkspecs/modules/qt_lib_network_private.pri:
+/usr/lib/qt/mkspecs/modules/qt_lib_networkauth.pri:
+/usr/lib/qt/mkspecs/modules/qt_lib_networkauth_private.pri:
/usr/lib/qt/mkspecs/modules/qt_lib_nfc.pri:
/usr/lib/qt/mkspecs/modules/qt_lib_nfc_private.pri:
/usr/lib/qt/mkspecs/modules/qt_lib_opengl.pri:
@@ -761,8 +763,8 @@ distdir: FORCE
@test -d $(DISTDIR) || mkdir -p $(DISTDIR)
$(COPY_FILE) --parents $(DIST) $(DISTDIR)/
$(COPY_FILE) --parents /usr/lib/qt/mkspecs/features/data/dummy.cpp $(DISTDIR)/
- $(COPY_FILE) --parents controllerwindow.h serial_communication.h $(DISTDIR)/
- $(COPY_FILE) --parents main.cpp controllerwindow.cpp serial_communication.cpp $(DISTDIR)/
+ $(COPY_FILE) --parents controllerwindow.h $(DISTDIR)/
+ $(COPY_FILE) --parents main.cpp controllerwindow.cpp $(DISTDIR)/
$(COPY_FILE) --parents controllerwindow.ui $(DISTDIR)/
@@ -798,8 +800,7 @@ moc_predefs.h: /usr/lib/qt/mkspecs/features/data/dummy.cpp
compiler_moc_header_make_all: moc_controllerwindow.cpp
compiler_moc_header_clean:
-$(DEL_FILE) moc_controllerwindow.cpp
-moc_controllerwindow.cpp: serial_communication.h \
- ui_controllerwindow.h \
+moc_controllerwindow.cpp: ui_controllerwindow.h \
controllerwindow.h \
moc_predefs.h \
/usr/bin/moc
@@ -825,20 +826,13 @@ compiler_clean: compiler_moc_predefs_clean compiler_moc_header_clean compiler_ui
####### Compile
main.o: main.cpp controllerwindow.h \
- serial_communication.h \
ui_controllerwindow.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
controllerwindow.o: controllerwindow.cpp controllerwindow.h \
- serial_communication.h \
ui_controllerwindow.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o controllerwindow.o controllerwindow.cpp
-serial_communication.o: serial_communication.cpp serial_communication.h \
- controllerwindow.h \
- ui_controllerwindow.h
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o serial_communication.o serial_communication.cpp
-
moc_controllerwindow.o: moc_controllerwindow.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_controllerwindow.o moc_controllerwindow.cpp
diff --git a/qt/RGBController/RGBController b/qt/RGBController/RGBController
index 98307b6..318ea1e 100755
--- a/qt/RGBController/RGBController
+++ b/qt/RGBController/RGBController
Binary files differ
diff --git a/qt/RGBController/RGBController.pro b/qt/RGBController/RGBController.pro
index d075466..2496348 100755
--- a/qt/RGBController/RGBController.pro
+++ b/qt/RGBController/RGBController.pro
@@ -13,10 +13,9 @@ TEMPLATE = app
SOURCES += main.cpp\
- controllerwindow.cpp \
- serial_communication.cpp
+ controllerwindow.cpp
-HEADERS += controllerwindow.h \
- serial_communication.h
+
+HEADERS += controllerwindow.h
FORMS += controllerwindow.ui
diff --git a/qt/RGBController/RGBController.pro.user b/qt/RGBController/RGBController.pro.user
index f76531e..5074773 100755
--- a/qt/RGBController/RGBController.pro.user
+++ b/qt/RGBController/RGBController.pro.user
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.1, 2017-02-23T11:02:51. -->
+<!-- Written by QtCreator 4.2.1, 2017-04-05T10:31:13. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
diff --git a/qt/RGBController/controllerwindow.cpp b/qt/RGBController/controllerwindow.cpp
index a0e9b52..cfc2428 100755
--- a/qt/RGBController/controllerwindow.cpp
+++ b/qt/RGBController/controllerwindow.cpp
@@ -4,10 +4,15 @@ controllerWindow::controllerWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::controllerWindow)
{
- /* TODO convert to QStandardPaths::standardLocations(QStandardPaths::AppDataLocation) */
/* this is our setup function, we set things up here */
ui->setupUi(this);
info_log("RGB Controller started");
+ /* serial */
+ ser = new QSerialPort(this);
+ connect(ser, &QSerialPort::readyRead, this, &controllerWindow::read);
+ ptimer = new QTimer(this);
+ connect(ptimer, SIGNAL(timeout()), this, SLOT(ping()));
+ pingtries = 0;
/* disable buttons and widgets that should not be enabled yet, set slider values to 0 */
ui->disconnect_button->setEnabled(false);
ui->connect_button->setEnabled(false);
@@ -27,32 +32,32 @@ controllerWindow::controllerWindow(QWidget *parent) :
ui->r_slider->setValue(0);
ui->g_slider->setValue(0);
ui->b_slider->setValue(0);
- ui->red_fade_button->setEnabled(false);
- ui->green_fade_button->setEnabled(false);
- ui->blue_fade_button->setEnabled(false);
- ui->speed_button->setEnabled(false);
- ui->rfrom->setEnabled(false);
- ui->rto->setEnabled(false);
- ui->gfrom->setEnabled(false);
- ui->gto->setEnabled(false);
- ui->bfrom->setEnabled(false);
- ui->bto->setEnabled(false);
- ui->r_speed_slider->setEnabled(false);
- ui->g_speed_slider->setEnabled(false);
- ui->b_speed_slider->setEnabled(false);
- ui->speed_slider->setEnabled(false);
- ui->r_speed_slider->setValue(0);
- ui->g_speed_slider->setValue(0);
- ui->b_speed_slider->setValue(0);
- ui->speed_slider->setValue(0);
- ui->rfrom->setValue(0);
- ui->rto->setValue(0);
- ui->gfrom->setValue(0);
- ui->gto->setValue(0);
- ui->bfrom->setValue(0);
- ui->bto->setValue(0);
- presetsfile = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/presets.txt";
- tempfile = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/tmp.file";
+ ui->red_fade_button->setEnabled(false);
+ ui->green_fade_button->setEnabled(false);
+ ui->blue_fade_button->setEnabled(false);
+ ui->speed_button->setEnabled(false);
+ ui->rfrom->setEnabled(false);
+ ui->rto->setEnabled(false);
+ ui->gfrom->setEnabled(false);
+ ui->gto->setEnabled(false);
+ ui->bfrom->setEnabled(false);
+ ui->bto->setEnabled(false);
+ ui->r_speed_slider->setEnabled(false);
+ ui->g_speed_slider->setEnabled(false);
+ ui->b_speed_slider->setEnabled(false);
+ ui->speed_slider->setEnabled(false);
+ ui->r_speed_slider->setValue(0);
+ ui->g_speed_slider->setValue(0);
+ ui->b_speed_slider->setValue(0);
+ ui->speed_slider->setValue(0);
+ ui->rfrom->setValue(100);
+ ui->rto->setValue(255);
+ ui->gfrom->setValue(100);
+ ui->gto->setValue(255);
+ ui->bfrom->setValue(100);
+ ui->bto->setValue(255);
+ presetsfile = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/presets.txt";
+ tempfile = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/tmp.file";
/* set some crucial ints */
preset_index = 0, r = 0, g = 0, b = 0;
/* populate our serial port dropdown box */
@@ -111,7 +116,7 @@ void controllerWindow::load_presets()
* -> add [0] to dropdown (name), add [1] to an array that stores all the values
*/
- QFile inputFile(presetsfile);
+ QFile inputFile(presetsfile);
if (inputFile.open(QIODevice::ReadOnly))
{
QTextStream in(&inputFile);
@@ -128,7 +133,7 @@ void controllerWindow::load_presets()
info_log("Presets loaded");
} else
{
- show_msgbox("Unable to load the presets file.\n");
+ show_msgbox("Unable to load the presets file.\n");
info_log("Presets file not found.");
}
}
@@ -136,9 +141,9 @@ void controllerWindow::load_presets()
void controllerWindow::save_preset(QString name)
{
/* this function will save our preset to file */
- if (!QDir("Folder").exists())
- QDir().mkdir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
- QFile file(presetsfile);
+ if (!QDir("Folder").exists())
+ QDir().mkdir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
+ QFile file(presetsfile);
if(!file.open(QIODevice::Append)) {
show_msgbox("Fatal error opening presets for appending text.");
@@ -160,7 +165,7 @@ void controllerWindow::delete_preset(QString name)
{
/*
* here we will delete a preset from the presets file
- * process:
+ * process:
* retrieve preset name
* go through preset file line by line and write it to a seperate tmp file
* if the [0] of split('=') equals the preset name, don't write it to the tmp file
@@ -172,8 +177,8 @@ void controllerWindow::delete_preset(QString name)
{
case QMessageBox::Ok:
{
- info_log("deleting preset: " + name);
- QFile file(tempfile);
+ info_log("deleting preset: " + name);
+ QFile file(tempfile);
if(!file.open(QIODevice::Append)) {
show_msgbox("Fatal error opening temp file for writing");
@@ -190,8 +195,8 @@ void controllerWindow::delete_preset(QString name)
}
file.close();
/* remove the current presets file then rename the temp file to presets.txt */
- QFile::remove(presetsfile);
- QFile::rename(tempfile, presetsfile);
+ QFile::remove(presetsfile);
+ QFile::rename(tempfile, presetsfile);
/* reload presets into memory and clear the drop down box */
ui->presets_dropdown->clear();
presets.clear();
@@ -213,8 +218,8 @@ void controllerWindow::delete_preset(QString name)
void controllerWindow::serial_rgb_change(int r, int g, int b)
{
- /* un used function */
- portf.rgb_change(r, g, b);
+ /* un used function */
+ rgb_change(r, g, b);
}
void controllerWindow::show_msgbox(QString message)
@@ -243,13 +248,14 @@ int controllerWindow::show_question_box(QString message, QString omessage)
void controllerWindow::on_connect_button_clicked()
{
- /*
+ /*
* here we need to call our serial port connect function
* if our connection is sucessful we need to enable and disable a few buttons and widgets
* we must also change our rgb sliders etc
*/
+ pingtries = 0;
port = ui->arduino_port_dropdown->currentText();
- if (portf.serial_connect(port))
+ if (serial_connect(port))
{ // if true we are connected
info_log("Connection established");
ui->arduino_status_label->setText("<font color=green>Connected</font>");
@@ -271,20 +277,21 @@ void controllerWindow::on_connect_button_clicked()
ui->b_slider->setEnabled(true);
ui->refresh_port_button->setEnabled(false);
ui->arduino_port_dropdown->setEnabled(false);
- ui->red_fade_button->setEnabled(true);
- ui->green_fade_button->setEnabled(true);
- ui->blue_fade_button->setEnabled(true);
- ui->speed_button->setEnabled(true);
- ui->rfrom->setEnabled(true);
- ui->rto->setEnabled(true);
- ui->gfrom->setEnabled(true);
- ui->gto->setEnabled(true);
- ui->bfrom->setEnabled(true);
- ui->bto->setEnabled(true);
- ui->r_speed_slider->setEnabled(true);
- ui->g_speed_slider->setEnabled(true);
- ui->b_speed_slider->setEnabled(true);
- ui->speed_slider->setEnabled(true);
+ ui->red_fade_button->setEnabled(true);
+ ui->green_fade_button->setEnabled(true);
+ ui->blue_fade_button->setEnabled(true);
+ ui->speed_button->setEnabled(true);
+ ui->rfrom->setEnabled(true);
+ ui->rto->setEnabled(true);
+ ui->gfrom->setEnabled(true);
+ ui->gto->setEnabled(true);
+ ui->bfrom->setEnabled(true);
+ ui->bto->setEnabled(true);
+ ui->r_speed_slider->setEnabled(true);
+ ui->g_speed_slider->setEnabled(true);
+ ui->b_speed_slider->setEnabled(true);
+ ui->speed_slider->setEnabled(true);
+ ptimer->start(60000);
} else
{
info_log("Unable to connect (port in use?)");
@@ -298,7 +305,7 @@ void controllerWindow::on_disconnect_button_clicked()
* here we will attempt to disconnect from our serial port
* we will also enable/disable some buttons and widgets and set slider values to 0
*/
- if (portf.serial_disconnect())
+ if (serial_disconnect())
{
info_log("Disconnected from serial port");
ui->arduino_status_label->setText("<font color=red>Disconnected</font>");
@@ -322,30 +329,30 @@ void controllerWindow::on_disconnect_button_clicked()
ui->r_slider->setValue(0);
ui->g_slider->setValue(0);
ui->b_slider->setValue(0);
- ui->red_fade_button->setEnabled(false);
- ui->green_fade_button->setEnabled(false);
- ui->blue_fade_button->setEnabled(false);
- ui->speed_button->setEnabled(false);
- ui->rfrom->setEnabled(false);
- ui->rto->setEnabled(false);
- ui->gfrom->setEnabled(false);
- ui->gto->setEnabled(false);
- ui->bfrom->setEnabled(false);
- ui->bto->setEnabled(false);
- ui->r_speed_slider->setEnabled(false);
- ui->g_speed_slider->setEnabled(false);
- ui->b_speed_slider->setEnabled(false);
- ui->speed_slider->setEnabled(false);
- ui->r_speed_slider->setValue(0);
- ui->g_speed_slider->setValue(0);
- ui->b_speed_slider->setValue(0);
- ui->speed_slider->setValue(0);
- ui->rfrom->setValue(0);
- ui->rto->setValue(0);
- ui->gfrom->setValue(0);
- ui->gto->setValue(0);
- ui->bfrom->setValue(0);
- ui->bto->setValue(0);
+ ui->red_fade_button->setEnabled(false);
+ ui->green_fade_button->setEnabled(false);
+ ui->blue_fade_button->setEnabled(false);
+ ui->speed_button->setEnabled(false);
+ ui->rfrom->setEnabled(false);
+ ui->rto->setEnabled(false);
+ ui->gfrom->setEnabled(false);
+ ui->gto->setEnabled(false);
+ ui->bfrom->setEnabled(false);
+ ui->bto->setEnabled(false);
+ ui->r_speed_slider->setEnabled(false);
+ ui->g_speed_slider->setEnabled(false);
+ ui->b_speed_slider->setEnabled(false);
+ ui->speed_slider->setEnabled(false);
+ ui->r_speed_slider->setValue(0);
+ ui->g_speed_slider->setValue(0);
+ ui->b_speed_slider->setValue(0);
+ ui->speed_slider->setValue(0);
+ ui->rfrom->setValue(100);
+ ui->rto->setValue(255);
+ ui->gfrom->setValue(100);
+ ui->gto->setValue(255);
+ ui->bfrom->setValue(100);
+ ui->bto->setValue(255);
} else
{
/* I have no clue how we'd get here */
@@ -369,22 +376,22 @@ void controllerWindow::on_reload_preset_button_clicked()
void controllerWindow::on_r_slider_valueChanged(int value)
{
r = value;
- //serial_rgb_change(r, g, b);
- portf.send("red=" + QString::number(r));
+ //serial_rgb_change(r, g, b);
+ send("red=" + QString::number(r));
}
void controllerWindow::on_g_slider_valueChanged(int value)
{
g = value;
- //serial_rgb_change(r, g, b);
- portf.send("green=" + QString::number(g));
+ //serial_rgb_change(r, g, b);
+ send("green=" + QString::number(g));
}
void controllerWindow::on_b_slider_valueChanged(int value)
{
b = value;
- //serial_rgb_change(r, g, b);
- portf.send("blue=" + QString::number(b));
+ //serial_rgb_change(r, g, b);
+ send("blue=" + QString::number(b));
}
void controllerWindow::on_red_button_clicked()
@@ -410,9 +417,9 @@ void controllerWindow::on_blue_button_clicked()
void controllerWindow::on_off_button_clicked()
{
- ui->r_slider->setValue(1);
- ui->g_slider->setValue(1);
- ui->b_slider->setValue(1);
+ ui->r_slider->setValue(1);
+ ui->g_slider->setValue(1);
+ ui->b_slider->setValue(1);
ui->r_slider->setValue(0);
ui->g_slider->setValue(0);
ui->b_slider->setValue(0);
@@ -460,68 +467,186 @@ void controllerWindow::on_preset_delete_button_clicked()
void controllerWindow::on_red_fade_button_clicked()
{
- portf.send("redfade");
+ send("redfade");
}
void controllerWindow::on_green_fade_button_clicked()
{
- portf.send("greenfade");
+ send("greenfade");
}
void controllerWindow::on_blue_fade_button_clicked()
{
- portf.send("bluefade");
+ send("bluefade");
}
void controllerWindow::on_speed_button_clicked()
{
- portf.send("speed=" + QString::number(ui->speed_slider->value()));
+ send("speed=" + QString::number(ui->speed_slider->value()));
}
void controllerWindow::on_r_speed_slider_valueChanged(int value)
{
- portf.send("rspeed=" + QString::number(value));
+ send("rspeed=" + QString::number(value));
}
void controllerWindow::on_g_speed_slider_valueChanged(int value)
{
- portf.send("gspeed=" + QString::number(value));
+ send("gspeed=" + QString::number(value));
}
void controllerWindow::on_b_speed_slider_valueChanged(int value)
{
- portf.send("bspeed=" + QString::number(value));
+ send("bspeed=" + QString::number(value));
}
void controllerWindow::on_rfrom_valueChanged(int arg1)
{
- portf.send("rf=" + QString::number(arg1));
- ui->r_slider->setValue(arg1);
+ send("rf=" + QString::number(arg1));
+ //ui->r_slider->setValue(arg1);
}
void controllerWindow::on_rto_valueChanged(int arg1)
{
- portf.send("rt=" + QString::number(arg1));
+ send("rt=" + QString::number(arg1));
}
void controllerWindow::on_gfrom_valueChanged(int arg1)
{
- portf.send("gf=" + QString::number(arg1));
- ui->g_slider->setValue(arg1);
+ send("gf=" + QString::number(arg1));
+ //ui->g_slider->setValue(arg1);
}
void controllerWindow::on_gto_valueChanged(int arg1)
{
-portf.send("gt=" + QString::number(arg1));
+ send("gt=" + QString::number(arg1));
}
void controllerWindow::on_bfrom_valueChanged(int arg1)
{
- portf.send("bf=" + QString::number(arg1));
- ui->b_slider->setValue(arg1);
+ send("bf=" + QString::number(arg1));
+ //ui->b_slider->setValue(arg1);
}
void controllerWindow::on_bto_valueChanged(int arg1)
{
- portf.send("bt=" + QString::number(arg1));
+ send("bt=" + QString::number(arg1));
+}
+
+bool controllerWindow::serial_connect(QString port)
+{
+ /* this function will attempt a ser.connection if we are not already connected */
+ if (!ser->isOpen())
+ {
+ ser->setPortName(port);
+ ser->setBaudRate(QSerialPort::Baud9600);
+ ser->setDataBits(QSerialPort::Data8);
+ ser->setParity(QSerialPort::NoParity);
+ ser->setStopBits(QSerialPort::OneStop);
+ ser->setFlowControl(QSerialPort::NoFlowControl);
+ ser->open(QIODevice::ReadWrite);
+ ser->waitForBytesWritten(9000);
+ if (ser->isWritable()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool controllerWindow::serial_disconnect()
+{
+ /* this function disconnects from the serial port if it is connected already */
+ if (ser->isOpen())
+ {
+ ser->close();
+ ptimer->stop();
+ return true;
+ }
+ return false;
+}
+
+void controllerWindow::send(QString com)
+{
+ data = "";
+ //qDebug() << com;
+ data.append(com + "\n");
+ if (ser->isOpen())
+ ser->write(data);
+}
+
+void controllerWindow::rgb_change(int r, int g, int b)
+{
+ // NOT USED FUNCTION
+
+ /* here we send our rgb values to the serial port */
+ data = "";
+ /* the 0 is a hack, i need to look into it at some point */
+ data.append("red=" + QString::number(r) + "," + QString::number(g) + "," + QString::number(b) + "\n");
+ if (ser->isOpen())
+ ser->write(data);
+}
+
+void controllerWindow::read()
+{
+ if (serdata[serdata.size() - 1] == '\n')
+ {
+ parse(QString(serdata));
+ serdata = "";
+ }
+ else
+ serdata = serdata + ser->readAll();
+}
+
+void controllerWindow::parse(QString message)
+{
+ qDebug() << message;
+ if (message.contains("="))
+ {
+ QString command = message.split("=")[0].remove(QRegExp("[\\n\\t\\r]"));
+ QString text = message.split("=")[1].remove(QRegExp("[\\n\\t\\r]"));
+ if (command == "msgbox")
+ show_msgbox(text);
+ if (command == "ping")
+ {
+ qDebug() << "pong from arduino";
+ tping = true;
+ }
+ }
+}
+
+void controllerWindow::on_serial_send_button_clicked()
+{
+ send(ui->serial_input->text());
+}
+// timer after ping send, if the timer timeout()'s, disconnect, claim no connection
+void controllerWindow::ping()
+{
+ qDebug() << "sending ping";
+ send("ping\n");
+ tping = false;
+ QTimer::singleShot(1000, this, SLOT(check_ping()));
+}
+
+void controllerWindow::check_ping()
+{
+ if (tping)
+ {
+ qDebug() << "connection fine";
+ tping = false;
+ pingtries = 0;
+ }
+ else
+ {
+ if (pingtries >= 3)
+ {
+ qDebug() << "connection lost";
+ on_disconnect_button_clicked();
+ show_msgbox("Disconnected from Arduino.\nNo ping response after 3 tries.");
+ }
+ else
+ {
+ pingtries++;
+ qDebug() << "no ping response try" << pingtries;
+ }
+ }
}
diff --git a/qt/RGBController/controllerwindow.h b/qt/RGBController/controllerwindow.h
index 0997e82..1fed07e 100755
--- a/qt/RGBController/controllerwindow.h
+++ b/qt/RGBController/controllerwindow.h
@@ -6,12 +6,13 @@
#include <QMainWindow>
#include <QDebug>
#include <QFile>
+#include <QSerialPort>
#include <QSerialPortInfo>
#include <QTextStream>
#include <QMessageBox>
#include <QStandardPaths>
#include <QDir>
-#include "serial_communication.h"
+#include <QTimer>
#include "ui_controllerwindow.h"
namespace Ui {
@@ -25,7 +26,6 @@ class controllerWindow : public QMainWindow
public:
explicit controllerWindow(QWidget *parent = 0);
~controllerWindow();
-
/* public functions */
void info_log(QString text);
void populate_serial_list();
@@ -34,6 +34,12 @@ class controllerWindow : public QMainWindow
void delete_preset(QString name);
void serial_rgb_change(int r, int g, int b);
void show_msgbox(QString message);
+ bool serial_connect(QString port);
+ bool serial_disconnect();
+ void rgb_change(int r, int g, int b);
+ void send(QString com);
+ void parse(QString message);
+ void read();
int show_question_box(QString message, QString omessage);
/*public variables */
/* these three ints will hold the current value (0 - 255) of each slider */
@@ -44,71 +50,80 @@ class controllerWindow : public QMainWindow
QString port;
/* this int will contain the current preset index selected */
int preset_index;
- QString presetsfile;
- QString tempfile;
+ QString presetsfile;
+ QString tempfile;
+ QString port_name;
+ QSerialPort *ser;
+ QByteArray data;
+ QByteArray serdata;
+ QTimer *ptimer;
+ bool tping;
+ int pingtries;
private slots:
/* these slots are used to trigger button clicks and drop down items selections etc */
- void on_connect_button_clicked();
+ void on_connect_button_clicked();
+
+ void on_disconnect_button_clicked();
+
+ void on_refresh_port_button_clicked();
+
+ void on_reload_preset_button_clicked();
- void on_disconnect_button_clicked();
-
- void on_refresh_port_button_clicked();
+ void on_r_slider_valueChanged(int value);
- void on_reload_preset_button_clicked();
-
- void on_r_slider_valueChanged(int value);
+ void on_g_slider_valueChanged(int value);
- void on_g_slider_valueChanged(int value);
+ void on_b_slider_valueChanged(int value);
- void on_b_slider_valueChanged(int value);
+ void on_red_button_clicked();
- void on_red_button_clicked();
+ void on_green_button_clicked();
- void on_green_button_clicked();
+ void on_blue_button_clicked();
- void on_blue_button_clicked();
+ void on_off_button_clicked();
- void on_off_button_clicked();
+ void on_set_preset_button_clicked();
- void on_set_preset_button_clicked();
+ void on_presets_dropdown_currentIndexChanged(int index);
- void on_presets_dropdown_currentIndexChanged(int index);
+ void on_preset_save_button_clicked();
- void on_preset_save_button_clicked();
+ void on_preset_delete_button_clicked();
- void on_preset_delete_button_clicked();
+ void on_red_fade_button_clicked();
- void on_red_fade_button_clicked();
+ void on_green_fade_button_clicked();
- void on_green_fade_button_clicked();
+ void on_blue_fade_button_clicked();
- void on_blue_fade_button_clicked();
+ void on_speed_button_clicked();
- void on_speed_button_clicked();
+ void on_r_speed_slider_valueChanged(int value);
- void on_r_speed_slider_valueChanged(int value);
+ void on_g_speed_slider_valueChanged(int value);
- void on_g_speed_slider_valueChanged(int value);
+ void on_b_speed_slider_valueChanged(int value);
- void on_b_speed_slider_valueChanged(int value);
+ void on_rfrom_valueChanged(int arg1);
- void on_rfrom_valueChanged(int arg1);
+ void on_rto_valueChanged(int arg1);
- void on_rto_valueChanged(int arg1);
+ void on_gfrom_valueChanged(int arg1);
- void on_gfrom_valueChanged(int arg1);
+ void on_gto_valueChanged(int arg1);
- void on_gto_valueChanged(int arg1);
+ void on_bfrom_valueChanged(int arg1);
- void on_bfrom_valueChanged(int arg1);
+ void on_bto_valueChanged(int arg1);
- void on_bto_valueChanged(int arg1);
+ void on_serial_send_button_clicked();
+ void ping();
+ void check_ping();
private:
Ui::controllerWindow *ui;
- /* serial communication object */
- serial_communication portf;
};
#endif // CONTROLLERWINDOW_H
diff --git a/qt/RGBController/controllerwindow.o b/qt/RGBController/controllerwindow.o
index e17bfd6..99fc93f 100644
--- a/qt/RGBController/controllerwindow.o
+++ b/qt/RGBController/controllerwindow.o
Binary files differ
diff --git a/qt/RGBController/controllerwindow.ui b/qt/RGBController/controllerwindow.ui
index ca1d807..837abf2 100755..100644
--- a/qt/RGBController/controllerwindow.ui
+++ b/qt/RGBController/controllerwindow.ui
@@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>232</width>
+ <width>238</width>
<height>629</height>
</rect>
</property>
@@ -53,6 +53,9 @@
</property>
</widget>
</item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="arduino_port_dropdown"/>
+ </item>
<item row="0" column="1">
<widget class="QLabel" name="arduino_status_label">
<property name="text">
@@ -60,9 +63,6 @@
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QComboBox" name="arduino_port_dropdown"/>
- </item>
<item row="7" column="0">
<widget class="QSlider" name="b_slider">
<property name="minimumSize">
@@ -403,6 +403,16 @@
</property>
</widget>
</item>
+ <item row="21" column="1">
+ <widget class="QPushButton" name="serial_send_button">
+ <property name="text">
+ <string>Send</string>
+ </property>
+ </widget>
+ </item>
+ <item row="21" column="0">
+ <widget class="QLineEdit" name="serial_input"/>
+ </item>
</layout>
</widget>
</widget>
diff --git a/qt/RGBController/main.o b/qt/RGBController/main.o
index 8ace6c4..c77f1fa 100644
--- a/qt/RGBController/main.o
+++ b/qt/RGBController/main.o
Binary files differ
diff --git a/qt/RGBController/moc_controllerwindow.cpp b/qt/RGBController/moc_controllerwindow.cpp
index 3b9dff9..0603691 100644
--- a/qt/RGBController/moc_controllerwindow.cpp
+++ b/qt/RGBController/moc_controllerwindow.cpp
@@ -21,8 +21,8 @@ QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_controllerWindow_t {
- QByteArrayData data[33];
- char stringdata0[777];
+ QByteArrayData data[36];
+ char stringdata0[823];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
@@ -63,7 +63,10 @@ QT_MOC_LITERAL(28, 673, 19), // "on_rto_valueChanged"
QT_MOC_LITERAL(29, 693, 21), // "on_gfrom_valueChanged"
QT_MOC_LITERAL(30, 715, 19), // "on_gto_valueChanged"
QT_MOC_LITERAL(31, 735, 21), // "on_bfrom_valueChanged"
-QT_MOC_LITERAL(32, 757, 19) // "on_bto_valueChanged"
+QT_MOC_LITERAL(32, 757, 19), // "on_bto_valueChanged"
+QT_MOC_LITERAL(33, 777, 29), // "on_serial_send_button_clicked"
+QT_MOC_LITERAL(34, 807, 4), // "ping"
+QT_MOC_LITERAL(35, 812, 10) // "check_ping"
},
"controllerWindow\0on_connect_button_clicked\0"
@@ -89,7 +92,8 @@ QT_MOC_LITERAL(32, 757, 19) // "on_bto_valueChanged"
"on_rfrom_valueChanged\0arg1\0"
"on_rto_valueChanged\0on_gfrom_valueChanged\0"
"on_gto_valueChanged\0on_bfrom_valueChanged\0"
- "on_bto_valueChanged"
+ "on_bto_valueChanged\0on_serial_send_button_clicked\0"
+ "ping\0check_ping"
};
#undef QT_MOC_LITERAL
@@ -99,7 +103,7 @@ static const uint qt_meta_data_controllerWindow[] = {
7, // revision
0, // classname
0, 0, // classinfo
- 28, 14, // methods
+ 31, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
@@ -107,34 +111,37 @@ static const uint qt_meta_data_controllerWindow[] = {
0, // signalCount
// slots: name, argc, parameters, tag, flags
- 1, 0, 154, 2, 0x08 /* Private */,
- 3, 0, 155, 2, 0x08 /* Private */,
- 4, 0, 156, 2, 0x08 /* Private */,
- 5, 0, 157, 2, 0x08 /* Private */,
- 6, 1, 158, 2, 0x08 /* Private */,
- 8, 1, 161, 2, 0x08 /* Private */,
- 9, 1, 164, 2, 0x08 /* Private */,
- 10, 0, 167, 2, 0x08 /* Private */,
- 11, 0, 168, 2, 0x08 /* Private */,
- 12, 0, 169, 2, 0x08 /* Private */,
- 13, 0, 170, 2, 0x08 /* Private */,
- 14, 0, 171, 2, 0x08 /* Private */,
- 15, 1, 172, 2, 0x08 /* Private */,
- 17, 0, 175, 2, 0x08 /* Private */,
- 18, 0, 176, 2, 0x08 /* Private */,
- 19, 0, 177, 2, 0x08 /* Private */,
- 20, 0, 178, 2, 0x08 /* Private */,
- 21, 0, 179, 2, 0x08 /* Private */,
- 22, 0, 180, 2, 0x08 /* Private */,
- 23, 1, 181, 2, 0x08 /* Private */,
- 24, 1, 184, 2, 0x08 /* Private */,
- 25, 1, 187, 2, 0x08 /* Private */,
- 26, 1, 190, 2, 0x08 /* Private */,
- 28, 1, 193, 2, 0x08 /* Private */,
- 29, 1, 196, 2, 0x08 /* Private */,
- 30, 1, 199, 2, 0x08 /* Private */,
- 31, 1, 202, 2, 0x08 /* Private */,
- 32, 1, 205, 2, 0x08 /* Private */,
+ 1, 0, 169, 2, 0x08 /* Private */,
+ 3, 0, 170, 2, 0x08 /* Private */,
+ 4, 0, 171, 2, 0x08 /* Private */,
+ 5, 0, 172, 2, 0x08 /* Private */,
+ 6, 1, 173, 2, 0x08 /* Private */,
+ 8, 1, 176, 2, 0x08 /* Private */,
+ 9, 1, 179, 2, 0x08 /* Private */,
+ 10, 0, 182, 2, 0x08 /* Private */,
+ 11, 0, 183, 2, 0x08 /* Private */,
+ 12, 0, 184, 2, 0x08 /* Private */,
+ 13, 0, 185, 2, 0x08 /* Private */,
+ 14, 0, 186, 2, 0x08 /* Private */,
+ 15, 1, 187, 2, 0x08 /* Private */,
+ 17, 0, 190, 2, 0x08 /* Private */,
+ 18, 0, 191, 2, 0x08 /* Private */,
+ 19, 0, 192, 2, 0x08 /* Private */,
+ 20, 0, 193, 2, 0x08 /* Private */,
+ 21, 0, 194, 2, 0x08 /* Private */,
+ 22, 0, 195, 2, 0x08 /* Private */,
+ 23, 1, 196, 2, 0x08 /* Private */,
+ 24, 1, 199, 2, 0x08 /* Private */,
+ 25, 1, 202, 2, 0x08 /* Private */,
+ 26, 1, 205, 2, 0x08 /* Private */,
+ 28, 1, 208, 2, 0x08 /* Private */,
+ 29, 1, 211, 2, 0x08 /* Private */,
+ 30, 1, 214, 2, 0x08 /* Private */,
+ 31, 1, 217, 2, 0x08 /* Private */,
+ 32, 1, 220, 2, 0x08 /* Private */,
+ 33, 0, 223, 2, 0x08 /* Private */,
+ 34, 0, 224, 2, 0x08 /* Private */,
+ 35, 0, 225, 2, 0x08 /* Private */,
// slots: parameters
QMetaType::Void,
@@ -165,6 +172,9 @@ static const uint qt_meta_data_controllerWindow[] = {
QMetaType::Void, QMetaType::Int, 27,
QMetaType::Void, QMetaType::Int, 27,
QMetaType::Void, QMetaType::Int, 27,
+ QMetaType::Void,
+ QMetaType::Void,
+ QMetaType::Void,
0 // eod
};
@@ -203,6 +213,9 @@ void controllerWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int
case 25: _t->on_gto_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 26: _t->on_bfrom_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 27: _t->on_bto_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
+ case 28: _t->on_serial_send_button_clicked(); break;
+ case 29: _t->ping(); break;
+ case 30: _t->check_ping(); break;
default: ;
}
}
@@ -233,13 +246,13 @@ int controllerWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
- if (_id < 28)
+ if (_id < 31)
qt_static_metacall(this, _c, _id, _a);
- _id -= 28;
+ _id -= 31;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
- if (_id < 28)
+ if (_id < 31)
*reinterpret_cast<int*>(_a[0]) = -1;
- _id -= 28;
+ _id -= 31;
}
return _id;
}
diff --git a/qt/RGBController/moc_controllerwindow.o b/qt/RGBController/moc_controllerwindow.o
index 4cb2317..b5aef42 100644
--- a/qt/RGBController/moc_controllerwindow.o
+++ b/qt/RGBController/moc_controllerwindow.o
Binary files differ
diff --git a/qt/RGBController/moc_predefs.h b/qt/RGBController/moc_predefs.h
index 68884ac..f7a843b 100644
--- a/qt/RGBController/moc_predefs.h
+++ b/qt/RGBController/moc_predefs.h
@@ -131,7 +131,7 @@
#define __DBL_HAS_DENORM__ 1
#define __UINT8_TYPE__ unsigned char
#define __FLT_MANT_DIG__ 24
-#define __VERSION__ "6.3.1 20170109"
+#define __VERSION__ "6.3.1 20170306"
#define __UINT64_C(c) c ## UL
#define __cpp_unicode_characters 200704
#define _STDC_PREDEF_H 1
diff --git a/qt/RGBController/old_src/old.ui b/qt/RGBController/old_src/old.ui
new file mode 100755
index 0000000..f05209e
--- /dev/null
+++ b/qt/RGBController/old_src/old.ui
@@ -0,0 +1,430 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>controllerWindow</class>
+ <widget class="QMainWindow" name="controllerWindow">
+ <property name="windowModality">
+ <enum>Qt::WindowModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>325</width>
+ <height>686</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>RGB Controller</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="22" column="1">
+ <widget class="QPushButton" name="preset_delete_button">
+ <property name="text">
+ <string>Delete</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QSlider" name="g_slider">
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>120</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QPushButton" name="connect_button">
+ <property name="text">
+ <string>Connect</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QSlider" name="r_slider">
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>120</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="21" column="0">
+ <widget class="QLineEdit" name="preset_name_textbox"/>
+ </item>
+ <item row="19" column="0">
+ <widget class="QSlider" name="g_speed_slider">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>500</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QPushButton" name="red_button">
+ <property name="text">
+ <string>Red</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="arduino_port_dropdown"/>
+ </item>
+ <item row="14" column="0">
+ <widget class="QPushButton" name="speed_button">
+ <property name="text">
+ <string>Speed</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="rgb_label">
+ <property name="text">
+ <string>RGB colors</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0">
+ <widget class="QSlider" name="b_slider">
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>120</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="15" column="0">
+ <widget class="QSlider" name="b_speed_slider">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>500</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="1">
+ <widget class="QPushButton" name="set_preset_button">
+ <property name="text">
+ <string>Set</string>
+ </property>
+ </widget>
+ </item>
+ <item row="12" column="0">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="5" column="0">
+ <widget class="QSpinBox" name="bfrom">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="fade_label">
+ <property name="text">
+ <string>Fade</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QSpinBox" name="rfrom">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="3">
+ <widget class="QPushButton" name="blue_fade_button">
+ <property name="text">
+ <string>Blue toggle</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QPushButton" name="red_fade_button">
+ <property name="text">
+ <string>Red toggle</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="r_to_label">
+ <property name="text">
+ <string>to</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QSpinBox" name="gfrom">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="3">
+ <widget class="QPushButton" name="green_fade_button">
+ <property name="text">
+ <string>Green toggle</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="QSpinBox" name="bto">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="value">
+ <number>255</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QSpinBox" name="gto">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="value">
+ <number>255</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLabel" name="_to_label">
+ <property name="text">
+ <string>to</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="g_to_label">
+ <property name="text">
+ <string>to</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QSpinBox" name="rto">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="value">
+ <number>255</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="9" column="0">
+ <widget class="QLabel" name="presets_label">
+ <property name="text">
+ <string>Presets</string>
+ </property>
+ </widget>
+ </item>
+ <item row="23" column="0">
+ <widget class="QTextEdit" name="info_log_textarea"/>
+ </item>
+ <item row="3" column="1">
+ <widget class="QPushButton" name="disconnect_button">
+ <property name="text">
+ <string>Disconnect</string>
+ </property>
+ </widget>
+ </item>
+ <item row="20" column="0">
+ <widget class="QLabel" name="r_speed_label">
+ <property name="text">
+ <string>Red speed</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="arduino_port_label">
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Arduino port</string>
+ </property>
+ </widget>
+ </item>
+ <item row="18" column="0">
+ <widget class="QLabel" name="b_speed_label">
+ <property name="text">
+ <string>Blue speed</string>
+ </property>
+ </widget>
+ </item>
+ <item row="17" column="0">
+ <widget class="QSlider" name="speed_slider">
+ <property name="minimum">
+ <number>10</number>
+ </property>
+ <property name="maximum">
+ <number>500</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="arduino_status_label">
+ <property name="text">
+ <string>&lt;font color = red&gt;Disconnected&lt;/font&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="1">
+ <widget class="QPushButton" name="off_button">
+ <property name="text">
+ <string>Off</string>
+ </property>
+ </widget>
+ </item>
+ <item row="16" column="0">
+ <widget class="QSlider" name="r_speed_slider">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>500</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="status_label">
+ <property name="text">
+ <string>Status</string>
+ </property>
+ </widget>
+ </item>
+ <item row="21" column="1">
+ <widget class="QPushButton" name="preset_save_button">
+ <property name="text">
+ <string>Save</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="0">
+ <widget class="QComboBox" name="presets_dropdown">
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1">
+ <widget class="QPushButton" name="blue_button">
+ <property name="text">
+ <string>Blue</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QPushButton" name="refresh_port_button">
+ <property name="text">
+ <string>Refresh</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QPushButton" name="green_button">
+ <property name="text">
+ <string>Green</string>
+ </property>
+ </widget>
+ </item>
+ <item row="11" column="0">
+ <widget class="QPushButton" name="reload_preset_button">
+ <property name="text">
+ <string>Reload</string>
+ </property>
+ </widget>
+ </item>
+ <item row="22" column="0">
+ <widget class="QLabel" name="info_log_label">
+ <property name="text">
+ <string>Information log</string>
+ </property>
+ </widget>
+ </item>
+ <item row="13" column="0">
+ <widget class="QLabel" name="g_speed_label">
+ <property name="text">
+ <string>Green speed</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/qt/RGBController/old_src/serial.cpp b/qt/RGBController/old_src/serial.cpp
new file mode 100644
index 0000000..f3f4f1e
--- /dev/null
+++ b/qt/RGBController/old_src/serial.cpp
@@ -0,0 +1,86 @@
+#include "serial.h"
+#include "controllerwindow.h"
+serial::serial(QObject *parent) : QObject(parent)
+{
+ ser = new QSerialPort(this);
+ connect(ser, &QSerialPort::readyRead, this, &serial::read);
+
+}
+
+bool serial::serial_connect(QString port)
+{
+ /* this function will attempt a ser.connection if we are not already connected */
+ if (!ser->isOpen())
+ {
+ ser->setPortName(port);
+ ser->setBaudRate(QSerialPort::Baud9600);
+ ser->setDataBits(QSerialPort::Data8);
+ ser->setParity(QSerialPort::NoParity);
+ ser->setStopBits(QSerialPort::OneStop);
+ ser->setFlowControl(QSerialPort::NoFlowControl);
+ ser->open(QIODevice::ReadWrite);
+ ser->waitForBytesWritten(9000);
+ if (ser->isWritable()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool serial::serial_disconnect()
+{
+ /* this function disconnects from the serial port if it is connected already */
+ if (ser->isOpen())
+ {
+ ser->close();
+ return true;
+ }
+ return false;
+}
+
+void serial::send(QString com)
+{
+ data = "";
+ //qDebug() << com;
+ data.append(com + "\n");
+ if (ser->isOpen())
+ ser->write(data);
+}
+
+void serial::rgb_change(int r, int g, int b)
+{
+ // NOT USED FUNCTION
+
+ /* here we send our rgb values to the serial port */
+ data = "";
+ /* the 0 is a hack, i need to look into it at some point */
+ data.append("red=" + QString::number(r) + "," + QString::number(g) + "," + QString::number(b) + "\n");
+ if (ser->isOpen())
+ ser->write(data);
+}
+
+void serial::read()
+{
+ if (serdata[serdata.size() - 1] != '\n')
+ serdata = serdata + ser->readAll();
+ if (serdata[serdata.size() - 1] == '\n')
+ {
+ qDebug() << "got data" << serdata;
+ parse(QString(serdata));
+ serdata = "";
+ }
+}
+
+void serial::parse(QString message)
+{
+ if (message.contains("="))
+ {
+ QString command = message.split("=")[0];
+ QString text = message.split("=")[1];
+ qDebug() << "command:" << command << "message:" << text;
+
+// win->info_log(text);
+ //((controllerWindow*)(parent()))->info_log("tesT");
+
+ }
+}
diff --git a/qt/RGBController/old_src/serial.h b/qt/RGBController/old_src/serial.h
new file mode 100644
index 0000000..6403887
--- /dev/null
+++ b/qt/RGBController/old_src/serial.h
@@ -0,0 +1,32 @@
+#ifndef SERIAL_H
+#define SERIAL_H
+
+#include <QObject>
+#include <QSerialPort>
+#include <QSerialPortInfo>
+#include <QDebug>
+
+class serial : public QObject
+{
+ Q_OBJECT
+ public:
+ explicit serial(QObject *parent = 0);
+
+
+ /* function declares */
+ bool serial_connect(QString port);
+ bool serial_disconnect();
+ void rgb_change(int r, int g, int b);
+ void send(QString com);
+ void parse(QString message);
+ /* variables */
+ QString port_name;
+ //QSerialPort ser;
+ QSerialPort *ser;
+ QByteArray data;
+ QByteArray serdata;
+ private slots:
+ void read();
+};
+
+#endif // SERIAL_H
diff --git a/qt/RGBController/serial_communication.cpp b/qt/RGBController/old_src/serial_communication.cpp
index f8bd66a..32d4863 100644
--- a/qt/RGBController/serial_communication.cpp
+++ b/qt/RGBController/old_src/serial_communication.cpp
@@ -1,8 +1,9 @@
#include "serial_communication.h"
#include "controllerwindow.h"
+
serial_communication::serial_communication()
{
-
+ qDebug() << "serial test";
}
bool serial_communication::serial_connect(QString port)
@@ -56,3 +57,8 @@ void serial_communication::rgb_change(int r, int g, int b)
if (serial.isOpen())
serial.write(data);
}
+
+void serial_communication::read()
+{
+ qDebug() << "serial read";
+}
diff --git a/qt/RGBController/serial_communication.h b/qt/RGBController/old_src/serial_communication.h
index 3499028..5f2826c 100644
--- a/qt/RGBController/serial_communication.h
+++ b/qt/RGBController/old_src/serial_communication.h
@@ -15,11 +15,13 @@ class serial_communication
bool serial_connect(QString port);
bool serial_disconnect();
void rgb_change(int r, int g, int b);
- void send(QString com);
+ void send(QString com);
/* variables */
QString port_name;
QSerialPort serial;
QByteArray data;
+ private slots:
+ void read();
};
#endif // SERIAL_COMMUNICATION_H
diff --git a/qt/RGBController/serial_communication.o b/qt/RGBController/serial_communication.o
deleted file mode 100644
index 03987dd..0000000
--- a/qt/RGBController/serial_communication.o
+++ /dev/null
Binary files differ
diff --git a/qt/RGBController/ui_controllerwindow.h b/qt/RGBController/ui_controllerwindow.h
index 5c2c857..02fed42 100644
--- a/qt/RGBController/ui_controllerwindow.h
+++ b/qt/RGBController/ui_controllerwindow.h
@@ -37,8 +37,8 @@ public:
QPushButton *preset_delete_button;
QLabel *presets_label;
QPushButton *disconnect_button;
- QLabel *arduino_status_label;
QComboBox *arduino_port_dropdown;
+ QLabel *arduino_status_label;
QSlider *b_slider;
QSlider *b_speed_slider;
QTextEdit *info_log_textarea;
@@ -78,13 +78,15 @@ public:
QLabel *b_speed_label;
QPushButton *speed_button;
QSlider *speed_slider;
+ QPushButton *serial_send_button;
+ QLineEdit *serial_input;
void setupUi(QMainWindow *controllerWindow)
{
if (controllerWindow->objectName().isEmpty())
controllerWindow->setObjectName(QStringLiteral("controllerWindow"));
controllerWindow->setWindowModality(Qt::WindowModal);
- controllerWindow->resize(232, 629);
+ controllerWindow->resize(238, 629);
centralWidget = new QWidget(controllerWindow);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
gridLayout_2 = new QGridLayout(centralWidget);
@@ -116,16 +118,16 @@ public:
gridLayout_2->addWidget(disconnect_button, 3, 1, 1, 1);
- arduino_status_label = new QLabel(centralWidget);
- arduino_status_label->setObjectName(QStringLiteral("arduino_status_label"));
-
- gridLayout_2->addWidget(arduino_status_label, 0, 1, 1, 1);
-
arduino_port_dropdown = new QComboBox(centralWidget);
arduino_port_dropdown->setObjectName(QStringLiteral("arduino_port_dropdown"));
gridLayout_2->addWidget(arduino_port_dropdown, 1, 1, 1, 1);
+ arduino_status_label = new QLabel(centralWidget);
+ arduino_status_label->setObjectName(QStringLiteral("arduino_status_label"));
+
+ gridLayout_2->addWidget(arduino_status_label, 0, 1, 1, 1);
+
b_slider = new QSlider(centralWidget);
b_slider->setObjectName(QStringLiteral("b_slider"));
b_slider->setMinimumSize(QSize(120, 0));
@@ -354,6 +356,16 @@ public:
gridLayout_2->addWidget(speed_slider, 18, 0, 1, 1);
+ serial_send_button = new QPushButton(centralWidget);
+ serial_send_button->setObjectName(QStringLiteral("serial_send_button"));
+
+ gridLayout_2->addWidget(serial_send_button, 21, 1, 1, 1);
+
+ serial_input = new QLineEdit(centralWidget);
+ serial_input->setObjectName(QStringLiteral("serial_input"));
+
+ gridLayout_2->addWidget(serial_input, 21, 0, 1, 1);
+
controllerWindow->setCentralWidget(centralWidget);
retranslateUi(controllerWindow);
@@ -392,6 +404,7 @@ public:
arduino_port_label->setText(QApplication::translate("controllerWindow", "Arduino port", Q_NULLPTR));
b_speed_label->setText(QApplication::translate("controllerWindow", "Blue speed", Q_NULLPTR));
speed_button->setText(QApplication::translate("controllerWindow", "Speed", Q_NULLPTR));
+ serial_send_button->setText(QApplication::translate("controllerWindow", "Send", Q_NULLPTR));
} // retranslateUi
};