summaryrefslogtreecommitdiff
path: root/qt/RGBController/serial_communication.cpp
diff options
context:
space:
mode:
authordaniel-Jones <daniel@danieljon.es>2017-04-07 09:17:10 +0930
committerdaniel-Jones <daniel@danieljon.es>2017-04-07 09:17:10 +0930
commit9ff573e9fe4c40ffb342ce2b215042c39b518aeb (patch)
treee4168caacbb934b072da417275ea578d26229db6 /qt/RGBController/serial_communication.cpp
parent1189c8c2671b2463dbca7842a81adfe00c35549c (diff)
downloadRGB-Controller-9ff573e9fe4c40ffb342ce2b215042c39b518aeb.tar.gz
RGB-Controller-9ff573e9fe4c40ffb342ce2b215042c39b518aeb.zip
Merged source into one .cpp and .h. Added serial communication from the Arduino to the host computer. Added ping/pong system to maintain a connection, once 3 failed tries have occured, the connection is force closed, this restores the ui to a desired state. A ping is sent every 60 seconds and a response is required within one second. Some debug UI additions and code is still present, to be removed.
Diffstat (limited to 'qt/RGBController/serial_communication.cpp')
-rw-r--r--qt/RGBController/serial_communication.cpp58
1 files changed, 0 insertions, 58 deletions
diff --git a/qt/RGBController/serial_communication.cpp b/qt/RGBController/serial_communication.cpp
deleted file mode 100644
index f8bd66a..0000000
--- a/qt/RGBController/serial_communication.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#include "serial_communication.h"
-#include "controllerwindow.h"
-serial_communication::serial_communication()
-{
-
-}
-
-bool serial_communication::serial_connect(QString port)
-{
- /* this function will attempt a serial connection if we are not already connected */
- if (!serial.isOpen())
- {
- serial.setPortName(port);
- serial.setBaudRate(QSerialPort::Baud9600);
- serial.setDataBits(QSerialPort::Data8);
- serial.setParity(QSerialPort::NoParity);
- serial.setStopBits(QSerialPort::OneStop);
- serial.setFlowControl(QSerialPort::NoFlowControl);
- serial.open(QIODevice::ReadWrite);
- serial.waitForBytesWritten(9000);
- if (serial.isWritable()) {
- return true;
- }
- }
- return false;
-}
-
-bool serial_communication::serial_disconnect()
-{
- /* this function disconnects from the serial port if it is connected already */
- if (serial.isOpen())
- {
- serial.close();
- return true;
- }
- return false;
-}
-
-void serial_communication::send(QString com)
-{
- data = "";
- //qDebug() << com;
- data.append(com + "\n");
- if (serial.isOpen())
- serial.write(data);
-}
-
-void serial_communication::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 (serial.isOpen())
- serial.write(data);
-}