Skip to content

Commit 91437c7

Browse files
committed
Added sampled data CSV export button and SWD prog erase flash button
1 parent c34ca3b commit 91437c7

File tree

9 files changed

+113
-4
lines changed

9 files changed

+113
-4
lines changed

android/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<manifest package="vedder.vesctool" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.15" android:versionCode="24" android:installLocation="auto">
2+
<manifest package="vedder.vesctool" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.15" android:versionCode="22" android:installLocation="auto">
33
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="VESC Tool" android:icon="@drawable/icon">
44
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="VESC Tool" android:screenOrientation="unspecified" android:launchMode="singleTop">
55
<intent-filter>

pages/pagesampleddata.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,56 @@ void PageSampledData::on_plotModeBox_currentIndexChanged(int index)
644644
{
645645
ui->currentStack->setCurrentIndex(index == 2 ? 1 : 0);
646646
}
647+
648+
void PageSampledData::on_saveDataButton_clicked()
649+
{
650+
QString fileName = QFileDialog::getSaveFileName(this,
651+
tr("Save CSV"), "",
652+
tr("CSV Files (*.csv)"));
653+
654+
if (!fileName.isEmpty()) {
655+
if (!fileName.toLower().endsWith(".csv")) {
656+
fileName.append(".csv");
657+
}
658+
659+
QFile file(fileName);
660+
if (!file.open(QIODevice::WriteOnly)) {
661+
QMessageBox::critical(this, "Save CSV File",
662+
"Could not open\n" + fileName + "\nfor writing");
663+
return;
664+
}
665+
666+
QTextStream stream(&file);
667+
stream.setCodec("UTF-8");
668+
669+
// Generate Time axis
670+
QVector<double> timeVec;
671+
timeVec.resize(fSwVector.size());
672+
double prev_t = 0.0;
673+
for (int i = 0;i < timeVec.size();i++) {
674+
timeVec[i] = prev_t;
675+
prev_t += 1.0 / fSwVector[i];
676+
}
677+
678+
stream << "T;I1;I2;I3;V1;V2;V3;I_tot;V_zero;Phase\n";
679+
680+
for (int i = 0;i < curr1Vector.size();i++) {
681+
stream << timeVec.at(i) << ";";
682+
stream << curr1Vector.at(i) << ";";
683+
stream << curr2Vector.at(i) << ";";
684+
stream << -(curr1Vector.at(i) + curr2Vector.at(i)) << ";";
685+
stream << ph1Vector.at(i) << ";";
686+
stream << ph2Vector.at(i) << ";";
687+
stream << ph3Vector.at(i) << ";";
688+
stream << currTotVector.at(i) << ";";
689+
stream << vZeroVector.at(i) << ";";
690+
stream << (double)((quint8)phaseArray.at(i)) / 250.0 * 360.0 << ";";
691+
692+
if (i < (curr1Vector.size() - 1)) {
693+
stream << "\n";
694+
}
695+
}
696+
697+
file.close();
698+
}
699+
}

pages/pagesampleddata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private slots:
5858
void on_rescaleButton_clicked();
5959
void on_filterLogScaleBox_toggled(bool checked);
6060
void on_plotModeBox_currentIndexChanged(int index);
61+
void on_saveDataButton_clicked();
6162

6263
private:
6364
Ui::PageSampledData *ui;

pages/pagesampleddata.ui

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>591</width>
9+
<width>613</width>
1010
<height>472</height>
1111
</rect>
1212
</property>
@@ -637,6 +637,26 @@
637637
</property>
638638
</spacer>
639639
</item>
640+
<item>
641+
<widget class="QPushButton" name="saveDataButton">
642+
<property name="sizePolicy">
643+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
644+
<horstretch>0</horstretch>
645+
<verstretch>0</verstretch>
646+
</sizepolicy>
647+
</property>
648+
<property name="toolTip">
649+
<string>Save samples to CSV file...</string>
650+
</property>
651+
<property name="text">
652+
<string/>
653+
</property>
654+
<property name="icon">
655+
<iconset resource="../res.qrc">
656+
<normaloff>:/res/icons/Save as-96.png</normaloff>:/res/icons/Save as-96.png</iconset>
657+
</property>
658+
</widget>
659+
</item>
640660
</layout>
641661
</item>
642662
<item>

pages/pageswdprog.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ void PageSwdProg::fwUploadStatus(const QString &status, double progress, bool is
196196
ui->display->setValue(progress * 100.0);
197197

198198
ui->connectButton->setEnabled(!isOngoing);
199+
ui->eraseFlashButton->setEnabled(!isOngoing);
199200
ui->disconnectButton->setEnabled(!isOngoing);
200201
ui->uploadButton->setEnabled(!isOngoing);
201202
}
@@ -312,3 +313,21 @@ void PageSwdProg::addSwdFw(QString name, QString path, uint32_t addr, QString bl
312313
item->setData(Qt::UserRole, QVariant::fromValue(fw));
313314
ui->fwList->insertItem(ui->fwList->count(), item);
314315
}
316+
317+
void PageSwdProg::on_eraseFlashButton_clicked()
318+
{
319+
if (mVesc) {
320+
if (!mVesc->isPortConnected()) {
321+
QMessageBox::critical(this,
322+
tr("Connection Error"),
323+
tr("The VESC is not connected."));
324+
return;
325+
}
326+
327+
if (mVesc->swdEraseFlash()) {
328+
QMessageBox::information(this,
329+
tr("Erase Flash"),
330+
tr("The flash memory on the target was erased successfully!"));
331+
}
332+
}
333+
}

pages/pageswdprog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ private slots:
6262
void on_uploadButton_clicked();
6363
void on_disconnectButton_clicked();
6464
void on_cancelButton_clicked();
65+
void on_eraseFlashButton_clicked();
6566

6667
private:
6768
Ui::PageSwdProg *ui;

pages/pageswdprog.ui

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,21 @@
170170
</property>
171171
</widget>
172172
</item>
173+
<item>
174+
<widget class="QPushButton" name="eraseFlashButton">
175+
<property name="text">
176+
<string>Erase Only</string>
177+
</property>
178+
<property name="icon">
179+
<iconset resource="../res.qrc">
180+
<normaloff>:/res/icons/Delete-96.png</normaloff>:/res/icons/Delete-96.png</iconset>
181+
</property>
182+
</widget>
183+
</item>
173184
<item>
174185
<widget class="QPushButton" name="uploadButton">
175186
<property name="text">
176-
<string>Upload</string>
187+
<string>Erase &amp;&amp; Upload</string>
177188
</property>
178189
<property name="icon">
179190
<iconset resource="../res.qrc">

res/CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
== 1.16 ==
2+
* Added support to export sampled data as CSV.
3+
* Added erase only button to SWD prog.
4+
15
== 1.15 ==
26
* Keep screen on setting on android.
37
* Added support for imperial units.

vesc_tool.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#-------------------------------------------------
66

77
# Version
8-
VT_VERSION = 1.15
8+
VT_VERSION = 1.16
99
VT_INTRO_VERSION = 1
1010

1111
VT_ANDROID_VERSION_ARMV7 = 22

0 commit comments

Comments
 (0)