diff --git a/common/app/screen_guitest.c b/common/app/screen_guitest.c index d2d93e3..282636e 100644 --- a/common/app/screen_guitest.c +++ b/common/app/screen_guitest.c @@ -62,6 +62,8 @@ static void enter(void* screen) { //tft test + tft_draw_pixel(0,0,BLACK); + tft_draw_pixel(319,239,BLACK); tft_draw_pixel(10,210,BLUE); tft_draw_pixel(12,210,BLUE); tft_draw_rectangle(40,100,60,235,BLUE); diff --git a/emulator/qt/ll_system.cpp b/emulator/qt/ll_system.cpp index 1356956..8d087b5 100644 --- a/emulator/qt/ll_system.cpp +++ b/emulator/qt/ll_system.cpp @@ -15,6 +15,7 @@ void ll_system_delay(uint32_t msec) { void ll_system_process() { QApplication::processEvents(); + QThread::msleep(1); } void ll_system_toggle_led() { diff --git a/emulator/qt/mainwindow.cpp b/emulator/qt/mainwindow.cpp index aa3fa5f..3756730 100644 --- a/emulator/qt/mainwindow.cpp +++ b/emulator/qt/mainwindow.cpp @@ -12,8 +12,6 @@ extern "C" { #define DISPLAY_WIDTH 320 #define DISPLAY_HEIGHT 240 -#define DISPLAY_X 10 -#define DISPLAY_Y 10 QColor QColorFromRGB565(uint16_t color) { @@ -35,6 +33,7 @@ QRgb QRgbFromRGB565(uint16_t color) { MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), image(DISPLAY_WIDTH,DISPLAY_HEIGHT, QImage::Format_RGB16), ui(new Ui::MainWindow){ ui->setupUi(this); image.fill(Qt::black); + currentScale = 1; } void MainWindow::draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) @@ -134,9 +133,13 @@ void MainWindow::paintEvent(QPaintEvent *) //render_mutex.lock(); QPainter painter(this); - painter.drawImage(DISPLAY_X,DISPLAY_Y,image); + QRectF imgRect (ui->widgetDisplay->geometry().topLeft(),QSizeF(DISPLAY_WIDTH*currentScale,DISPLAY_HEIGHT*currentScale)); + + painter.drawImage(imgRect,image); painter.setPen(QPen(Qt::green,2)); - painter.drawRect(DISPLAY_X-1,DISPLAY_Y-1,DISPLAY_WIDTH+2,DISPLAY_HEIGHT+2); + painter.drawRect(imgRect.adjusted(-1,-1,1,1)); + + //render_mutex.unlock(); } @@ -167,7 +170,8 @@ MainWindow::~MainWindow() void MainWindow::checkAndSendEvent(QPoint pos, bool down) { - QPoint p = pos - QPoint(DISPLAY_X,DISPLAY_Y); + QPoint p = pos - ui->widgetDisplay->geometry().topLeft(); + p/=currentScale; if(p.x()<0 || p.y()<0 || p.x() >= DISPLAY_WIDTH || p.y() >= DISPLAY_HEIGHT) return; //qDebug() << down << p; @@ -175,3 +179,9 @@ void MainWindow::checkAndSendEvent(QPoint pos, bool down) touch_add_raw_event(p.x(),p.y(),down?TOUCH_DOWN:TOUCH_UP); } + +void MainWindow::on_cboZoom_currentIndexChanged(int index) +{ + currentScale=index+1; + update(); +} diff --git a/emulator/qt/mainwindow.h b/emulator/qt/mainwindow.h index c4c015b..ad14809 100644 --- a/emulator/qt/mainwindow.h +++ b/emulator/qt/mainwindow.h @@ -31,9 +31,13 @@ protected: void mouseMoveEvent(QMouseEvent* evt); ~MainWindow(); +private slots: + void on_cboZoom_currentIndexChanged(int index); + private: //QMutex render_mutex; QImage image; + int currentScale; void checkAndSendEvent(QPoint pos, bool down); Ui::MainWindow *ui; diff --git a/emulator/qt/mainwindow.ui b/emulator/qt/mainwindow.ui index 560c879..293d0a3 100644 --- a/emulator/qt/mainwindow.ui +++ b/emulator/qt/mainwindow.ui @@ -6,26 +6,102 @@ 0 0 - 339 - 263 + 980 + 778 DiscoverPixy Emulator - - - - - 0 - 0 - 339 - 19 - - + + + + + + + + Zoom + + + + + + + + 1x + + + + + 2x + + + + + 3x + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Exit + + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + - - + + + btnExit + clicked() + MainWindow + close() + + + 652 + 20 + + + 351 + 244 + + + +