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