Packets are shown on screen

This commit is contained in:
Ollo 2023-08-17 21:51:03 +02:00
parent 536779910e
commit c5bfaa2a4a
4 changed files with 21 additions and 12 deletions

View File

@ -11,15 +11,8 @@ MainWindow::MainWindow(QWidget *parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->server = new UdpLedServer ();
this->mOffscreenPanel = new QImage(DEFAULT_WIDTH + LED_DISTANCE, DEFAULT_HEIGHT + LED_DISTANCE, QImage::Format_RGB32);
for(int x=0; x < (PANEL_WIDTH * MAXIMUM_PANELSIZE); x++) {
for(int y=0; y < PANEL_HEIGHT; y++) {
setLED(x, y);
}
}
updatePanel();
this->server = new UdpLedServer (NULL, this);
}
MainWindow::~MainWindow()

View File

@ -14,6 +14,9 @@ QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
/* dummy */
class UdpLedServer;
class MainWindow : public QMainWindow
{
Q_OBJECT

View File

@ -6,19 +6,27 @@
#define UDP_IMAGE_PORT 4242
UdpLedServer ::UdpLedServer (QObject *parent)
UdpLedServer::UdpLedServer (QObject *parent, MainWindow *window)
: QObject(parent)
{
initSocket();
connect(this,
&UdpLedServer::changeLEDstate,
(MainWindow*) parent,
window,
&MainWindow::setLED);
connect(this,
&UdpLedServer::updatePanelContent,
(MainWindow*) parent,
window,
&MainWindow::updatePanel);
for(int x=0; x < (PANEL_WIDTH * MAXIMUM_PANELSIZE); x++) {
for(int y=0; y < PANEL_HEIGHT; y++) {
changeLEDstate(x, y);
}
}
updatePanelContent();
}
void UdpLedServer ::initSocket()
@ -49,6 +57,7 @@ void UdpLedServer::processTheDatagram(QNetworkDatagram datagram) {
for(int y=0; y < PANEL_HEIGHT; y++) {
if (datagram.data().at(currentIndex) & mask) {
this->changeLEDstate(x, y);
qDebug() << x << "x" << y << " set";
}
mask = (mask << 1);
if (mask >= 256) {

View File

@ -3,13 +3,17 @@
#include <QAbstractItemModel>
#include <QUdpSocket>
#include "mainwindow.h"
class MainWindow;
class UdpLedServer : public QObject
{
Q_OBJECT
public:
explicit UdpLedServer (QObject *parent = nullptr);
/*UdpLedServer (QObject *parent = nullptr); */
UdpLedServer (QObject *parent = nullptr, MainWindow *window = nullptr);
private:
void initSocket();