Changeset View
Changeset View
Standalone View
Standalone View
testclient/mainwindow.cpp
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Line(s) | |||||
149 | void MainWindow::makePrintDock() | 149 | void MainWindow::makePrintDock() | ||
150 | { | 150 | { | ||
151 | printWidget = new PrintWidget; | 151 | printWidget = new PrintWidget; | ||
152 | connect(printWidget, &PrintWidget::printPressed, this, &MainWindow::printPBClicked); | 152 | connect(printWidget, &PrintWidget::printPressed, this, &MainWindow::printPBClicked); | ||
153 | connect(printWidget, &PrintWidget::emergencyStopPressed, core, &AtCore::emergencyStop); | 153 | connect(printWidget, &PrintWidget::emergencyStopPressed, core, &AtCore::emergencyStop); | ||
154 | connect(printWidget, &PrintWidget::fanSpeedChanged, core, &AtCore::setFanSpeed); | 154 | connect(printWidget, &PrintWidget::fanSpeedChanged, core, &AtCore::setFanSpeed); | ||
155 | 155 | | |||
156 | connect(printWidget, &PrintWidget::printSpeedChanged, this, [this](const int speed) { | 156 | connect(printWidget, &PrintWidget::printSpeedChanged, this, [this](const int speed) { | ||
157 | core->setPrinterSpeed(speed); | 157 | std::max(1, speed); | ||
158 | core->setPrinterSpeed(uint(speed)); | ||||
patrickelectric: negative numbers will overflow. | |||||
rizzitello: The range here is 1-300. It will not be negative. | |||||
How can you assure that to be future proof ? patrickelectric: How can you assure that to be future proof ?
You should use std::max | |||||
158 | }); | 159 | }); | ||
159 | 160 | | |||
160 | connect(printWidget, &PrintWidget::flowRateChanged, [this](const int rate) { | 161 | connect(printWidget, &PrintWidget::flowRateChanged, [this](const int rate) { | ||
161 | core->setFlowRate(rate); | 162 | std::max(1, rate); | ||
163 | core->setFlowRate(uint(rate)); | ||||
162 | }); | 164 | }); | ||
163 | 165 | | |||
164 | printDock = new QDockWidget(tr("Print"), this); | 166 | printDock = new QDockWidget(tr("Print"), this); | ||
165 | printDock->setWidget(printWidget); | 167 | printDock->setWidget(printWidget); | ||
166 | 168 | | |||
167 | menuView->insertAction(nullptr, printDock->toggleViewAction()); | 169 | menuView->insertAction(nullptr, printDock->toggleViewAction()); | ||
168 | addDockWidget(Qt::LeftDockWidgetArea, printDock); | 170 | addDockWidget(Qt::LeftDockWidgetArea, printDock); | ||
169 | } | 171 | } | ||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Line(s) | 365 | { | |||
365 | event->accept(); | 367 | event->accept(); | ||
366 | } | 368 | } | ||
367 | 369 | | |||
368 | MainWindow::~MainWindow() | 370 | MainWindow::~MainWindow() | ||
369 | { | 371 | { | ||
370 | 372 | | |||
371 | } | 373 | } | ||
372 | 374 | | |||
373 | void MainWindow::checkTemperature(uint sensorType, uint number, uint temp) | 375 | void MainWindow::checkTemperature(uint sensorType, uint number, float temp) | ||
374 | { | 376 | { | ||
375 | QString msg; | 377 | QString msg; | ||
376 | switch (sensorType) { | 378 | switch (sensorType) { | ||
377 | case 0x00: // bed | 379 | case 0x00: // bed | ||
378 | msg = QString::fromLatin1("Bed Temperature "); | 380 | msg = QString::fromLatin1("Bed Temperature "); | ||
379 | break; | 381 | break; | ||
380 | 382 | | |||
381 | case 0x01: // bed target | 383 | case 0x01: // bed target | ||
Show All 13 Lines | 395 | case 0x04: // enclosure | |||
395 | break; | 397 | break; | ||
396 | 398 | | |||
397 | case 0x05: // enclosure target | 399 | case 0x05: // enclosure target | ||
398 | msg = QString::fromLatin1("Enclosure Target Temperature "); | 400 | msg = QString::fromLatin1("Enclosure Target Temperature "); | ||
399 | break; | 401 | break; | ||
400 | } | 402 | } | ||
401 | 403 | | |||
402 | msg.append(QString::fromLatin1("[%1] : %2").arg( | 404 | msg.append(QString::fromLatin1("[%1] : %2").arg( | ||
403 | QString::number(number), QString::number(temp) | 405 | QString::number(number), QString::number(double(temp), 'f', 2) | ||
404 | )); | 406 | )); | ||
405 | 407 | | |||
406 | logWidget->appendLog(msg); | 408 | logWidget->appendLog(msg); | ||
407 | } | 409 | } | ||
408 | /** | 410 | /** | ||
409 | * @brief MainWindow::locateSerialPort | 411 | * @brief MainWindow::locateSerialPort | ||
410 | * Locate all active serial ports on the computer and add to the list | 412 | * Locate all active serial ports on the computer and add to the list | ||
411 | * of serial ports | 413 | * of serial ports | ||
▲ Show 20 Lines • Show All 180 Lines • Show Last 20 Lines |
negative numbers will overflow.