mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
Issue #757 fixed
This commit is contained in:
parent
0a30595bb1
commit
1c482e7f6e
2 changed files with 92 additions and 72 deletions
|
@ -38,7 +38,8 @@ avrOutputDialog::avrOutputDialog(QWidget *parent, QString prog, QStringList arg,
|
|||
if (arg.count()<2) {
|
||||
closeOpt = AVR_DIALOG_FORCE_CLOSE;
|
||||
QTimer::singleShot(0, this, SLOT(forceClose()));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sourceFile=arg.at(0);
|
||||
destFile=arg.at(1);
|
||||
if (!displayDetails) {
|
||||
|
@ -68,7 +69,6 @@ avrOutputDialog::avrOutputDialog(QWidget *parent, QString prog, QStringList arg,
|
|||
efuse = 0;
|
||||
phase=0;
|
||||
currLine.clear();
|
||||
prevLine.clear();
|
||||
if (!displayDetails) {
|
||||
ui->plainTextEdit->hide();
|
||||
QTimer::singleShot(0, this, SLOT(shrink()));
|
||||
|
@ -132,11 +132,12 @@ void avrOutputDialog::doCopy()
|
|||
char * pointer=buf;
|
||||
QFile source(sourceFile);
|
||||
int blocks=(source.size()/BLKSIZE);
|
||||
ui->progressBar->setMaximum(blocks-1);
|
||||
ui->progressBar->setMaximum(blocks-1);
|
||||
if (!source.open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::warning(this, tr("Error"),tr("Cannot open source file"));
|
||||
hasErrors=true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
source.read(buf,READBUF);
|
||||
source.close();
|
||||
QFile dest(destFile);
|
||||
|
@ -183,7 +184,6 @@ void avrOutputDialog::runAgain(QString prog, QStringList arg, int closeBehaviour
|
|||
foreach(QString str, arg) cmdLine.append(" " + str);
|
||||
closeOpt = closeBehaviour;
|
||||
currLine.clear();
|
||||
prevLine.clear();
|
||||
process->start(prog,arg);
|
||||
}
|
||||
|
||||
|
@ -194,12 +194,18 @@ void avrOutputDialog::waitForFinish()
|
|||
|
||||
void avrOutputDialog::addText(const QString &text)
|
||||
{
|
||||
int val = ui->plainTextEdit->verticalScrollBar()->maximum();
|
||||
ui->plainTextEdit->insertPlainText(text);
|
||||
if(val!=ui->plainTextEdit->verticalScrollBar()->maximum())
|
||||
ui->plainTextEdit->verticalScrollBar()->setValue(ui->plainTextEdit->verticalScrollBar()->maximum());
|
||||
}
|
||||
QTextCursor cursor(ui->plainTextEdit->textCursor());
|
||||
|
||||
// is the scrollbar at the end?
|
||||
bool atEnd = (ui->plainTextEdit->verticalScrollBar()->value() == ui->plainTextEdit->verticalScrollBar()->maximum());
|
||||
|
||||
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor, 1);
|
||||
cursor.insertText(text);
|
||||
|
||||
if (atEnd) {
|
||||
ui->plainTextEdit->verticalScrollBar()->triggerAction(QAbstractSlider::SliderToMaximum);
|
||||
}
|
||||
}
|
||||
|
||||
void avrOutputDialog::doAddTextStdOut()
|
||||
{
|
||||
|
@ -209,31 +215,30 @@ void avrOutputDialog::doAddTextStdOut()
|
|||
int nlPos, pos, size;
|
||||
|
||||
addText(text);
|
||||
|
||||
currStdLine.append(text);
|
||||
if (currStdLine.contains("size = ")) {
|
||||
pos=currStdLine.lastIndexOf("size = ");
|
||||
temp=currStdLine.mid(pos+7);
|
||||
pos=temp.lastIndexOf("\n");
|
||||
size=temp.left(pos).toInt();
|
||||
pos = currStdLine.lastIndexOf("size = ");
|
||||
temp = currStdLine.mid(pos+7);
|
||||
pos = temp.lastIndexOf("\n");
|
||||
size = temp.left(pos).toInt();
|
||||
ui->progressBar->setMaximum(size/2048);
|
||||
}
|
||||
if (currStdLine.contains("\n")) {
|
||||
nlPos=currStdLine.lastIndexOf("\n");
|
||||
prevStdLine=currStdLine.left(nlPos).trimmed();
|
||||
currStdLine=currStdLine.mid(nlPos+1);
|
||||
nlPos = currStdLine.lastIndexOf("\n");
|
||||
currStdLine = currStdLine.mid(nlPos+1);
|
||||
}
|
||||
if (!currStdLine.isEmpty()) {
|
||||
if (currStdLine.at(0)==QChar('.')) {
|
||||
pos=currStdLine.lastIndexOf(".");
|
||||
ui->progressBar->setValue(pos);
|
||||
}
|
||||
}
|
||||
if (!currStdLine.isEmpty()) {
|
||||
if (currStdLine.startsWith("Starting upload: [")) {
|
||||
pos=(currStdLine.lastIndexOf("#")-19)/(MAX_FSIZE/204800.0);
|
||||
if (currStdLine.at(0) == QChar('.')) {
|
||||
pos = currStdLine.lastIndexOf(".");
|
||||
ui->progressBar->setValue(pos);
|
||||
}
|
||||
else if (currStdLine.startsWith("Starting upload: [")) {
|
||||
pos = (currStdLine.lastIndexOf("#")-19)/(MAX_FSIZE/204800.0);
|
||||
ui->progressBar->setValue(pos);
|
||||
}
|
||||
}
|
||||
|
||||
if (text.contains("Complete ")) {
|
||||
#if !__GNUC__
|
||||
if (kill_timer) {
|
||||
|
@ -250,19 +255,15 @@ void avrOutputDialog::doAddTextStdOut()
|
|||
}
|
||||
}
|
||||
|
||||
//addText("\n=====\n" + text + "\n=====\n");
|
||||
|
||||
if(text.contains(":010000")) //contains fuse info
|
||||
{
|
||||
QStringList stl = text.split(":01000000");
|
||||
|
||||
foreach (QString t, stl)
|
||||
{
|
||||
bool ok = false;
|
||||
if(!lfuse) lfuse = t.left(2).toInt(&ok,16);
|
||||
if(!hfuse && !ok) hfuse = t.left(2).toInt(&ok,16);
|
||||
if(!efuse && !ok) efuse = t.left(2).toInt(&ok,16);
|
||||
}
|
||||
if (text.contains(":010000")) {
|
||||
//contains fuse info
|
||||
QStringList stl = text.split(":01000000");
|
||||
foreach (QString t, stl) {
|
||||
bool ok = false;
|
||||
if (!lfuse) lfuse = t.left(2).toInt(&ok,16);
|
||||
if (!hfuse && !ok) hfuse = t.left(2).toInt(&ok,16);
|
||||
if (!efuse && !ok) efuse = t.left(2).toInt(&ok,16);
|
||||
}
|
||||
}
|
||||
|
||||
if (text.contains("-E-")) {
|
||||
|
@ -276,9 +277,11 @@ QString avrOutputDialog::getProgrammer()
|
|||
EEPROMInterface *eepromInterface = GetEepromInterface();
|
||||
if (IS_TARANIS(eepromInterface->getBoard())) {
|
||||
return "DFU Util";
|
||||
} else if (eepromInterface->getBoard()==BOARD_SKY9X) {
|
||||
}
|
||||
else if (eepromInterface->getBoard()==BOARD_SKY9X) {
|
||||
return "SAM-BA";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return "AVRDUDE";
|
||||
}
|
||||
}
|
||||
|
@ -298,25 +301,31 @@ void avrOutputDialog::errorWizard()
|
|||
DeviceStr="Atmega 64";
|
||||
FwStr="\n"+tr("ie: OpenTX for 9X board or OpenTX for 9XR board");
|
||||
fwexist=true;
|
||||
} else if (DeviceId=="0x1e9702") {
|
||||
}
|
||||
else if (DeviceId=="0x1e9702") {
|
||||
DeviceStr="Atmega 128";
|
||||
FwStr="\n"+tr("ie: OpenTX for M128 / 9X board or OpenTX for 9XR board with M128 chip");
|
||||
fwexist=true;
|
||||
} else if (DeviceId=="0x1e9703") {
|
||||
}
|
||||
else if (DeviceId=="0x1e9703") {
|
||||
DeviceStr="Atmega 1280";
|
||||
} else if (DeviceId=="0x1e9704") {
|
||||
}
|
||||
else if (DeviceId=="0x1e9704") {
|
||||
DeviceStr="Atmega 1281";
|
||||
} else if (DeviceId=="0x1e9801") {
|
||||
}
|
||||
else if (DeviceId=="0x1e9801") {
|
||||
DeviceStr="Atmega 2560";
|
||||
FwStr="\n"+tr("ie: OpenTX for Gruvin9X board");
|
||||
fwexist=true;
|
||||
} else if (DeviceId=="0x1e9802") {
|
||||
}
|
||||
else if (DeviceId=="0x1e9802") {
|
||||
DeviceStr="Atmega 2561";
|
||||
}
|
||||
}
|
||||
if (fwexist==false) {
|
||||
QMessageBox::warning(this, "Companion - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease check advanced burn options to set the correct cpu type.").arg(DeviceStr));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
FirmwareInfo *firmware = GetCurrentFirmware();
|
||||
QMessageBox::warning(this, "Companion - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease select an appropriate firmware type to program it.").arg(DeviceStr)+FwStr+tr("\nYou are currently using:\n %1").arg(firmware->name));
|
||||
}
|
||||
|
@ -333,7 +342,7 @@ void avrOutputDialog::doAddTextStdErr()
|
|||
|
||||
currLine.append(text);
|
||||
if (currLine.contains("#")) {
|
||||
avrphase=currLine.left(1).toLower();
|
||||
avrphase = currLine.left(1).toLower();
|
||||
if (avrphase=="w") {
|
||||
ui->progressBar->setStyleSheet("QProgressBar {text-align: center;} QProgressBar::chunk { background-color: #ff0000; text-align:center;}:");
|
||||
phase=1;
|
||||
|
@ -344,14 +353,15 @@ void avrOutputDialog::doAddTextStdErr()
|
|||
pbvalue=currLine.count("#")*2;
|
||||
ui->progressBar->setValue(pbvalue);
|
||||
}
|
||||
if (avrphase=="r") {
|
||||
else if (avrphase=="r") {
|
||||
if (phase==0) {
|
||||
ui->progressBar->setStyleSheet("QProgressBar {text-align: center;} QProgressBar::chunk { background-color: #00ff00; text-align:center;}:");
|
||||
if(winTitle.isEmpty())
|
||||
setWindowTitle(getProgrammer() + " - " + tr("Reading"));
|
||||
else
|
||||
setWindowTitle(getProgrammer() + " - " + winTitle + " - " + tr("Reading"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ui->progressBar->setStyleSheet("QProgressBar {text-align: center;} QProgressBar::chunk { background-color: #0000ff; text-align:center;}:");
|
||||
phase=2;
|
||||
if(winTitle.isEmpty())
|
||||
|
@ -363,11 +373,12 @@ void avrOutputDialog::doAddTextStdErr()
|
|||
ui->progressBar->setValue(pbvalue);
|
||||
}
|
||||
}
|
||||
|
||||
if (currLine.contains("\n")) {
|
||||
nlPos=currLine.lastIndexOf("\n");
|
||||
prevLine=currLine.left(nlPos).trimmed();
|
||||
currLine=currLine.mid(nlPos+1);
|
||||
nlPos = currLine.lastIndexOf("\n");
|
||||
currLine = currLine.mid(nlPos+1);
|
||||
}
|
||||
|
||||
if (text.contains("-E-") && !text.contains("-E- No receive file name")) {
|
||||
hasErrors = true;
|
||||
}
|
||||
|
@ -376,6 +387,7 @@ void avrOutputDialog::doAddTextStdErr()
|
|||
}
|
||||
|
||||
#define HLINE_SEPARATOR "================================================================================="
|
||||
|
||||
void avrOutputDialog::doFinished(int code=0)
|
||||
{
|
||||
addText("\n" HLINE_SEPARATOR);
|
||||
|
@ -385,17 +397,22 @@ void avrOutputDialog::doFinished(int code=0)
|
|||
if (code) {
|
||||
ui->checkBox->setChecked(true);
|
||||
addText("\n" + getProgrammer() + " " + tr("done - exit code %1").arg(code));
|
||||
} else if (hasErrors) {
|
||||
}
|
||||
else if (hasErrors) {
|
||||
ui->checkBox->setChecked(true);
|
||||
addText("\n" + getProgrammer() + " " + tr("done with errors"));
|
||||
} else if (!cmdLine.isEmpty()) {
|
||||
}
|
||||
else if (!cmdLine.isEmpty()) {
|
||||
addText("\n" + getProgrammer() + " " + tr("done - SUCCESSFUL"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
addText(tr("done - SUCCESSFUL"));
|
||||
}
|
||||
addText("\n" HLINE_SEPARATOR "\n");
|
||||
|
||||
if(lfuse || hfuse || efuse) addReadFuses();
|
||||
if(lfuse || hfuse || efuse) {
|
||||
addReadFuses();
|
||||
}
|
||||
|
||||
switch(closeOpt)
|
||||
{
|
||||
|
@ -417,7 +434,8 @@ void avrOutputDialog::doFinished(int code=0)
|
|||
if (!cmdLine.isEmpty()) {
|
||||
if (getProgrammer()!="AVRDUDE") {
|
||||
QMessageBox::critical(this, "Companion", getProgrammer() + " " + tr("did not finish correctly"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int res = QMessageBox::question(this, "Companion",getProgrammer() + " " + tr("did not finish correctly!\nDo you want some help ?"),QMessageBox::Yes | QMessageBox::No);
|
||||
if (res != QMessageBox::No) {
|
||||
errorWizard();
|
||||
|
@ -427,12 +445,14 @@ void avrOutputDialog::doFinished(int code=0)
|
|||
QMessageBox::critical(this, "Companion", tr("Copy did not finish correctly"));
|
||||
}
|
||||
// reject();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!cmdLine.isEmpty()) {
|
||||
ui->progressBar->setValue(100);
|
||||
ui->progressBar->setValue(ui->progressBar->maximum());
|
||||
QMessageBox::information(this, "Companion", getProgrammer() + " " + tr("finished correctly"));
|
||||
accept();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
QMessageBox::information(this, "Companion", tr("Copy finished correctly"));
|
||||
accept();
|
||||
}
|
||||
|
@ -454,8 +474,6 @@ void avrOutputDialog::doProcessStarted()
|
|||
addText("\n" HLINE_SEPARATOR "\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void avrOutputDialog::addReadFuses()
|
||||
{
|
||||
addText(HLINE_SEPARATOR "\n");
|
||||
|
@ -463,19 +481,23 @@ void avrOutputDialog::addReadFuses()
|
|||
addText("\n" HLINE_SEPARATOR "\n");
|
||||
}
|
||||
|
||||
void avrOutputDialog::on_checkBox_toggled(bool checked) {
|
||||
void avrOutputDialog::on_checkBox_toggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
ui->plainTextEdit->show();
|
||||
} else {
|
||||
ui->plainTextEdit->hide();
|
||||
QTimer::singleShot(0, this, SLOT(shrink()));
|
||||
ui->plainTextEdit->show();
|
||||
}
|
||||
else {
|
||||
ui->plainTextEdit->hide();
|
||||
QTimer::singleShot(0, this, SLOT(shrink()));
|
||||
}
|
||||
}
|
||||
|
||||
void avrOutputDialog::shrink() {
|
||||
void avrOutputDialog::shrink()
|
||||
{
|
||||
resize(0,0);
|
||||
}
|
||||
|
||||
void avrOutputDialog::forceClose() {
|
||||
accept();;
|
||||
void avrOutputDialog::forceClose()
|
||||
{
|
||||
accept();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue