Refactoring fixes
This commit is contained in:
@@ -715,6 +715,8 @@ void SetupPanel::updateStartupSwitches()
|
|||||||
unsigned int switchStates = model->switchWarningStates;
|
unsigned int switchStates = model->switchWarningStates;
|
||||||
|
|
||||||
for (int i=0; i<firmware->getCapability(Switches); i++) {
|
for (int i=0; i<firmware->getCapability(Switches); i++) {
|
||||||
|
if (!IS_TARANIS(firmware->getBoard()) && i==firmware->getCapability(Switches)-1)
|
||||||
|
continue;
|
||||||
QSlider * slider = startupSwitchesSliders[i];
|
QSlider * slider = startupSwitchesSliders[i];
|
||||||
QCheckBox * cb = startupSwitchesCheckboxes[i];
|
QCheckBox * cb = startupSwitchesCheckboxes[i];
|
||||||
bool enabled = !(model->switchWarningEnable & (1 << i));
|
bool enabled = !(model->switchWarningEnable & (1 << i));
|
||||||
@@ -725,10 +727,6 @@ void SetupPanel::updateStartupSwitches()
|
|||||||
switchStates >>= 2;
|
switchStates >>= 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (i == firmware->getCapability(Switches)-1) {
|
|
||||||
// Trainer switch, no switch warning
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
slider->setValue(i==0 ? switchStates & 0x3 : switchStates & 0x1);
|
slider->setValue(i==0 ? switchStates & 0x3 : switchStates & 0x1);
|
||||||
switchStates >>= (i==0 ? 2 : 1);
|
switchStates >>= (i==0 ? 2 : 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,7 @@
|
|||||||
#ifndef MOUNTLIST_H_
|
#ifndef MOUNTLIST_H_
|
||||||
# define MOUNTLIST_H_
|
# define MOUNTLIST_H_
|
||||||
|
|
||||||
#if defined WIN32 || !defined __GNUC__
|
#if defined __GNUC__
|
||||||
#define bool char
|
|
||||||
#else
|
|
||||||
# include <stdbool.h>
|
# include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ void FlashProcess::onStarted()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# if !__GNUC__
|
# if !__GNUC__
|
||||||
bool KillProcessByName(const char *szProcessToKill)
|
bool killProcessByName(const char *szProcessToKill)
|
||||||
{
|
{
|
||||||
HANDLE hProcessSnap;
|
HANDLE hProcessSnap;
|
||||||
HANDLE hProcess;
|
HANDLE hProcess;
|
||||||
@@ -107,13 +107,13 @@ bool KillProcessByName(const char *szProcessToKill)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# if !__GNUC__
|
|
||||||
void FlashProcess::onKillTimerElapsed()
|
void FlashProcess::onKillTimerElapsed()
|
||||||
{
|
{
|
||||||
|
# if !__GNUC__
|
||||||
// trick to accelerate SAM-BA startup
|
// trick to accelerate SAM-BA startup
|
||||||
KillProcessByName("tasklist.exe");
|
killProcessByName("tasklist.exe");
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void FlashProcess::analyseStandardOutput(const QString &text)
|
void FlashProcess::analyseStandardOutput(const QString &text)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
class ProgressWidget;
|
class ProgressWidget;
|
||||||
class QProcess;
|
class QProcess;
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
class FlashProcess : public QObject
|
class FlashProcess : public QObject
|
||||||
{
|
{
|
||||||
@@ -25,6 +26,7 @@ protected slots:
|
|||||||
void onReadyReadStandardOutput();
|
void onReadyReadStandardOutput();
|
||||||
void onReadyReadStandardError();
|
void onReadyReadStandardError();
|
||||||
void onFinished(int);
|
void onFinished(int);
|
||||||
|
void onKillTimerElapsed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void analyseStandardOutput(const QString &text);
|
void analyseStandardOutput(const QString &text);
|
||||||
@@ -43,6 +45,9 @@ protected:
|
|||||||
unsigned int efuse;
|
unsigned int efuse;
|
||||||
enum FlashPhase { READING, WRITING, VERIFYING };
|
enum FlashPhase { READING, WRITING, VERIFYING };
|
||||||
FlashPhase flashPhase;
|
FlashPhase flashPhase;
|
||||||
|
#if !__GNUC__
|
||||||
|
QTimer *killTimer;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLASHPROCESS_H_
|
#endif // FLASHPROCESS_H_
|
||||||
|
|||||||
@@ -30,55 +30,6 @@ QString getRadioInterfaceCmd()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString findMassstoragePath(const QString &filename)
|
|
||||||
{
|
|
||||||
QString temppath;
|
|
||||||
QStringList drives;
|
|
||||||
QString eepromfile;
|
|
||||||
QString fsname;
|
|
||||||
#if defined WIN32 || !defined __GNUC__
|
|
||||||
foreach( QFileInfo drive, QDir::drives() ) {
|
|
||||||
WCHAR szVolumeName[256] ;
|
|
||||||
WCHAR szFileSystemName[256];
|
|
||||||
DWORD dwSerialNumber = 0;
|
|
||||||
DWORD dwMaxFileNameLength=256;
|
|
||||||
DWORD dwFileSystemFlags=0;
|
|
||||||
bool ret = GetVolumeInformationW( (WCHAR *) drive.absolutePath().utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256);
|
|
||||||
if (ret) {
|
|
||||||
QString vName = QString::fromUtf16 ( (const ushort *) szVolumeName) ;
|
|
||||||
temppath = drive.absolutePath();
|
|
||||||
eepromfile = temppath;
|
|
||||||
eepromfile.append("/" + filename);
|
|
||||||
if (QFile::exists(eepromfile)) {
|
|
||||||
return eepromfile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
struct mount_entry *entry;
|
|
||||||
entry = read_file_system_list(true);
|
|
||||||
while (entry != NULL) {
|
|
||||||
if (!drives.contains(entry->me_devname)) {
|
|
||||||
drives.append(entry->me_devname);
|
|
||||||
temppath = entry->me_mountdir;
|
|
||||||
eepromfile = temppath;
|
|
||||||
eepromfile.append("/" + filename);
|
|
||||||
#if !defined __APPLE__
|
|
||||||
QString fstype = entry->me_type;
|
|
||||||
if (QFile::exists(eepromfile) && fstype.contains("fat") ) {
|
|
||||||
#else
|
|
||||||
if (QFile::exists(eepromfile)) {
|
|
||||||
#endif
|
|
||||||
return eepromfile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry = entry->me_next;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList getAvrdudeArgs(const QString &cmd, const QString &filename)
|
QStringList getAvrdudeArgs(const QString &cmd, const QString &filename)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
@@ -407,3 +358,52 @@ bool writeEeprom(const QString &filename, ProgressWidget *progress)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString findMassstoragePath(const QString &filename)
|
||||||
|
{
|
||||||
|
QString temppath;
|
||||||
|
QStringList drives;
|
||||||
|
QString eepromfile;
|
||||||
|
QString fsname;
|
||||||
|
#if defined WIN32 || !defined __GNUC__
|
||||||
|
foreach(QFileInfo drive, QDir::drives()) {
|
||||||
|
WCHAR szVolumeName[256] ;
|
||||||
|
WCHAR szFileSystemName[256];
|
||||||
|
DWORD dwSerialNumber = 0;
|
||||||
|
DWORD dwMaxFileNameLength=256;
|
||||||
|
DWORD dwFileSystemFlags=0;
|
||||||
|
bool ret = GetVolumeInformationW( (WCHAR *) drive.absolutePath().utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256);
|
||||||
|
if (ret) {
|
||||||
|
QString vName = QString::fromUtf16 ( (const ushort *) szVolumeName) ;
|
||||||
|
temppath = drive.absolutePath();
|
||||||
|
eepromfile = temppath;
|
||||||
|
eepromfile.append("/" + filename);
|
||||||
|
if (QFile::exists(eepromfile)) {
|
||||||
|
return eepromfile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
struct mount_entry *entry;
|
||||||
|
entry = read_file_system_list(true);
|
||||||
|
while (entry != NULL) {
|
||||||
|
if (!drives.contains(entry->me_devname)) {
|
||||||
|
drives.append(entry->me_devname);
|
||||||
|
temppath = entry->me_mountdir;
|
||||||
|
eepromfile = temppath;
|
||||||
|
eepromfile.append("/" + filename);
|
||||||
|
#if !defined __APPLE__
|
||||||
|
QString fstype = entry->me_type;
|
||||||
|
if (QFile::exists(eepromfile) && fstype.contains("fat") ) {
|
||||||
|
#else
|
||||||
|
if (QFile::exists(eepromfile)) {
|
||||||
|
#endif
|
||||||
|
return eepromfile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry = entry->me_next;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user