From ef885e1a2855bf8de3d44f07451d3c421f0ab5c0 Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Thu, 2 Jun 2016 18:10:52 +0930 Subject: Added feedback for missing presets.txt file, added message box funcrion for user alerts and other misc things --- qt/RGBController/serial_communication.cpp | 58 +++++++++++++++---------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'qt/RGBController/serial_communication.cpp') diff --git a/qt/RGBController/serial_communication.cpp b/qt/RGBController/serial_communication.cpp index 94e75db..ac0fd81 100644 --- a/qt/RGBController/serial_communication.cpp +++ b/qt/RGBController/serial_communication.cpp @@ -7,41 +7,41 @@ 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; + /* 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; + /* this function disconnects from the serial port if it is connected already */ + if (serial.isOpen()) + { + serial.close(); + return true; + } + return false; } void serial_communication::rgb_change(int r, int g, int b) { - /* 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("0" + QString::number(r) + "," + QString::number(g) + "," + QString::number(b) + "\n"); - if (serial.isOpen()) - serial.write(data); + /* 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("0" + QString::number(r) + "," + QString::number(g) + "," + QString::number(b) + "\n"); + if (serial.isOpen()) + serial.write(data); } -- cgit v1.2.3