Skip to content

Commit

Permalink
Added display of address and percentage on the progress bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
esden committed Aug 22, 2014
1 parent d8c414d commit 61a7493
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dfu_manager.cpp
Expand Up @@ -217,7 +217,7 @@ void DFUManager::flash(QString *filename)
dfu_makeidle(handle, iface);

for (bindata_offset = 0; bindata_offset < binfile_content.size(); bindata_offset += block_size) {
emit flashProgressUpdate((bindata_offset*100)/binfile_content.size());
emit flashProgressUpdate(LOAD_ADDRESS + bindata_offset, (bindata_offset*100)/binfile_content.size());
if (stm32_mem_erase(handle, iface, LOAD_ADDRESS + bindata_offset) != 0) {
/* TODO: emit error */

Expand Down
2 changes: 1 addition & 1 deletion dfu_manager.h
Expand Up @@ -51,7 +51,7 @@ class DFUManager : public QObject
void foundDevice(QString *string);
void lostDevice();
void finishedFlash();
void flashProgressUpdate(int percentage);
void flashProgressUpdate(int address, int percentage);

private slots:
void findIFace();
Expand Down
5 changes: 3 additions & 2 deletions mainwindow.cpp
Expand Up @@ -44,7 +44,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(&dfu_manager, SIGNAL(lostDevice()), this, SLOT(lostDevice()));
connect(&dfu_thread, SIGNAL(started()), &dfu_manager, SLOT(start()));
connect(&dfu_manager, SIGNAL(finishedFlash()), this, SLOT(finishedFlash()));
connect(&dfu_manager, SIGNAL(flashProgressUpdate(int)), this, SLOT(onFlashProgressUpdate(int)));
connect(&dfu_manager, SIGNAL(flashProgressUpdate(int, int)), this, SLOT(onFlashProgressUpdate(int, int)));
connect(this, SIGNAL(doFlash(QString*)), &dfu_manager, SLOT(flash(QString*)));

dfu_thread.start();
Expand Down Expand Up @@ -131,7 +131,8 @@ void MainWindow::finishedFlash()
ui->label_Iface->setText("Done Flashing!");
}

void MainWindow::onFlashProgressUpdate(int percent)
void MainWindow::onFlashProgressUpdate(int address, int percent)
{
ui->label_Iface->setText(QString("Flashing address 0x%1 %2%").arg(QString::number(address, 16)).arg(percent));
ui->progressBar->setValue(percent);
}
2 changes: 1 addition & 1 deletion mainwindow.h
Expand Up @@ -51,7 +51,7 @@ private slots:
void lostDevice();
void flash();
void finishedFlash();
void onFlashProgressUpdate(int percent);
void onFlashProgressUpdate(int address, int percent);
};

#endif // MAINWINDOW_H
6 changes: 6 additions & 0 deletions mainwindow.ui
Expand Up @@ -86,6 +86,12 @@
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>true</bool>
</property>
<property name="format">
<string>%p%</string>
</property>
</widget>
</item>
<item row="1" column="1">
Expand Down

0 comments on commit 61a7493

Please sign in to comment.