Simulation is working
This commit is contained in:
parent
c5bfaa2a4a
commit
aac762e8f1
@ -12,6 +12,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->mOffscreenPanel = new QImage(DEFAULT_WIDTH + LED_DISTANCE, DEFAULT_HEIGHT + LED_DISTANCE, QImage::Format_RGB32);
|
this->mOffscreenPanel = new QImage(DEFAULT_WIDTH + LED_DISTANCE, DEFAULT_HEIGHT + LED_DISTANCE, QImage::Format_RGB32);
|
||||||
|
this->drawImage(this->mOffscreenPanel);
|
||||||
this->server = new UdpLedServer (NULL, this);
|
this->server = new UdpLedServer (NULL, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,12 +22,10 @@ MainWindow::~MainWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::drawImage(QImage *target) {
|
void MainWindow::drawImage(QImage *target) {
|
||||||
|
this->mScene=new QGraphicsScene() ;
|
||||||
QGraphicsView *graphicsView = new QGraphicsView();
|
QGraphicsView *graphicsView = new QGraphicsView();
|
||||||
graphicsView->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
graphicsView->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
||||||
QGraphicsScene* scene=new QGraphicsScene() ;
|
graphicsView->setScene(this->mScene);
|
||||||
graphicsView->setScene(scene);
|
|
||||||
QGraphicsPixmapItem* item = new QGraphicsPixmapItem(QPixmap::fromImage(*(target)));
|
|
||||||
scene->addItem(item);
|
|
||||||
graphicsView->show();
|
graphicsView->show();
|
||||||
this->ui->ledPanel->addWidget(graphicsView);
|
this->ui->ledPanel->addWidget(graphicsView);
|
||||||
}
|
}
|
||||||
@ -42,7 +41,10 @@ void MainWindow::setLED(uint8_t x, uint8_t y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updatePanel(void) {
|
void MainWindow::updatePanel(void) {
|
||||||
this->drawImage(this->mOffscreenPanel);
|
|
||||||
|
QGraphicsPixmapItem* item = new QGraphicsPixmapItem(QPixmap::fromImage(*(this->mOffscreenPanel)));
|
||||||
|
this->mScene->clear();
|
||||||
|
mScene->addItem(item);
|
||||||
this->renderPanel();
|
this->renderPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QGraphicsScene>
|
||||||
#include "udpserver.h"
|
#include "udpserver.h"
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@ -31,8 +32,9 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
UdpLedServer *server;
|
UdpLedServer *server = nullptr;
|
||||||
QImage *mOffscreenPanel;
|
QImage *mOffscreenPanel = nullptr;
|
||||||
|
QGraphicsScene* mScene = nullptr;
|
||||||
void drawImage(QImage *image);
|
void drawImage(QImage *image);
|
||||||
void renderPanel(void);
|
void renderPanel(void);
|
||||||
};
|
};
|
||||||
|
@ -53,8 +53,8 @@ void UdpLedServer::processTheDatagram(QNetworkDatagram datagram) {
|
|||||||
int currentIndex = PACKET_INDEX_PANEL0;
|
int currentIndex = PACKET_INDEX_PANEL0;
|
||||||
|
|
||||||
uint16_t mask = 1;
|
uint16_t mask = 1;
|
||||||
for(int x=0; x < (PANEL_WIDTH * MAXIMUM_PANELSIZE); x++) {
|
|
||||||
for(int y=0; y < PANEL_HEIGHT; y++) {
|
for(int y=0; y < PANEL_HEIGHT; y++) {
|
||||||
|
for(int x=0; x < (PANEL_WIDTH * MAXIMUM_PANELSIZE); x++) {
|
||||||
if (datagram.data().at(currentIndex) & mask) {
|
if (datagram.data().at(currentIndex) & mask) {
|
||||||
this->changeLEDstate(x, y);
|
this->changeLEDstate(x, y);
|
||||||
qDebug() << x << "x" << y << " set";
|
qDebug() << x << "x" << y << " set";
|
||||||
|
Loading…
Reference in New Issue
Block a user