summaryrefslogtreecommitdiff
path: root/qt/RGBController/controllerwindow.cpp
diff options
context:
space:
mode:
authordaniel-Jones <daniel@danieljon.es>2017-06-04 16:26:56 +0930
committerdaniel-Jones <daniel@danieljon.es>2017-06-04 16:26:56 +0930
commitf66536d84b38aa0eb46e928fdaf13d7da790b2ee (patch)
treeba2624354136f3f0db3ec929d1eea15635527ba1 /qt/RGBController/controllerwindow.cpp
parent2ce2f6376152402c3fc0d750720770b963a7d3cf (diff)
downloadRGB-Controller-f66536d84b38aa0eb46e928fdaf13d7da790b2ee.tar.gz
RGB-Controller-f66536d84b38aa0eb46e928fdaf13d7da790b2ee.zip
added HTML/JS/PHP pages/scripts to allow RGB changes over a web page. Integrated a server into the application to allow incoming connections and receive commands
Diffstat (limited to 'qt/RGBController/controllerwindow.cpp')
-rwxr-xr-xqt/RGBController/controllerwindow.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/qt/RGBController/controllerwindow.cpp b/qt/RGBController/controllerwindow.cpp
index 7c4f552..dd21ece 100755
--- a/qt/RGBController/controllerwindow.cpp
+++ b/qt/RGBController/controllerwindow.cpp
@@ -12,9 +12,12 @@ controllerWindow::controllerWindow(QWidget *parent) :
connect(ser, &QSerialPort::readyRead, this, &controllerWindow::read);
ptimer = new QTimer(this);
connect(ptimer, SIGNAL(timeout()), this, SLOT(ping()));
- connect (&ircbot, SIGNAL(sendcmd(QString)), this, SLOT(cmdrecv(QString)));
+ connect(&ircbot, SIGNAL(sendcmd(QString)), this, SLOT(cmdrecv(QString)));
+ connect(&srv, SIGNAL(sendcmd(QString)), this, SLOT(cmdrecv(QString)));
pingtries = 0;
irccon = false;
+ pingcount = 0;
+ server_started = false;
/* 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);
@@ -413,6 +416,7 @@ void controllerWindow::on_off_button_clicked()
ui->r_slider->setValue(0);
ui->g_slider->setValue(0);
ui->b_slider->setValue(0);
+ send("off");
}
void controllerWindow::on_set_preset_button_clicked()
@@ -616,6 +620,8 @@ void controllerWindow::ping()
send("ping\n");
tping = false;
QTimer::singleShot(1000, this, SLOT(check_ping()));
+ pingcount++;
+ ui->ping_count_label->setText("Ping: " + QString::number(pingcount));
}
void controllerWindow::check_ping()
@@ -658,6 +664,37 @@ void controllerWindow::on_irc_connect_button_clicked()
}
}
+void controllerWindow::on_server_start_button_clicked()
+{
+ if (!server_started)
+ {
+ if (srv.server_start())
+ {
+ server_started = true;
+ ui->server_start_button->setText("Stop server");
+ info_log("Server started");
+ }
+ else
+ {
+ info_log("Server could not start");
+ }
+ }
+
+ else if (server_started)
+ {
+ if (srv.server_stop())
+ {
+ server_started = false;
+ ui->server_start_button->setText("Start server");
+ info_log("Server stopped");
+ }
+ else
+ {
+ info_log("Server not not be stopped");
+ }
+ }
+}
+
void controllerWindow::cmdrecv(QString cmd)
{
qDebug() << "got cmd" << cmd;