SeekerOfKnowledge
Member
Good day,
I have 64*32 rgb led matrix form www.adafruit.com and have it setup according to the diagram here: https://github.com/pixelmatix/SmartMatrix/blob/master/extras/hardware/SmartMatrixSD_V3.pdf , the micro controller used is the teensy 3.1. I'm trying to create a code in arduino to upload to my teensy then create a gui in Qt so the two can communicate through serial connection. The user would be able to enter a message and it would be scrolled through left to right, with the option to change color and font size, then finally make it wifi using the esp8266ex connected according to the image here: https://www.google.com/search?biw=1....0j0i67k1.0._t3-XW_1Qnc#imgrc=-qo5M5JpQ9gTKM: . I have no clue how to start this any suggestion where to start or if code for this exists that would be very appreciated, I have done some research there is some serial code in the arduino but i'm not sure what Im looking at or if it serves any purpose to what i'm looking for, i'm still an armature. Thank you in advance.
I started the layout in Qt, heres what I have so far:
matrix.pro
#-------------------------------------------------
#
# Project created by QtCreator 2018-02-20T16:33:06
#
#-------------------------------------------------
QT += core gui serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Matrix
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
Widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QString>
#include <QList>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QTextEdit>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QMessageBox>
#include <QIcon>
#include <QComboBox>
#include <QTextEdit>
#include <QLineEdit>
#include <QSlider>
#include <QIntValidator>
#include <QFont>
#include <QByteArray>
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
void enumerateSerPorts(void); // finds all serial ports
public slots: //custom slot methods
void serConnect(void); //connect to serial port
void serDisConnect(void); //disconnects from serial port
void findPorts(void);
private: //added
QSerialPort *serial;
QList<QSerialPortInfo> serinfo;
QHBoxLayout *hbox, *hbox1;
QVBoxLayout *vbox, *vbox1, *vbox2;
QTextEdit *tbox;
QLabel *text;
QPushButton *enumbtn, *conbtn, *disconbtn;
QComboBox *ports;
QLabel *blue2,*blue3,*blue4,*blue5,*blue6,*blue7,*green2,*green3,*green4,*green5,*green6,*green7,*red3,*red4,*red5,*red6,*red7,*red2,*hours,*minutes,*red,*green,*blue,*statuslbl,*brightnesslabel,*alarm,*circleColor,*textColor,*hoursColor,*minutesColor,*secondsColor,*digitalSeperator,*outlinesColor;
QLineEdit *alarm1,*alarm2;
QSlider *brightness1,*circleColor1,*circleColor2,*circleColor3,*textColor1,*textColor2,*textColor3,*hoursColor1,*hoursColor2,*hoursColor3,*minutesColor1,*minutesColor2,*minutesColor3,*secondsColor1,*secondsColor2,*secondsColor3,*digitalSeperator1,*digitalSeperator2,*digitalSeperator3,*outlinesColor1,*outlinesColor2,*outlinesColor3;
QVBoxLayout *vboxbuff,*vboxall,*vboxbrightness,*vboxalarm,*vboxcirclecolor,*vboxtextcolor,*vboxhourscolor,*vboxminutescolor,*vboxsecondscolor,*vboxdigitalseperatorcolor,*vboxoutlinescolor;
QHBoxLayout *rxhbox,*hboxalarmnames,*hboxoutlinescolornames,*hboxdigitalseperatorcolornames,*hboxsecondscolornames,*hboxminutescolornames,*hboxhourscolornames,*hboxtextcolornames,*hboxcirclecolornames,*hboxbtns,*hboxbrightness,*hboxalarm,*hboxcirclecolor,*hboxtextcolor,*hboxhourscolor,*hboxminutescolor,*hboxsecondscolor,*hboxdigitalseperatorcolor,*hboxoutlinescolor;
QIntValidator *int1,*int2;
QFont font_;
QByteArray arr;
};
#endif // WIDGET_H
Widget.cpp
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
hbox = new QHBoxLayout();
hbox1 = new QHBoxLayout();
vbox = new QVBoxLayout();
vbox1 = new QVBoxLayout();
vbox2 = new QVBoxLayout();
text = new QLabel("Enter Text Below:");
enumbtn = new QPushButton("Ports");
conbtn = new QPushButton("Connect");
disconbtn = new QPushButton("Disconnect");
ports = new QComboBox();
tbox = new QTextEdit();
statuslbl = new QLabel(); // Create status label...displys port status
statuslbl->setText("Port: is disconnected");
//colors
conbtn->setStyleSheet("QPushButton {background-color: #00FF7F }");
disconbtn->setStyleSheet("QPushButton {background-color: red}");
enumbtn->setStyleSheet("QPushButton {background-color: #87CEEB}");
ports->setStyleSheet("QComboBox {background-color: #87CEEB}");
hbox->addWidget(enumbtn);
hbox->addWidget(ports);
hbox->addWidget(conbtn);
hbox->addWidget(disconbtn);
vbox->addWidget(text);
vbox-> addWidget(tbox);
vbox1->addLayout(hbox);
vbox1->addLayout(vbox);
setLayout(vbox1);
connect(conbtn,SIGNAL(clicked()),this,SLOT(serConnect()));
connect(disconbtn,SIGNAL(clicked()),this,SLOT(serDisConnect()));
connect(enumbtn,SIGNAL(clicked()), this,SLOT(findPorts()));
}
void Widget::findPorts(void){
enumerateSerPorts();
ports->clear();
for(int i = 0 ; i<serinfo.length();i++){
ports->addItem(serinfo.portName());
}
}
void Widget::enumerateSerPorts(void){
serinfo = QSerialPortInfo::availablePorts();
}
void Widget::serConnect(void){
enumerateSerPorts();// save a list of available ports info in serinfo
if(serinfo.count() == 0){ // if no ports are found...
QMessageBox::warning(this,"Oops!","No Serial Port Found!!!");
}
else{//if at least one port is found...we will use the first port found
serial->setPortName(ports->currentText());//added for ex 5
serial->setPort(serinfo[ports->currentIndex()]);//added for ex 5
if(serial->isOpen())//if port is already open...
QMessageBox::warning(this,"Oops!","Serial port is already open. Please disconnect first");
else{ //if port is available and not open...open it
if (serial->open(QIODevice::ReadWrite) == false){
QMessageBox::warning(this,"Oops!","Failed to open port");
serial->close(); //if opening port failed close it
}
}
}
}
void Widget::serDisConnect(void){
if(serial->isOpen()==false)
QMessageBox::warning(this,"Oops!","Serial port is already closed!");
else{
serial->close(); // close port
statuslbl->setText("Port :" + ports->currentText() + " is disconnected"); //update status label
}
}
Widget::~Widget()
{
}
main.cpp
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
I have 64*32 rgb led matrix form www.adafruit.com and have it setup according to the diagram here: https://github.com/pixelmatix/SmartMatrix/blob/master/extras/hardware/SmartMatrixSD_V3.pdf , the micro controller used is the teensy 3.1. I'm trying to create a code in arduino to upload to my teensy then create a gui in Qt so the two can communicate through serial connection. The user would be able to enter a message and it would be scrolled through left to right, with the option to change color and font size, then finally make it wifi using the esp8266ex connected according to the image here: https://www.google.com/search?biw=1....0j0i67k1.0._t3-XW_1Qnc#imgrc=-qo5M5JpQ9gTKM: . I have no clue how to start this any suggestion where to start or if code for this exists that would be very appreciated, I have done some research there is some serial code in the arduino but i'm not sure what Im looking at or if it serves any purpose to what i'm looking for, i'm still an armature. Thank you in advance.
I started the layout in Qt, heres what I have so far:
matrix.pro
#-------------------------------------------------
#
# Project created by QtCreator 2018-02-20T16:33:06
#
#-------------------------------------------------
QT += core gui serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Matrix
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
Widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QString>
#include <QList>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QTextEdit>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QMessageBox>
#include <QIcon>
#include <QComboBox>
#include <QTextEdit>
#include <QLineEdit>
#include <QSlider>
#include <QIntValidator>
#include <QFont>
#include <QByteArray>
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
void enumerateSerPorts(void); // finds all serial ports
public slots: //custom slot methods
void serConnect(void); //connect to serial port
void serDisConnect(void); //disconnects from serial port
void findPorts(void);
private: //added
QSerialPort *serial;
QList<QSerialPortInfo> serinfo;
QHBoxLayout *hbox, *hbox1;
QVBoxLayout *vbox, *vbox1, *vbox2;
QTextEdit *tbox;
QLabel *text;
QPushButton *enumbtn, *conbtn, *disconbtn;
QComboBox *ports;
QLabel *blue2,*blue3,*blue4,*blue5,*blue6,*blue7,*green2,*green3,*green4,*green5,*green6,*green7,*red3,*red4,*red5,*red6,*red7,*red2,*hours,*minutes,*red,*green,*blue,*statuslbl,*brightnesslabel,*alarm,*circleColor,*textColor,*hoursColor,*minutesColor,*secondsColor,*digitalSeperator,*outlinesColor;
QLineEdit *alarm1,*alarm2;
QSlider *brightness1,*circleColor1,*circleColor2,*circleColor3,*textColor1,*textColor2,*textColor3,*hoursColor1,*hoursColor2,*hoursColor3,*minutesColor1,*minutesColor2,*minutesColor3,*secondsColor1,*secondsColor2,*secondsColor3,*digitalSeperator1,*digitalSeperator2,*digitalSeperator3,*outlinesColor1,*outlinesColor2,*outlinesColor3;
QVBoxLayout *vboxbuff,*vboxall,*vboxbrightness,*vboxalarm,*vboxcirclecolor,*vboxtextcolor,*vboxhourscolor,*vboxminutescolor,*vboxsecondscolor,*vboxdigitalseperatorcolor,*vboxoutlinescolor;
QHBoxLayout *rxhbox,*hboxalarmnames,*hboxoutlinescolornames,*hboxdigitalseperatorcolornames,*hboxsecondscolornames,*hboxminutescolornames,*hboxhourscolornames,*hboxtextcolornames,*hboxcirclecolornames,*hboxbtns,*hboxbrightness,*hboxalarm,*hboxcirclecolor,*hboxtextcolor,*hboxhourscolor,*hboxminutescolor,*hboxsecondscolor,*hboxdigitalseperatorcolor,*hboxoutlinescolor;
QIntValidator *int1,*int2;
QFont font_;
QByteArray arr;
};
#endif // WIDGET_H
Widget.cpp
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
hbox = new QHBoxLayout();
hbox1 = new QHBoxLayout();
vbox = new QVBoxLayout();
vbox1 = new QVBoxLayout();
vbox2 = new QVBoxLayout();
text = new QLabel("Enter Text Below:");
enumbtn = new QPushButton("Ports");
conbtn = new QPushButton("Connect");
disconbtn = new QPushButton("Disconnect");
ports = new QComboBox();
tbox = new QTextEdit();
statuslbl = new QLabel(); // Create status label...displys port status
statuslbl->setText("Port: is disconnected");
//colors
conbtn->setStyleSheet("QPushButton {background-color: #00FF7F }");
disconbtn->setStyleSheet("QPushButton {background-color: red}");
enumbtn->setStyleSheet("QPushButton {background-color: #87CEEB}");
ports->setStyleSheet("QComboBox {background-color: #87CEEB}");
hbox->addWidget(enumbtn);
hbox->addWidget(ports);
hbox->addWidget(conbtn);
hbox->addWidget(disconbtn);
vbox->addWidget(text);
vbox-> addWidget(tbox);
vbox1->addLayout(hbox);
vbox1->addLayout(vbox);
setLayout(vbox1);
connect(conbtn,SIGNAL(clicked()),this,SLOT(serConnect()));
connect(disconbtn,SIGNAL(clicked()),this,SLOT(serDisConnect()));
connect(enumbtn,SIGNAL(clicked()), this,SLOT(findPorts()));
}
void Widget::findPorts(void){
enumerateSerPorts();
ports->clear();
for(int i = 0 ; i<serinfo.length();i++){
ports->addItem(serinfo.portName());
}
}
void Widget::enumerateSerPorts(void){
serinfo = QSerialPortInfo::availablePorts();
}
void Widget::serConnect(void){
enumerateSerPorts();// save a list of available ports info in serinfo
if(serinfo.count() == 0){ // if no ports are found...
QMessageBox::warning(this,"Oops!","No Serial Port Found!!!");
}
else{//if at least one port is found...we will use the first port found
serial->setPortName(ports->currentText());//added for ex 5
serial->setPort(serinfo[ports->currentIndex()]);//added for ex 5
if(serial->isOpen())//if port is already open...
QMessageBox::warning(this,"Oops!","Serial port is already open. Please disconnect first");
else{ //if port is available and not open...open it
if (serial->open(QIODevice::ReadWrite) == false){
QMessageBox::warning(this,"Oops!","Failed to open port");
serial->close(); //if opening port failed close it
}
}
}
}
void Widget::serDisConnect(void){
if(serial->isOpen()==false)
QMessageBox::warning(this,"Oops!","Serial port is already closed!");
else{
serial->close(); // close port
statuslbl->setText("Port :" + ports->currentText() + " is disconnected"); //update status label
}
}
Widget::~Widget()
{
}
main.cpp
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}