Skip to content

Commit

Permalink
Update to qt 5.14, upgrade to Meyer singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaone committed Feb 29, 2020
1 parent 6071aa6 commit fb2263a
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 119 deletions.
5 changes: 2 additions & 3 deletions FlightController/DeviceConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "DeviceInterface.h"
#include "LayerCondition.h"
#include "settings.h"
#include "singleton.h"

const std::vector<std::string> expModeNames_{
"Disabled",
Expand Down Expand Up @@ -55,7 +54,7 @@ bool DeviceConfig::eventFilter(QObject *obj __attribute__((unused)),
* Fire up the uploader.
*/
void DeviceConfig::toDevice(void) {
DeviceInterface &di = Singleton<DeviceInterface>::instance();
DeviceInterface &di = DeviceInterface::get();
if (di.getStatusBit(C2DEVSTATUS_MATRIX_MONITOR)) {
QMessageBox::critical(NULL, "Matrix monitor active",
"Turn off matrix monitor first!");
Expand Down Expand Up @@ -106,7 +105,7 @@ void DeviceConfig::_uploadConfigBlock(void) {
}

void DeviceConfig::fromDevice() {
DeviceInterface &di = Singleton<DeviceInterface>::instance();
DeviceInterface &di = DeviceInterface::get();
if (di.getStatusBit(C2DEVSTATUS_MATRIX_MONITOR)) {
QMessageBox::critical(NULL, "Matrix monitor active",
"Turn off matrix monitor first!");
Expand Down
6 changes: 5 additions & 1 deletion FlightController/DeviceInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ void DeviceInterface::processStatusReply(QByteArray* payload) {
if (receivedStatus_ != payload->at(1)) {
rx = true;
}
if (payload->size() < 6) {
qInfo() << "Received status packet runt, length: " << payload->size();
return;
}
receivedStatus_ = payload->at(1);
scanEnabled = payload->at(1) & (1 << C2DEVSTATUS_SCAN_ENABLED);
outputEnabled = payload->at(1) & (1 << C2DEVSTATUS_OUTPUT_ENABLED);
Expand Down Expand Up @@ -318,7 +322,7 @@ void DeviceInterface::_initDevice(void) {
cts_.store(true); // Not expecting anything from device - clear to send.
_updateDeviceStatus(mode == DeviceInterfaceNormal ? DeviceConnected
: BootloaderConnected);
QByteArray tmp(5, (char)0);
QByteArray tmp(64, (char)0);
processStatusReply(&tmp);
// No need to change timer rate - loading config will switch it.
return;
Expand Down
8 changes: 4 additions & 4 deletions FlightController/DeviceInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "DeviceSelector.h"
#include "Events.h"
#include "LogViewer.h"
#include "singleton.h"

class DeviceInterface : public QObject {
Q_OBJECT
Expand All @@ -28,11 +27,12 @@ class DeviceInterface : public QObject {
Q_ENUMS(Mode)

public:
static DeviceInterface& getInstance() {
return Singleton<DeviceInterface>::instance();
static DeviceInterface& get() {
static DeviceInterface instance{};
return instance;
}
static DeviceConfig* config;
DeviceInterface(QObject *parent = 0);
DeviceInterface(QObject *parent = nullptr);
~DeviceInterface();
void start(void);
bool event(QEvent *e);
Expand Down
4 changes: 1 addition & 3 deletions FlightController/FirmwareLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
#include <QFileDialog>
#include <QMessageBox>

#include "singleton.h"

#include "DeviceInterface.h"
#include "Events.h"
#include "settings.h"

FirmwareLoader::FirmwareLoader(QObject *parent)
: QObject(parent), bootloaderMode(false), firmware(NULL),
lastCommand(BR_CYRET_SUCCESS) {
DeviceInterface &di = Singleton<DeviceInterface>::instance();
DeviceInterface &di = DeviceInterface::get();
di.installEventFilter(this);
}

Expand Down
15 changes: 7 additions & 8 deletions FlightController/FlightController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "../c2/nvram.h"
#include "DeviceConfig.h"
#include "DeviceInterface.h"
#include "singleton.h"

constexpr size_t kBlinkTimerTick = 20;

Expand All @@ -22,7 +21,7 @@ FlightController::FlightController(QWidget *parent)
ui->setupUi(this);
ui->swVersionLabel->setText(QCoreApplication::applicationVersion());

DeviceInterface &di = Singleton<DeviceInterface>::instance();
DeviceInterface &di = DeviceInterface::get();

matrixMonitor = new MatrixMonitor();
connect(
Expand Down Expand Up @@ -62,7 +61,7 @@ FlightController::FlightController(QWidget *parent)
}

void FlightController::setup(void) {
DeviceInterface &di = Singleton<DeviceInterface>::instance();
DeviceInterface &di = DeviceInterface::get();

connect(ui->ClearButton, SIGNAL(clicked()), ui->LogViewport,
SLOT(clearButtonClick()));
Expand Down Expand Up @@ -127,7 +126,7 @@ void FlightController::setup(void) {
}

void FlightController::blinkLights() {
DeviceInterface &di = Singleton<DeviceInterface>::instance();
DeviceInterface &di = DeviceInterface::get();
if (di.tx) {
di.tx = false;
ui->txLabel
Expand Down Expand Up @@ -157,7 +156,7 @@ void FlightController::timerEvent(QTimerEvent * timer) {
}

void FlightController::updateStatus(void) {
DeviceInterface &di = Singleton<DeviceInterface>::instance();
DeviceInterface &di = DeviceInterface::get();
ui->fwVersionLabel->setText(di.firmwareVersion);
ui->tempGauge->setText(di.dieTemp);
if (di.scanEnabled) {
Expand Down Expand Up @@ -240,7 +239,7 @@ void FlightController::deviceStatusNotification(
layerConditions->init();
_delays->init();
_hardware->init();
ui->typeLabel->setText(DeviceInterface::getInstance().switchType);
ui->typeLabel->setText(DeviceInterface::get().switchType);
lockUI(false);
break;
case DeviceInterface::BootloaderConnected:
Expand Down Expand Up @@ -325,11 +324,11 @@ void FlightController::on_redButton_clicked() {
void FlightController::on_reconnectButton_clicked() {
qInfo() << "reconnecting..";
emit setStatusBit(C2DEVSTATUS_SETUP_MODE, false);
DeviceInterface &di = Singleton<DeviceInterface>::instance();
DeviceInterface &di = DeviceInterface::get();
di.releaseDevice();
}

void FlightController::on_statusRequestButton_clicked(void) {
DeviceInterface &di = Singleton<DeviceInterface>::instance();
DeviceInterface &di = DeviceInterface::get();
di.printableStatus = true;
}
2 changes: 0 additions & 2 deletions FlightController/FlightController.pro
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ SOURCES += main.cpp \

HEADERS += \
../c2/nvram.h \
call_once.h \
singleton.h \
settings.h \
FlightController.h \
LogViewer.h \
Expand Down
1 change: 0 additions & 1 deletion FlightController/LayoutEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "LayoutEditor.h"
#include "ScancodeList.h"
#include "settings.h"
#include "singleton.h"
#include "ui_LayoutEditor.h"

LayoutEditor::LayoutEditor(DeviceConfig *config, QWidget *parent)
Expand Down
1 change: 0 additions & 1 deletion FlightController/MacroEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "DeviceInterface.h"
#include "MacroEditor.h"
#include "singleton.h"
#include "ScancodeList.h"
#include "ui_MacroEditor.h"

Expand Down
5 changes: 2 additions & 3 deletions FlightController/MatrixMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "Events.h"
#include "MatrixMonitor.h"
#include "settings.h"
#include "singleton.h"
#include "ui_MatrixMonitor.h"

MatrixMonitor::MatrixMonitor(QWidget *parent)
Expand All @@ -22,7 +21,7 @@ MatrixMonitor::MatrixMonitor(QWidget *parent)
ui->setupUi(this);

initDisplay();
auto& di = Singleton<DeviceInterface>::instance();
auto& di = DeviceInterface::get();
connect(this, SIGNAL(sendCommand(c2command, uint8_t)), &di,
SLOT(sendCommand(c2command, uint8_t)));
connect(this, SIGNAL(setStatusBit(deviceStatus, bool)), &di,
Expand Down Expand Up @@ -105,7 +104,7 @@ bool MatrixMonitor::eventFilter(QObject *obj __attribute__((unused)),
_warmupRows--;
return true;
}
auto& di = Singleton<DeviceInterface>::instance();
auto& di = DeviceInterface::get();
uint8_t row = pl->at(1);
uint8_t max_cols = pl->at(2);
for (uint8_t i = 0; i < max_cols; i++) {
Expand Down
5 changes: 2 additions & 3 deletions FlightController/ThresholdEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "DeviceInterface.h"
#include "ThresholdEditor.h"
#include "singleton.h"
#include "ui_ThresholdEditor.h"

ThresholdEditor::ThresholdEditor(DeviceConfig *config, QWidget *parent)
Expand All @@ -16,7 +15,7 @@ ThresholdEditor::ThresholdEditor(DeviceConfig *config, QWidget *parent)
connect(ui->revertButton, SIGNAL(clicked()), this, SLOT(resetThresholds()));
connect(ui->incButton, SIGNAL(clicked()), this, SLOT(increaseThresholds()));
connect(ui->decButton, SIGNAL(clicked()), this, SLOT(decreaseThresholds()));
auto& di = Singleton<DeviceInterface>::instance();
auto& di = DeviceInterface::get();
di.installEventFilter(this);
}

Expand Down Expand Up @@ -126,7 +125,7 @@ bool ThresholdEditor::eventFilter(QObject *obj __attribute__((unused)),
QEvent *event) {
if (event->type() == DeviceMessage::ET) {
QByteArray *pl = static_cast<DeviceMessage *>(event)->getPayload();
auto& di = Singleton<DeviceInterface>::instance();
auto& di = DeviceInterface::get();
if (pl->at(0) != C2RESPONSE_MATRIX_ROW) {
return false;
}
Expand Down
46 changes: 0 additions & 46 deletions FlightController/call_once.h

This file was deleted.

2 changes: 1 addition & 1 deletion FlightController/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
QCoreApplication::setOrganizationDomain("none.exists");
QCoreApplication::setOrganizationName("DMA Labs");
QCoreApplication::setApplicationName("FlightController");
QCoreApplication::setApplicationVersion("1.0.1.0");
QCoreApplication::setApplicationVersion("1.0.1.1");
qInfo() << "Start start!";
FlightController w;
qInfo() << "Switching to LogViewer..";
Expand Down
34 changes: 0 additions & 34 deletions FlightController/singleton.h

This file was deleted.

10 changes: 5 additions & 5 deletions Qt-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,25 @@ Because windows app can be a single file - static version is better.
### Abridged version
http://download.qt.io/official_releases/qt/

Get qt-opensource-windows-x86-???.exe from a version subdir. Latest is 5.10.0 as of now.
Install "Sources", "MinGW5.3.0 32bit" and everything from "Tools" to C:\Qt.
Get qt-opensource-windows-x86-???.exe from a version subdir. Latest is 5.14.1 as of now.
Install "Sources", "MinGWx.x.x 32bit" and everything from "Tools" to C:\Qt.
Perl msi didn't run on me - installed with defaults to c:\Strawberry.
copy windows-build-qt-static.ps1 to c:\qt
```
cd \qt
mkdir static
mv 5.10.0\Src static
mv 5.14.1\Src static
```

Fix versions in windows-build-qt-static.ps1

Run powershell as administrator. Run windows-build-qt-static.ps1 - you'll need to Set-Ex[TAB] Bypass to run it.
Run powershell as administrator. Run windows-build-qt-static.ps1 - you _may_ need to `Set-Ex[TAB] Bypass` to run it.

This will take a while.

Then in Qt Creator go Tools->options, select "Build & Run", add new Qt version from c:\Qt\Static\5.10\,
Then in Qt Creator go Tools->options, select "Build & Run", add new Qt version from c:\Qt\Static\{qt version}\,
then clone autodetected kit, name "static", select newly added Qt version for it.

Don't forget to click "Apply".
Expand Down
1 change: 0 additions & 1 deletion Qt-build/mac-build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash

QT_VERSION=5.9
BUILD_DIR=build-macx

QT_PACKAGE=qt
Expand Down
4 changes: 2 additions & 2 deletions Qt-build/windows-build-qt-static.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
param(
$QtSrcUrl = "http://download.qt.io/official_releases/qt/5.8/5.8.0/single/qt-everywhere-opensource-src-5.8.0.7z",
$QtStaticDir = "C:\Qt\Static",
$QtVersion = "5.10",
$MingwDir = "C:\Qt\Tools\mingw530_32",
$QtVersion = "5.14",
$MingwDir = "C:\Qt\Tools\mingw730_32",
[switch]$NoPause = $false
)

Expand Down
2 changes: 1 addition & 1 deletion cortex/scan_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "PSoC_USB.h"

static uint32_t matrix_status[MATRIX_ROWS];
static uint32_t matrix_status[ABSOLUTE_MAX_ROWS];
bool matrix_was_active;

#define MAX_MATRIX_VALUE 0xffff
Expand Down

0 comments on commit fb2263a

Please sign in to comment.