#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); #if (PLATFORM_USED==PLATFORM_ARM) this->setWindowFlags(Qt::FramelessWindowHint); #else this->setGeometry(0,0,800,480); #endif BuzzerDrv::init_buzzer_gpio(); workThread = new Work_Thread(); workThread->start(); workPage = new Work_Page(this,workThread); workPage->hide(); dataListPage = new DataList_Page(this,workThread); dataListPage->hide(); sysSetPage = new SysSet_Page(this,workThread); sysSetPage->hide(); workThread->setPageIndex(0); connect(ui->pushButton_1,SIGNAL(pressed()),this,SLOT(btn_beep())); connect(ui->pushButton_7,SIGNAL(pressed()),this,SLOT(btn_beep())); connect(ui->pushButton_8,SIGNAL(pressed()),this,SLOT(btn_beep())); connect(ui->pushButton_9,SIGNAL(pressed()),this,SLOT(btn_beep())); connect(ui->pushButton_1,SIGNAL(released()),this,SLOT(MainBtnAction())); connect(ui->pushButton_7,SIGNAL(released()),this,SLOT(MainBtnAction())); connect(ui->pushButton_8,SIGNAL(released()),this,SLOT(MainBtnAction())); connect(ui->pushButton_9,SIGNAL(released()),this,SLOT(MainBtnAction())); Remote_Ctrl *remoteCtrl = new Remote_Ctrl(workThread); Network_Comm *netwk = new Network_Comm(remoteCtrl); netwk->start(); ESP32_Comm *esp32Comm = new ESP32_Comm(ESP32_UART_DEV_PORT, remoteCtrl); esp32Comm->start(); timer_500ms = new QTimer(this); connect(timer_500ms,SIGNAL(timeout()),this,SLOT(SystemTime())); timer_500ms->start(500); } MainWindow::~MainWindow() { delete ui; delete timer_500ms; qDebug("~MainWindow"); } void MainWindow::checkIcon() { // if(workThread->iconState.usbState) // ui->label_USB->setPixmap(QPixmap(":new/prefix1/usb.png")); // else // ui->label_USB->setPixmap(QPixmap("")); } void MainWindow::SystemTime(void) { checkIcon(); if(1 == workThread->remoteState.to_workpage){ timer_500ms->stop(); workPage->showWorkPage(); timer_500ms->start(500); workThread->setPageIndex(0); } } void MainWindow::MainBtnAction() { QPushButton *pb = dynamic_cast(sender()); if(ui->pushButton_1 == pb) { PACK_PARAM packparm = workThread->packParam; packparm.pack_type = PACK_TYPE_Halo; packparm.pack_devaddr = 0x06; workThread->savePackParam(packparm); timer_500ms->stop(); workPage->showWorkPage(); timer_500ms->start(500); workThread->setPageIndex(0); } else if(ui->pushButton_7 == pb) { PACK_PARAM packparm = workThread->packParam; packparm.pack_type = PACK_TYPE_Other; packparm.pack_devaddr = 0x01; workThread->savePackParam(packparm); timer_500ms->stop(); workPage->showWorkPage(); timer_500ms->start(500); workThread->setPageIndex(0); } else if(ui->pushButton_8 == pb) { timer_500ms->stop(); dataListPage->showDataListPage(); timer_500ms->start(500); workThread->setPageIndex(0); } else if(ui->pushButton_9 == pb) { timer_500ms->stop(); sysSetPage->showSyssetPage(); timer_500ms->start(500); workThread->setPageIndex(0); } } void MainWindow::btn_beep(void) { BuzzerDrv BD; BD.BuzzerBeep(50); }