From f66536d84b38aa0eb46e928fdaf13d7da790b2ee Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Sun, 4 Jun 2017 16:26:56 +0930 Subject: 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 --- qt/RGBController/controllerwindow.cpp | 39 ++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'qt/RGBController/controllerwindow.cpp') 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; -- cgit v1.2.3