Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions codeloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ bool CodeLoader::lispErase(int size)
if (erRes == -10) {
msg = tr("Erase timed out");
} else if (erRes == -1) {
msg = tr("Erasing Lisp Code failed");
msg = tr("Erasing LispBM Code failed");
}

mVesc->emitMessageDialog(tr("Erase Lisp"), msg, false);
mVesc->emitMessageDialog(tr("Erase LispBM"), msg, false);
return false;
}

Expand Down Expand Up @@ -142,13 +142,13 @@ QString CodeLoader::reduceLispFile(QString fileData)
int fileNum = QDir("lispReduceBefore").
entryInfoList(QDir::NoFilter, QDir::Name).size();

QFile fBefore(QString("lispReduceBefore/lispBeforeReduce%1.lisp").arg(fileNum));
QFile fBefore(QString("lispReduceBefore/lispBeforeReduce%1.lbm").arg(fileNum));
if (fBefore.open(QIODevice::WriteOnly | QIODevice::Text)) {
fBefore.write(fileData.toUtf8());
fBefore.close();
}

QFile fAfter(QString("lispReduceAfter/lispAfterReduce%1.lisp").arg(fileNum));
QFile fAfter(QString("lispReduceAfter/lispAfterReduce%1.lbm").arg(fileNum));
if (fAfter.open(QIODevice::WriteOnly | QIODevice::Text)) {
fAfter.write(res.toUtf8());
fAfter.close();
Expand Down Expand Up @@ -270,7 +270,9 @@ QByteArray CodeLoader::lispPackImports(QString codeStr, QString editorPath, bool
}
}
} else {
if (reduceLisp && fi.absoluteFilePath().endsWith(".lisp", Qt::CaseInsensitive)) {
bool hasExtension = fi.absoluteFilePath().endsWith(".lbm", Qt::CaseInsensitive)
|| fi.absoluteFilePath().endsWith(".lisp", Qt::CaseInsensitive);
if (reduceLisp && hasExtension) {
fileData = reduceLispFile(QString::fromUtf8(fileData)).toUtf8();
}
fileData.append('\0'); // Pad with 0 in case it is a text file
Expand Down Expand Up @@ -365,7 +367,7 @@ bool CodeLoader::lispUpload(VByteArray vb)
data.vbAppendUint16(crc);
data.append(vb);

// The ESP32 partition table has 512k space for lisp scripts. The STM32
// The ESP32 partition table has 512k space for LispBM scripts. The STM32
// has one 128k flash page. Subtract 6 bytes for fw size and crc.
auto fwParams = mVesc->getLastFwRxParams();
int max_size = 1024 * 512 - 6;
Expand Down Expand Up @@ -597,7 +599,7 @@ QString CodeLoader::lispRead(QWidget *parent, QString &lispPath)
QString dirName = QFileDialog::getExistingDirectory(parent, tr("Choose Directory"));

if (!dirName.isEmpty()) {
QFile fileLisp(dirName + "/From VESC.lisp");
QFile fileLisp(dirName + "/From VESC.lbm");
if (!fileLisp.exists()) {
if (fileLisp.open(QIODevice::WriteOnly)) {
fileLisp.write(res.toUtf8());
Expand Down Expand Up @@ -651,8 +653,8 @@ QString CodeLoader::lispRead(QWidget *parent, QString &lispPath)
}
}

mVesc->emitMessageDialog(tr("Get Lisp"),
tr("Could not read Lisp code"),
mVesc->emitMessageDialog(tr("Get LispBM"),
tr("Could not read LispBM code"),
false);

disconnect(conn);
Expand Down Expand Up @@ -1165,15 +1167,15 @@ bool CodeLoader::createPackageFromDescription(QString path, VescPackage *pkgRes,

// Empty array means an error. Otherwise, lispPackImports() always returns data.
if (pkg.lispData.isEmpty()) {
qWarning() << "Errors when processing lisp imports.";
qWarning() << "Errors when processing LispBM imports.";
result = false;
}

f.close();

qDebug() << "Package lisp found and parsed!";
qDebug() << "Package LispBM found and parsed!";
} else {
qWarning() << "Could not open lisp file.";
qWarning() << "Could not open LispBM file.";
result = false;
}
}
Expand Down
33 changes: 17 additions & 16 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ static void showHelp()
qDebug() << "--getCustomConf [confPath] : Connect and read custom configuration 1 and store the XML to confPath.";
qDebug() << "--setCustomConf [confPath] : Connect and write custom configuration 1 XML from confPath.";
qDebug() << "--debugOutFile [path] : Print debug output to file with path.";
qDebug() << "--uploadLisp [path] : Upload lisp-script.";
qDebug() << "--uploadLisp [path] : Upload LispBM script.";
qDebug() << "--reduceLisp : Reduce LispBM file size by removing comments, spaces and imports.";
qDebug() << "--eraseLisp : Erase lisp-script.";
qDebug() << "--eraseLisp : Erase LispBM script.";
qDebug() << "--uploadFirmware [path] : Upload firmware-file from path.";
qDebug() << "--uploadBootloaderBuiltin : Upload bootloader from generic included bootloaders.";
qDebug() << "--queryDeviceFwParams : Connect and print out device fw parameters.";
qDebug() << "--writeFileToSdCard [fileLocal:pathSdcard] : Write file to SD-card.";
qDebug() << "--packFirmware [fileIn:fileOut] : Pack firmware-file for compatibility with the bootloader. ";
qDebug() << "--packLisp [fileIn:fileOut] : Pack lisp-file and the included imports.";
qDebug() << "--bridgeAppData : Send app data (such as data from send-data in lisp) to stdout.";
qDebug() << "--packLisp [fileIn:fileOut] : Pack LispBM file and the included imports.";
qDebug() << "--bridgeAppData : Send app data (such as data from send-data in LispBM) to stdout.";
qDebug() << "--offscreen : Use offscreen QPA so that X is not required for the CLI-mode.";
qDebug() << "--downloadPackageArchive : Download package archive to application data directory.";
}
Expand Down Expand Up @@ -859,8 +859,9 @@ int main(int argc, char *argv[])
}

if (!lispPackIn.isEmpty()) {
if (!lispPackIn.endsWith(".lisp", Qt::CaseInsensitive)) {
qWarning() << "Warning: Unexpected file extension for a lisp-file.";
if (!lispPackIn.endsWith(".lbm", Qt::CaseInsensitive)
&& !lispPackIn.endsWith(".lisp", Qt::CaseInsensitive)) {
qWarning() << "Warning: Unexpected file extension for a LispBM file.";
}

QFile fIn(lispPackIn);
Expand Down Expand Up @@ -942,20 +943,20 @@ int main(int argc, char *argv[])
if (!lispPath.isEmpty()) {
QFile f(lispPath);
if (!f.open(QIODevice::ReadOnly)) {
qWarning() << "Could not open lisp file for reading.";
qWarning() << "Could not open LispBM file for reading.";
return 1;
}

QFileInfo fi(f);
pkg.lispData = loader.lispPackImports(f.readAll(), fi.canonicalPath(), reduceLisp);
// Empty array means an error. Otherwise, CodeLoader.lispPackImports() always returns data.
if (pkg.lispData.isEmpty()) {
qWarning() << "Errors when processing lisp imports.";
qWarning() << "Errors when processing LispBM imports.";
return 1;
}
f.close();

qDebug() << "Read lisp script done";
qDebug() << "Read LispBM script done";
}

if (!qmlPath.isEmpty()) {
Expand Down Expand Up @@ -1157,9 +1158,9 @@ int main(int argc, char *argv[])

if (eraseLisp) {
if (loader.lispErase(16)) {
qDebug() << "Lisp erase OK!";
qDebug() << "LispBM erase OK!";
} else {
qWarning() << "Could not erase lisp";
qWarning() << "Could not erase LispBM";
exitCode = -10;
}
}
Expand All @@ -1176,23 +1177,23 @@ int main(int argc, char *argv[])
if (ok) {
ok = loader.lispUpload(lispData);
} else {
qWarning() << "Could not erase lisp";
qWarning() << "Could not erase LispBM";
exitCode = -10;
}
if (ok) {
qDebug() << "Lisp upload OK!";
qDebug() << "LispBM upload OK!";
vesc->commands()->lispSetRunning(1);
Utility::sleepWithEventLoop(100);
} else {
qWarning() << "Could not upload lisp";
qWarning() << "Could not upload LispBM";
exitCode = -11;
}
} else {
qWarning() << "Empty or invalid lisp-file.";
qWarning() << "Empty or invalid LispBM file.";
exitCode = -12;
}
} else {
qWarning() << "Could not open lisp file for reading.";
qWarning() << "Could not open LispBM file for reading.";
exitCode = -13;
}
}
Expand Down
4 changes: 2 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
if (mPageLisp->hasUnsavedTabs()) {
QMessageBox::StandardButton answer = QMessageBox::question(
this,
tr("Unsaved Lisp-Tabs"),
tr("There are unsaved Lisp-tabs open. Do you want to close "
tr("Unsaved LispBM Tabs"),
tr("There are unsaved LispBM tabs open. Do you want to close "
"VESC Tool without saving them?"),
QMessageBox::Yes | QMessageBox::Cancel
);
Expand Down
4 changes: 2 additions & 2 deletions pages/pageespprog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@ void PageEspProg::listAllFw()
void PageEspProg::on_eraseLispButton_clicked()
{
ui->eraseLispButton->setEnabled(false);
ui->progWidget->setText("Erasing Lisp...");
ui->progWidget->setText("Erasing LispBM...");
ui->progWidget->setValue(0.0);
mEspFlash.eraseFlash(512 * 1024, ui->lispOffsetBox->value());
ui->eraseLispButton->setEnabled(true);
ui->progWidget->setText("Done erasing Lisp!");
ui->progWidget->setText("Done erasing LispBM!");
}

void PageEspProg::on_eraseQmlButton_clicked()
Expand Down
4 changes: 2 additions & 2 deletions pages/pageespprog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
<item>
<widget class="QPushButton" name="eraseLispButton">
<property name="text">
<string>Erase Lisp</string>
<string>Erase LispBM</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -376,7 +376,7 @@
<item>
<widget class="QSpinBox" name="lispOffsetBox">
<property name="prefix">
<string>Lisp: 0x</string>
<string>LispBM: 0x</string>
</property>
<property name="maximum">
<number>9999999</number>
Expand Down
16 changes: 8 additions & 8 deletions pages/pagelisp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ PageLisp::PageLisp(QWidget *parent) :
updateRecentList();

// Load examples
foreach (auto &fi, QDir("://res/Lisp/Examples/").entryInfoList(QDir::NoFilter, QDir::Name)) {
foreach (auto &fi, QDir("://res/LispBM/Examples/").entryInfoList(QDir::NoFilter, QDir::Name)) {
QListWidgetItem *item = new QListWidgetItem;
item->setText(fi.fileName());
item->setData(Qt::UserRole, fi.filePath());
Expand Down Expand Up @@ -229,8 +229,8 @@ void PageLisp::setVesc(VescInterface *vesc)

connect(mVesc->commands(), &Commands::lispRunningResRx, [this](bool ok) {
if (!ok) {
mVesc->emitMessageDialog(tr("Start/Stop Lisp"),
tr("Start/Stop Lisp failed. Did you forget to upload the code?"), false);
mVesc->emitMessageDialog(tr("Start/Stop LispBM"),
tr("Start/Stop LispBM failed. Did you forget to upload the code?"), false);
}
});

Expand Down Expand Up @@ -511,7 +511,7 @@ void PageLisp::openExample()
QFile file(item->data(Qt::UserRole).toString());

if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, "Open Lisp File",
QMessageBox::critical(this, "Open LispBM File",
"Could not open example for reading");
return;
}
Expand All @@ -534,7 +534,7 @@ void PageLisp::openRecentList()
QFile file(fileName);

if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, "Open Lisp File",
QMessageBox::critical(this, "Open LispBM File",
"Could not open\n " + fileName + " for reading");
return;
}
Expand Down Expand Up @@ -739,13 +739,13 @@ void PageLisp::on_rescaleButton_clicked()

void PageLisp::on_helpButton_clicked()
{
QString html = "<b>VESC Lisp Editor</b><br><br>"
QString html = "<b>VESC LispBM Editor</b><br><br>"
""
"For documentation, go to<br>"
"<a href=\"https://github.com/vedderb/bldc/blob/master/lispBM/README.md\">https://github.com/vedderb/bldc/blob/master/lispBM/README.md</a><br><br>"
""
"You can also join the unofficial VESC Discord server and ask questions "
"in the lisp-scripting chat at<br>"
"in the lisp-and-qml-scripting chat at<br>"
"<a href=\"https://discord.gg/JgvV5NwYts\">https://discord.gg/JgvV5NwYts</a><br><br>"
"<b>Keyboard Commands</b><br>"
"Ctrl + '+' : Increase font size<br>"
Expand Down Expand Up @@ -857,7 +857,7 @@ void PageLisp::on_infoButton_clicked()
"Reduction enabled : %3<br>"
"<br>"
"The sizes include the size of all imports. All "
"imports that end with .lisp are also reduced. "
"imports that end with .lbm or .lisp are also reduced. "
"The reduction option can be enabled in the preferences."
).arg(vbNoReduce.size()).
arg(vbReduce.size()).
Expand Down
4 changes: 2 additions & 2 deletions pages/pagelisp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<item>
<widget class="QPushButton" name="eraseButton">
<property name="toolTip">
<string>Erase lisp application from VESC. This will also prevent it from starting on next boot (as expected).</string>
<string>Erase LispBM application from VESC. This will also prevent it from starting on next boot (as expected).</string>
</property>
<property name="text">
<string>Erase</string>
Expand Down Expand Up @@ -72,7 +72,7 @@
<item>
<widget class="QPushButton" name="readExistingButton">
<property name="toolTip">
<string>Read lisp code from connected VESC</string>
<string>Read LispBM code from connected VESC</string>
</property>
<property name="text">
<string>Read</string>
Expand Down
8 changes: 4 additions & 4 deletions pages/pagevescpackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ void PageVescPackage::on_chooseLoadButton_clicked()
void PageVescPackage::on_chooseLispButton_clicked()
{
QString filename = QFileDialog::getOpenFileName(this,
tr("Choose Lisp File"), ui->lispEdit->text(),
tr("Lisp files (*.lisp)"));
tr("Choose LispBM File"), ui->lispEdit->text(),
tr("LispBM files (*.lbm *.lisp)"));
if (!filename.isNull()) {
ui->lispEdit->setText(filename);
}
Expand Down Expand Up @@ -213,7 +213,7 @@ void PageVescPackage::on_saveButton_clicked()
QFile f(ui->lispEdit->text());
if (!f.open(QIODevice::ReadOnly)) {
mVesc->emitMessageDialog(tr("Save Package"),
tr("Could not open lisp file for reading."),
tr("Could not open LispBM file for reading."),
false, false);
return;
}
Expand Down Expand Up @@ -482,7 +482,7 @@ void PageVescPackage::packageSelected(VescPackage pkg)
ui->installButton->setToolTip("");
} else {
ui->installButton->setToolTip("This is a library, so it is not supposed to be installed. You can use "
"it from your own LispBM-scripts without installing it.");
"it from your own LispBM scripts without installing it.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion pages/pagevescpackage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
<item>
<widget class="QGroupBox" name="lispBox">
<property name="title">
<string>Lisp</string>
<string>LispBM</string>
</property>
<property name="checkable">
<bool>true</bool>
Expand Down
4 changes: 2 additions & 2 deletions res/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
### 6.06
#### Released TBD
* Auto-save UI-state on regular intervals.
* Movable lisp-tabs and better tab behavior in general.
* Movable LispBM tabs and better tab behavior in general.
* Detect file system changes in script editor.
* Duplicate line shortcut in script editor.
* Use temperature convention on BMS page.
* Show Min, Max and Diff voltage on BMS page.
* Support building VESC Packages from QML description file.
* Filter package store based on rules from QML description.
* Added option to reduce Lisp file size by removing comments, spaces and imports.
* Added option to reduce LispBM file size by removing comments, spaces and imports.
* Disable motor commands after using the stop button or ESC key for 5 seconds (configurable in preferences).
* Show dialog with package description in mobile UI when installing from file.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; Balance robot controller written in lisp
; Balance robot controller written in LispBM

(defun #abs (x) (if (> x 0) x (- x)))

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; This is how to print a string in LispBM to the console below
(print "Hello World!")

; You can also print lisp types, such as the list (1 2 3 4 5)
; You can also print other types, such as the list (1 2 3 4 5)
(print (list 1 2 3 4 5))

; Here we print the index of a range loop
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
(defun test () {
(var ts (systime))
(repeat '(sort2 < numbers) 50)
(print (list "Lisp" (secs-since ts)))
(print (list "LispBM" (secs-since ts)))

(var ts (systime))
(repeat '(sort < numbers) 50)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading